🚨 Fix some clippy warnings

This commit is contained in:
2024-09-08 16:12:33 +02:00
parent 9d95bd4481
commit 27934c7fc9
9 changed files with 47 additions and 58 deletions

View File

@@ -1,8 +1,7 @@
use std::io::Cursor; use std::io::Cursor;
use image::imageops::FilterType; use image::imageops::FilterType;
use image::io::Reader; use image::{DynamicImage, ImageFormat, ImageReader};
use image::{DynamicImage, ImageFormat};
use image::{GenericImage, RgbImage}; use image::{GenericImage, RgbImage};
use tracing::{error, warn}; use tracing::{error, warn};
@@ -13,7 +12,7 @@ cfg_if! {
} }
fn from_raw_to_image(raw: &Vec<u8>) -> Option<DynamicImage> { fn from_raw_to_image(raw: &Vec<u8>) -> Option<DynamicImage> {
match Reader::new(Cursor::new(raw)).with_guessed_format() { match ImageReader::new(Cursor::new(raw)).with_guessed_format() {
Ok(reader) => match reader.decode() { Ok(reader) => match reader.decode() {
Ok(image) => return Some(image), Ok(image) => return Some(image),
Err(err) => error!("Unable to decode the image: {}", err), Err(err) => error!("Unable to decode the image: {}", err),

View File

@@ -99,7 +99,7 @@ fn app() -> Element {
} }
} else { } else {
rsx! { rsx! {
Login {}, Login {}
} }
} }
} }

View File

@@ -43,7 +43,7 @@ macro_rules! svg_text_button {
($name:ident,$style:ident,$icon:ident) => { ($name:ident,$style:ident,$icon:ident) => {
pub fn $name(props: ButtonProps) -> Element { pub fn $name(props: ButtonProps) -> Element {
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
Button { Button {
id: props.id, id: props.id,
@@ -79,7 +79,7 @@ pub struct ButtonProps {
pub fn Button(props: ButtonProps) -> Element { pub fn Button(props: ButtonProps) -> Element {
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
button { button {
id: props.id, id: props.id,
@@ -96,8 +96,8 @@ pub fn Button(props: ButtonProps) -> Element {
} }
}, },
{props.children}, {props.children}
}, }
} }
} }

View File

@@ -15,7 +15,8 @@ macro_rules! transparent_icon {
($name:ident, $icon:ident) => { ($name:ident, $icon:ident) => {
pub fn $name() -> Element { pub fn $name() -> Element {
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
Icon { Icon {
class: ClassName::TRANSPARENT_ICON, class: ClassName::TRANSPARENT_ICON,
icon: $icon, icon: $icon,
@@ -52,7 +53,7 @@ impl IconShape for LogoShape {
pub fn LogoIcon() -> Element { pub fn LogoIcon() -> Element {
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
Icon { Icon {
icon: LogoShape, icon: LogoShape,
@@ -133,14 +134,14 @@ impl IconShape for PyramidShape {
L {_PYRAMID_EDGES_E1_X} {_PYRAMID_CENTRAL_EDGE_E2_Y} \ L {_PYRAMID_EDGES_E1_X} {_PYRAMID_CENTRAL_EDGE_E2_Y} \
M {_PYRAMID_EDGES_E1_X} {_PYRAMID_EDGES_E1_Y} \ M {_PYRAMID_EDGES_E1_X} {_PYRAMID_EDGES_E1_Y} \
V {_PYRAMID_CENTRAL_EDGE_Y_LEN}", V {_PYRAMID_CENTRAL_EDGE_Y_LEN}",
}, }
path { path {
d: "\ d: "\
M {_PYRAMID_CENTRAL_EDGE_E2_X} {_PYRAMID_CENTRAL_EDGE_E2_Y} \ M {_PYRAMID_CENTRAL_EDGE_E2_X} {_PYRAMID_CENTRAL_EDGE_E2_Y} \
V {central_edge_ratio_e2_y} \ V {central_edge_ratio_e2_y} \
L {left_edge_ratio_e1_x} {no_central_edge_ratio_e1_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", L {_PYRAMID_LEFT_EDGE_E2_X} {_PYRAMID_LEFT_EDGE_E2_Y} Z",
}, }
path { path {
d: "\ d: "\
M {_PYRAMID_CENTRAL_EDGE_E2_X} {_PYRAMID_CENTRAL_EDGE_E2_Y} \ 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()); .unwrap_or(COLOR_TERNARY_100.to_string());
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
Icon { Icon {
class: ClassName::PYRAMID_ICON, class: ClassName::PYRAMID_ICON,
icon: PyramidShape { ratio: props.ratio, color, progress_color }, icon: PyramidShape { ratio: props.ratio, color, progress_color },
} }
} }

View File

@@ -97,27 +97,6 @@ impl Clone for Box<dyn OnValidationError> {
} }
} }
#[derive(Clone)]
struct TextInputHandler {
state: Signal<TextInputState>,
}
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<dyn OnValidationError> {
Box::new(self.clone())
}
}
#[derive(Clone)] #[derive(Clone)]
struct UrlInputHandler { struct UrlInputHandler {
state: Signal<TextInputState>, state: Signal<TextInputState>,
@@ -744,7 +723,7 @@ pub fn Login() -> Element {
let confirm_password_classes_str = confirm_password_classes.join(" "); let confirm_password_classes_str = confirm_password_classes.join(" ");
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
div { div {
class: "{classes_str}", class: "{classes_str}",
@@ -756,73 +735,79 @@ pub fn Login() -> Element {
random_avatar_future.restart() random_avatar_future.restart()
}, },
{avatar}, {avatar}
}, }
div { div {
class: ClassName::LOGIN_HOMESERVER, class: ClassName::LOGIN_HOMESERVER,
TextInput { TextInput {
placeholder: "Homeserver URL", placeholder: "Homeserver URL",
value: "{homeserver_url}", value: "{homeserver_url}",
state: homeserver_url_state, state: homeserver_url_state,
oninput: on_input![data, homeserver_url], oninput: on_input![data, homeserver_url],
}, }
}, }
div { div {
class: ClassName::LOGIN_ID, class: ClassName::LOGIN_ID,
TextInput { TextInput {
placeholder: "{id_placeholder}", placeholder: "{id_placeholder}",
value: "{id}", value: "{id}",
state: id_state, state: id_state,
oninput: on_input![data, id], oninput: on_input![data, id],
}, }
}, }
div { div {
class: "{password_classes_str}", class: "{password_classes_str}",
PasswordTextInput { PasswordTextInput {
placeholder: "Password", placeholder: "Password",
value: "{password}", value: "{password}",
state: password_state, state: password_state,
oninput: on_input![data, password], oninput: on_input![data, password],
}, }
}
},
div { div {
class: "{confirm_password_classes_str}", class: "{confirm_password_classes_str}",
PasswordTextInput { PasswordTextInput {
placeholder: "Confirm Password", placeholder: "Confirm Password",
value: "{confirm_password}", value: "{confirm_password}",
state: confirm_password_state, state: confirm_password_state,
oninput: on_input![data, confirm_password], oninput: on_input![data, confirm_password],
} }
}, }
div { div {
class: ClassName::LOGIN_SPINNER, class: ClassName::LOGIN_SPINNER,
Spinner { Spinner {
animate: *spinner_animated.read(), animate: *spinner_animated.read(),
}, }
}, }
div { div {
class: ClassName::LOGIN_REGISTER_BUTTON, class: ClassName::LOGIN_REGISTER_BUTTON,
RegisterButton { RegisterButton {
onclick: on_clicked_register, onclick: on_clicked_register,
}, }
}, }
div { div {
class: ClassName::LOGIN_LOGIN_BUTTON, class: ClassName::LOGIN_LOGIN_BUTTON,
LoginButton { LoginButton {
focus: true, focus: true,
onclick: on_clicked_login, onclick: on_clicked_login,
}, }
}, }
}, }
{rendered_modal}, {rendered_modal}
} }
} }

View File

@@ -76,7 +76,7 @@ pub fn Modal(props: ModalProps) -> Element {
Severity::Critical => ErrorButton, Severity::Critical => ErrorButton,
}; };
icon.as_ref().ok_or(VNode::empty()); let _ = icon.as_ref().ok_or(VNode::empty());
rsx! { rsx! {
style { {STYLE_SHEET} } style { {STYLE_SHEET} }

View File

@@ -13,13 +13,14 @@ pub struct SpinnerProps {
pub fn Spinner(props: SpinnerProps) -> Element { pub fn Spinner(props: SpinnerProps) -> Element {
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
div { div {
class: ClassName::SPINNER, class: ClassName::SPINNER,
Icon { Icon {
class: if props.animate { "" } else { ClassName::PAUSED }, class: if props.animate { "" } else { ClassName::PAUSED },
icon: LogoShape, icon: LogoShape,
} }
} }

View File

@@ -10,7 +10,8 @@ pub fn Wallpaper(display_version: Option<bool>) -> Element {
let version = display_version.map(|flag| if flag { Some(GIT_VERSION) } else { None }); let version = display_version.map(|flag| if flag { Some(GIT_VERSION) } else { None });
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
div { div {
class: ClassName::WALLPAPER, class: ClassName::WALLPAPER,
@@ -20,7 +21,8 @@ pub fn Wallpaper(display_version: Option<bool>) -> Element {
div { div {
class: ClassName::WALLPAPER_VERSION, class: ClassName::WALLPAPER_VERSION,
{version},
{version}
} }
} }
} }

View File

@@ -7,7 +7,7 @@ turf::style_sheet!("src/ui/layouts/login.scss");
pub fn Login() -> Element { pub fn Login() -> Element {
rsx! { rsx! {
style { {STYLE_SHEET} }, style { {STYLE_SHEET} }
Wallpaper { Wallpaper {
display_version: true display_version: true