From 2bfe02a16269bf480865671696e71e35f942c12d Mon Sep 17 00:00:00 2001 From: f4814n Date: Sun, 9 Jul 2023 03:50:25 +0200 Subject: [PATCH 1/5] split: Remove unneeded Message: Clone bound (#141) --- src/native/split.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/native/split.rs b/src/native/split.rs index 288f61dd..c679dd8a 100644 --- a/src/native/split.rs +++ b/src/native/split.rs @@ -169,7 +169,6 @@ where impl<'a, Message, Renderer> Widget for Split<'a, Message, Renderer> where - Message: Clone, Renderer: 'a + iced_native::Renderer, Renderer::Theme: StyleSheet, { @@ -638,7 +637,7 @@ where impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Message: 'a + Clone, + Message: 'a, Renderer: 'a + iced_native::Renderer, Renderer::Theme: StyleSheet, { From c5186eb0c2bd108d8f2364342279b679a672549c Mon Sep 17 00:00:00 2001 From: Mateo Lafalce Date: Mon, 10 Jul 2023 01:01:31 +1100 Subject: [PATCH 2/5] README.md (#142) --- README.md | 66 +++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index e567b409..6f9df1cd 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,10 @@ iced_aw = { version = "0.5", default-features = false, features = [...] } ### Badge -
- -![Badge showcase](./images/showcase/badge.png) - -
+
+ + ![Badge showcase](./images/showcase/badge.png) +
Please take a look into our examples on how to use badges. @@ -42,12 +41,10 @@ Enable this widget with the feature `badge`. ### Card -
- +
+ ![Card showcase](./images/showcase/card.png) - -
- + Please take a look into our examples on how to use cards. @@ -55,11 +52,10 @@ Enable this widget with the feature `card`. ### Color Picker -
+
![Color Picker showcase](./images/showcase/color_picker.png) - -
+ Please take a look into our examples on how to use color pickers. @@ -67,11 +63,10 @@ Enable this widget with the feature `color_picker`. ### Date Picker -
- -![Modal showcase](./images/showcase/date_picker.png) - -
+
+ + ![Modal showcase](./images/showcase/date_picker.png) +
Please take a look into our examples on how to use date pickers. @@ -79,11 +74,10 @@ Enable this widget with the feature `date_picker`. ### Floating Action Button -
+
![Floating Element showcase](./images/showcase/floating_button.png) - -
+ Please take a look into our examples on how to use floating elements. @@ -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. -
+
![Modal showcase](./images/showcase/modal.png) - -
+ Please take a look into our examples on how to use modals. @@ -108,11 +101,10 @@ Enable this widget with the feature `modal`. Just like TextInput, but only for numbers. -
+
![NumberInput showcase](./images/showcase/number_input.png) - -
+ Please take a look into our examples on how to use number inputs. @@ -124,11 +116,10 @@ Enable this widget with the feature `number_input`. A split divides the available space to display two different elements. -
+
![Split showcase](./images/showcase/split_example.gif) - -
+ Please take a look into our examples on how to use Splits. @@ -138,11 +129,10 @@ Enable Splits with the feature `split`. ### TabBar and Tabs -
+
![Tabs showcase](./images/showcase/tabs_example.gif) - -
+ Please take a look into our examples on how to use TabBars and Tabs. @@ -150,11 +140,10 @@ Enable TabBars with the feature `tab_bar` and Tabs with `tabs`. ### Time Picker -
+
![Modal showcase](./images/showcase/time_picker.png) - -
+ Please take a look into our examples on how to use time pickers. @@ -163,11 +152,10 @@ Enable this widget with the feature `time_picker`. ### Menu -
+
![Menu showcase](./images/showcase/menu.gif) - -
+ Please take a look into our examples on how to use menus. From 187554bbc13d01c0c5a5426d02a2891acf62cde6 Mon Sep 17 00:00:00 2001 From: Luni-4 Date: Wed, 12 Jul 2023 13:49:42 +0200 Subject: [PATCH 3/5] Remove the deprecated actions-rs (#145) --- .github/workflows/rustdoc.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml index 56a8cb24..ff5d88fc 100644 --- a/.github/workflows/rustdoc.yml +++ b/.github/workflows/rustdoc.yml @@ -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 '' > target/doc/index.html - name: Deploy Documentation From 84f77a430840cd50f781c5658c1b3e7ee29a973f Mon Sep 17 00:00:00 2001 From: Luni-4 Date: Wed, 12 Jul 2023 13:50:22 +0200 Subject: [PATCH 4/5] Remove nightly version for clippy and format checks (#144) --- .github/workflows/clippy.yml | 5 +---- .github/workflows/format.yml | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 3a64f022..ec548b46 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -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 diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 2a0905ca..f46b1046 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -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 From e5a671bb7888be9269d6e71ff58779b4f6d0bc5f Mon Sep 17 00:00:00 2001 From: Luni-4 Date: Wed, 12 Jul 2023 13:50:35 +0200 Subject: [PATCH 5/5] Fix clippy warnings (#143) * cupertino: Remove a useless else branch * cupertino: Use to_owned instead of to_string * cupertino: Remove useless returns * cupertino: Remove unnecessary not boolean operation * cupertino: Allow the use of todo! macro in production code * cupertino: Use expect instead of unwrap with more suitable messages * cupertino: Allow type repetition * cupertino: Add #[must_use] to a self function * cupertino: Fix consistent format * cupertino: Remove useless lifetime --- src/native/cupertino/cupertino_alert.rs | 67 +++++++++++++++--------- src/native/cupertino/cupertino_button.rs | 13 +++-- src/native/cupertino/cupertino_switch.rs | 17 +++--- 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/src/native/cupertino/cupertino_alert.rs b/src/native/cupertino/cupertino_alert.rs index 132ea0b6..4e2eb4f1 100644 --- a/src/native/cupertino/cupertino_alert.rs +++ b/src/native/cupertino/cupertino_alert.rs @@ -1,3 +1,5 @@ +#![allow(clippy::todo)] + use iced_native::{ alignment, event::Status, @@ -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, @@ -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) } } @@ -257,36 +259,36 @@ where ::Font: From, { 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( @@ -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"), + ); } } @@ -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"), + ); } } } @@ -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 // @@ -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> for Element<'a, Message, Renderer> where diff --git a/src/native/cupertino/cupertino_button.rs b/src/native/cupertino/cupertino_button.rs index 63ee6a66..2abe7b12 100644 --- a/src/native/cupertino/cupertino_button.rs +++ b/src/native/cupertino/cupertino_button.rs @@ -107,6 +107,7 @@ where } /// Sets the `colour` of the [`CupertinoButton`](CupertinoButton). + #[must_use] pub fn colour(mut self, colour: Option) -> Self { self.colour = colour; self @@ -180,7 +181,7 @@ where new_style.clone_from(style); if self.colour.is_some() { - new_style.text_color = self.colour.unwrap(); + new_style.text_color = self.colour.expect("Unable to retrieve the text colour"); } else if self.is_filled && self.on_pressed.is_some() { new_style.text_color = Color::WHITE; } else if !self.is_filled && self.on_pressed.is_some() { @@ -199,7 +200,7 @@ where layout, cursor_position, viewport, - ) + ); } fn on_event( @@ -225,7 +226,11 @@ where .contains(&cursor_position.y); if hit_x && hit_y { - shell.publish(self.on_pressed.clone().unwrap()); + shell.publish( + self.on_pressed + .clone() + .expect("Unable to retrieve the pressed message"), + ); return Status::Captured; } } @@ -234,7 +239,7 @@ where _ => {} } - return Status::Ignored; + Status::Ignored } } diff --git a/src/native/cupertino/cupertino_switch.rs b/src/native/cupertino/cupertino_switch.rs index 1d61a338..1c33a546 100644 --- a/src/native/cupertino/cupertino_switch.rs +++ b/src/native/cupertino/cupertino_switch.rs @@ -167,7 +167,7 @@ where } } -impl<'a, Message, B, T> Widget> for CupertinoSwitch +impl Widget> for CupertinoSwitch where B: Backend, Message: Clone, @@ -180,12 +180,12 @@ where } fn layout(&self, _renderer: &Renderer, limits: &Limits) -> Node { - return Node::new( + Node::new( limits .width(self.width) .height(self.height) .resolve(Size::new(f32::INFINITY, f32::INFINITY)), - ); + ) } fn draw( @@ -386,7 +386,12 @@ where state.animation_frame = 0; if self.on_changed.as_ref().is_some() { - shell.publish((self.on_changed.as_ref().unwrap())(!self.value)); + shell.publish((self + .on_changed + .as_ref() + .expect("Unable to retrieve the changed message"))( + !self.value + )); state.prev_value = self.value; state.published = true; @@ -399,7 +404,7 @@ where _ => {} } - return Status::Ignored; + Status::Ignored } fn overlay<'b>( @@ -412,7 +417,7 @@ where state.bounds = layout.bounds(); - return None; + None } }