From 27934c7fc9b193905166621b930427bf3007aed3 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 8 Sep 2024 16:12:33 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20some=20clippy=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/infrastructure/services/mozaik_builder.rs | 5 +- src/main.rs | 2 +- src/ui/components/button.rs | 8 +-- src/ui/components/icons.rs | 12 ++-- src/ui/components/login.rs | 65 +++++++------------ src/ui/components/modal.rs | 2 +- src/ui/components/spinner.rs | 3 +- src/ui/components/wallpaper.rs | 6 +- src/ui/layouts/login.rs | 2 +- 9 files changed, 47 insertions(+), 58 deletions(-) diff --git a/src/infrastructure/services/mozaik_builder.rs b/src/infrastructure/services/mozaik_builder.rs index fb946b4..0d58b52 100644 --- a/src/infrastructure/services/mozaik_builder.rs +++ b/src/infrastructure/services/mozaik_builder.rs @@ -1,8 +1,7 @@ use std::io::Cursor; use image::imageops::FilterType; -use image::io::Reader; -use image::{DynamicImage, ImageFormat}; +use image::{DynamicImage, ImageFormat, ImageReader}; use image::{GenericImage, RgbImage}; use tracing::{error, warn}; @@ -13,7 +12,7 @@ cfg_if! { } fn from_raw_to_image(raw: &Vec) -> Option { - match Reader::new(Cursor::new(raw)).with_guessed_format() { + match ImageReader::new(Cursor::new(raw)).with_guessed_format() { Ok(reader) => match reader.decode() { Ok(image) => return Some(image), Err(err) => error!("Unable to decode the image: {}", err), diff --git a/src/main.rs b/src/main.rs index 6bb9464..5cc8a45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -99,7 +99,7 @@ fn app() -> Element { } } else { rsx! { - Login {}, + Login {} } } } diff --git a/src/ui/components/button.rs b/src/ui/components/button.rs index 45fd74e..d8fd046 100644 --- a/src/ui/components/button.rs +++ b/src/ui/components/button.rs @@ -43,7 +43,7 @@ macro_rules! svg_text_button { ($name:ident,$style:ident,$icon:ident) => { pub fn $name(props: ButtonProps) -> Element { rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } Button { id: props.id, @@ -79,7 +79,7 @@ pub struct ButtonProps { pub fn Button(props: ButtonProps) -> Element { rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } button { id: props.id, @@ -96,8 +96,8 @@ pub fn Button(props: ButtonProps) -> Element { } }, - {props.children}, - }, + {props.children} + } } } diff --git a/src/ui/components/icons.rs b/src/ui/components/icons.rs index 7a14764..7516049 100644 --- a/src/ui/components/icons.rs +++ b/src/ui/components/icons.rs @@ -15,7 +15,8 @@ macro_rules! transparent_icon { ($name:ident, $icon:ident) => { pub fn $name() -> Element { rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } + Icon { class: ClassName::TRANSPARENT_ICON, icon: $icon, @@ -52,7 +53,7 @@ impl IconShape for LogoShape { pub fn LogoIcon() -> Element { rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } Icon { icon: LogoShape, @@ -133,14 +134,14 @@ impl IconShape for PyramidShape { L {_PYRAMID_EDGES_E1_X} {_PYRAMID_CENTRAL_EDGE_E2_Y} \ M {_PYRAMID_EDGES_E1_X} {_PYRAMID_EDGES_E1_Y} \ V {_PYRAMID_CENTRAL_EDGE_Y_LEN}", - }, + } path { d: "\ M {_PYRAMID_CENTRAL_EDGE_E2_X} {_PYRAMID_CENTRAL_EDGE_E2_Y} \ V {central_edge_ratio_e2_y} \ L {left_edge_ratio_e1_x} {no_central_edge_ratio_e1_y} \ L {_PYRAMID_LEFT_EDGE_E2_X} {_PYRAMID_LEFT_EDGE_E2_Y} Z", - }, + } path { d: "\ M {_PYRAMID_CENTRAL_EDGE_E2_X} {_PYRAMID_CENTRAL_EDGE_E2_Y} \ @@ -168,10 +169,11 @@ pub fn Pyramid(props: PyramidProps) -> Element { .unwrap_or(COLOR_TERNARY_100.to_string()); rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } Icon { class: ClassName::PYRAMID_ICON, + icon: PyramidShape { ratio: props.ratio, color, progress_color }, } } diff --git a/src/ui/components/login.rs b/src/ui/components/login.rs index 75f328f..6545eeb 100644 --- a/src/ui/components/login.rs +++ b/src/ui/components/login.rs @@ -97,27 +97,6 @@ impl Clone for Box { } } -#[derive(Clone)] -struct TextInputHandler { - state: Signal, -} - -impl TextInputHandler {} - -impl OnValidationError for TextInputHandler { - fn reset(&mut self) { - self.state.write().reset(); - } - - fn invalidate(&mut self, helper_text: String) { - self.state.write().invalidate(helper_text); - } - - fn box_clone(&self) -> Box { - Box::new(self.clone()) - } -} - #[derive(Clone)] struct UrlInputHandler { state: Signal, @@ -744,7 +723,7 @@ pub fn Login() -> Element { let confirm_password_classes_str = confirm_password_classes.join(" "); rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } div { class: "{classes_str}", @@ -756,73 +735,79 @@ pub fn Login() -> Element { random_avatar_future.restart() }, - {avatar}, - }, + {avatar} + } div { class: ClassName::LOGIN_HOMESERVER, + TextInput { placeholder: "Homeserver URL", value: "{homeserver_url}", state: homeserver_url_state, oninput: on_input![data, homeserver_url], - }, - }, + } + } div { class: ClassName::LOGIN_ID, + TextInput { placeholder: "{id_placeholder}", value: "{id}", state: id_state, oninput: on_input![data, id], - }, - }, + } + } div { class: "{password_classes_str}", + PasswordTextInput { placeholder: "Password", value: "{password}", state: password_state, oninput: on_input![data, password], - }, - - }, + } + } div { class: "{confirm_password_classes_str}", + PasswordTextInput { placeholder: "Confirm Password", value: "{confirm_password}", state: confirm_password_state, oninput: on_input![data, confirm_password], } - }, + } div { class: ClassName::LOGIN_SPINNER, + Spinner { animate: *spinner_animated.read(), - }, - }, + } + } div { class: ClassName::LOGIN_REGISTER_BUTTON, + RegisterButton { onclick: on_clicked_register, - }, - }, + } + } div { class: ClassName::LOGIN_LOGIN_BUTTON, + LoginButton { focus: true, onclick: on_clicked_login, - }, - }, - }, + } + } + } - {rendered_modal}, + {rendered_modal} } } diff --git a/src/ui/components/modal.rs b/src/ui/components/modal.rs index 7200f66..f919c83 100644 --- a/src/ui/components/modal.rs +++ b/src/ui/components/modal.rs @@ -76,7 +76,7 @@ pub fn Modal(props: ModalProps) -> Element { Severity::Critical => ErrorButton, }; - icon.as_ref().ok_or(VNode::empty()); + let _ = icon.as_ref().ok_or(VNode::empty()); rsx! { style { {STYLE_SHEET} } diff --git a/src/ui/components/spinner.rs b/src/ui/components/spinner.rs index 68750b1..a45f2d9 100644 --- a/src/ui/components/spinner.rs +++ b/src/ui/components/spinner.rs @@ -13,13 +13,14 @@ pub struct SpinnerProps { pub fn Spinner(props: SpinnerProps) -> Element { rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } div { class: ClassName::SPINNER, Icon { class: if props.animate { "" } else { ClassName::PAUSED }, + icon: LogoShape, } } diff --git a/src/ui/components/wallpaper.rs b/src/ui/components/wallpaper.rs index d880507..5578c73 100644 --- a/src/ui/components/wallpaper.rs +++ b/src/ui/components/wallpaper.rs @@ -10,7 +10,8 @@ pub fn Wallpaper(display_version: Option) -> Element { let version = display_version.map(|flag| if flag { Some(GIT_VERSION) } else { None }); rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } + div { class: ClassName::WALLPAPER, @@ -20,7 +21,8 @@ pub fn Wallpaper(display_version: Option) -> Element { div { class: ClassName::WALLPAPER_VERSION, - {version}, + + {version} } } } diff --git a/src/ui/layouts/login.rs b/src/ui/layouts/login.rs index 807661b..58001fe 100644 --- a/src/ui/layouts/login.rs +++ b/src/ui/layouts/login.rs @@ -7,7 +7,7 @@ turf::style_sheet!("src/ui/layouts/login.scss"); pub fn Login() -> Element { rsx! { - style { {STYLE_SHEET} }, + style { {STYLE_SHEET} } Wallpaper { display_version: true