Skip to content

Commit

Permalink
Merge pull request #146 from iced-rs/main
Browse files Browse the repository at this point in the history
updating to lastest main
  • Loading branch information
Andrew Wheeler(Genusis) authored Jul 12, 2023
2 parents 6dd25e2 + e5a671b commit 1a01e19
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 91 deletions.
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

0 comments on commit 1a01e19

Please sign in to comment.