Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating to lastest main #146

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ on: [push, pull_request]
jobs:
all:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly]
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
rust-version: stable
components: clippy
- uses: actions/checkout@master
- name: Lint with clippy
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ on: [push, pull_request]
jobs:
all:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly]
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
rust-version: stable
components: rustfmt
- uses: actions/checkout@master
- name: Check format
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/rustdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@ jobs:
uses: actions/checkout@v1

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: hecrj/setup-rust-action@v1
with:
toolchain: nightly
profile: minimal
override: true
rust-version: stable
components: rustfmt, rust-src
- uses: Swatinem/rust-cache@v1
- name: Build Documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: --all --no-deps
run: cargo doc --all --no-deps
- name: Add index.html
run: echo '<meta http-equiv=refresh content=0;url=iced_aw/index.html>' > target/doc/index.html
- name: Deploy Documentation
Expand Down
66 changes: 27 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,60 +30,54 @@ iced_aw = { version = "0.5", default-features = false, features = [...] }

### Badge

<center>

![Badge showcase](./images/showcase/badge.png)

</center>
<div align="center">

![Badge showcase](./images/showcase/badge.png)
</div>

Please take a look into our examples on how to use badges.

Enable this widget with the feature `badge`.

### Card

<center>

<div align="center">
![Card showcase](./images/showcase/card.png)

</center>

</div>

Please take a look into our examples on how to use cards.

Enable this widget with the feature `card`.

### Color Picker

<center>
<div align="center">

![Color Picker showcase](./images/showcase/color_picker.png)

</center>
</div>

Please take a look into our examples on how to use color pickers.

Enable this widget with the feature `color_picker`.

### Date Picker

<center>

![Modal showcase](./images/showcase/date_picker.png)

</center>
<div align="center">

![Modal showcase](./images/showcase/date_picker.png)
</div>

Please take a look into our examples on how to use date pickers.

Enable this widget with the feature `date_picker`.

### Floating Action Button

<center>
<div align="center">

![Floating Element showcase](./images/showcase/floating_button.png)

</center>
</div>

Please take a look into our examples on how to use floating elements.

Expand All @@ -93,11 +87,10 @@ Enable this widget with the feature `floating_element`.

Modals are useful for showing some content as an overlay on top. In combination with the Card widget, modals can be used to create some kind of dialog panels.

<center>
<div align="center">

![Modal showcase](./images/showcase/modal.png)

</center>
</div>


Please take a look into our examples on how to use modals.
Expand All @@ -108,11 +101,10 @@ Enable this widget with the feature `modal`.

Just like TextInput, but only for numbers.

<center>
<div align="center">

![NumberInput showcase](./images/showcase/number_input.png)

</center>
</div>

Please take a look into our examples on how to use number inputs.

Expand All @@ -124,11 +116,10 @@ Enable this widget with the feature `number_input`.

A split divides the available space to display two different elements.

<center>
<div align="center">

![Split showcase](./images/showcase/split_example.gif)

</center>
</div>

Please take a look into our examples on how to use Splits.

Expand All @@ -138,23 +129,21 @@ Enable Splits with the feature `split`.

### TabBar and Tabs

<center>
<div align="center">

![Tabs showcase](./images/showcase/tabs_example.gif)

</center>
</div>

Please take a look into our examples on how to use TabBars and Tabs.

Enable TabBars with the feature `tab_bar` and Tabs with `tabs`.

### Time Picker

<center>
<div align="center">

![Modal showcase](./images/showcase/time_picker.png)

</center>
</div>

Please take a look into our examples on how to use time pickers.

Expand All @@ -163,11 +152,10 @@ Enable this widget with the feature `time_picker`.

### Menu

<center>
<div align="center">

![Menu showcase](./images/showcase/menu.gif)

</center>
</div>

Please take a look into our examples on how to use menus.

Expand Down
67 changes: 43 additions & 24 deletions src/native/cupertino/cupertino_alert.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::todo)]

use iced_native::{
alignment,
event::Status,
Expand Down Expand Up @@ -158,8 +160,8 @@ where
width: Length::Fixed(400.0),
height: Length::Fixed(200.0),
is_hidden: true,
title: "Title".to_string(),
content: "Content".to_string(),
title: "Title".to_owned(),
content: "Content".to_owned(),
actions: vec![],
backdrop: None,
on_escape: None,
Expand Down Expand Up @@ -244,7 +246,7 @@ where
{
let as_text_element = element.into().font(SF_UI_ROUNDED);

return Element::from(as_text_element);
Element::from(as_text_element)
}
}

Expand All @@ -257,36 +259,36 @@ where
<Renderer as iced_native::text::Renderer>::Font: From<Font>,
{
fn width(&self) -> Length {
if !self.is_hidden {
self.width
} else {
if self.is_hidden {
Length::Fixed(0.0)
} else {
self.width
}
}

fn height(&self) -> Length {
if !self.is_hidden {
self.height
} else {
if self.is_hidden {
Length::Fixed(0.0)
} else {
self.height
}
}

fn layout(&self, _renderer: &Renderer, limits: &Limits) -> Node {
return Node::new(
Node::new(
limits
.width(if !self.is_hidden {
self.width
} else {
.width(if self.is_hidden {
Length::Fixed(0.0)
})
.height(if !self.is_hidden {
self.height
} else {
self.width
})
.height(if self.is_hidden {
Length::Fixed(0.0)
} else {
self.height
})
.resolve(Size::new(f32::INFINITY, f32::INFINITY)),
);
)
}

fn draw(
Expand Down Expand Up @@ -544,7 +546,12 @@ where

if hit_x.contains(&cursor_position.x) && hit_y.contains(&cursor_position.y)
{
shell.publish(self.actions[0].on_pressed.clone().unwrap());
shell.publish(
self.actions[0]
.on_pressed
.clone()
.expect("Unable to retrieve the left button click message"),
);
}
}

Expand All @@ -557,7 +564,12 @@ where

if hit_x.contains(&cursor_position.x) && hit_y.contains(&cursor_position.y)
{
shell.publish(self.actions[1].on_pressed.clone().unwrap());
shell.publish(
self.actions[1]
.on_pressed
.clone()
.expect("Unable to retrieve the right button click message"),
);
}
}
}
Expand All @@ -569,7 +581,11 @@ where

if !hit_x.contains(&cursor_position.x) || !hit_y.contains(&cursor_position.y) {
if self.backdrop.is_some() {
shell.publish(self.backdrop.clone().unwrap());
shell.publish(
self.backdrop
.clone()
.expect("Unable to retrieve the backdrop message"),
);
}

// Default behaviour: hide the modal after clicking on the backdrop //
Expand All @@ -581,20 +597,23 @@ where
if key_code == keyboard::KeyCode::Escape && self.on_escape.is_some() {
self.is_hidden = true;

shell.publish(self.on_escape.clone().unwrap());
shell.publish(
self.on_escape
.clone()
.expect("Unable to retrieve the escape message"),
);
return Status::Captured;
} else {
return Status::Ignored;
}
}

_ => return Status::Ignored,
}

return Status::Ignored;
Status::Ignored
}
}

#[allow(clippy::type_repetition_in_bounds)]
impl<'a, Message, Renderer: 'a> From<CupertinoAlert<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Expand Down
Loading
Loading