mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 20:11:00 +00:00
refactor(core/ui): fix clippy issues
This commit is contained in:
parent
b16411631b
commit
53609a85fd
@ -38,7 +38,7 @@ use crate::ui::{
|
|||||||
constant,
|
constant,
|
||||||
display::{toif::Toif, LOADER_MAX},
|
display::{toif::Toif, LOADER_MAX},
|
||||||
geometry::{Alignment, Alignment2D},
|
geometry::{Alignment, Alignment2D},
|
||||||
model_mercury::shapes::render_loader,
|
model_mercury::shapes::{render_loader, LoaderRange},
|
||||||
shape,
|
shape,
|
||||||
shape::render_on_display,
|
shape::render_on_display,
|
||||||
};
|
};
|
||||||
@ -130,9 +130,11 @@ impl ModelMercuryFeatures {
|
|||||||
inactive_color,
|
inactive_color,
|
||||||
fg_color,
|
fg_color,
|
||||||
bg_color,
|
bg_color,
|
||||||
0,
|
if progress >= LOADER_MAX {
|
||||||
end,
|
LoaderRange::Full
|
||||||
progress >= LOADER_MAX,
|
} else {
|
||||||
|
LoaderRange::FromTo(0, end)
|
||||||
|
},
|
||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
component::{Component, Event, EventCtx, Pad},
|
component::{Component, Event, EventCtx, Pad},
|
||||||
display::{self, toif::Icon, Color, LOADER_MAX},
|
display::{self, toif::Icon, Color, LOADER_MAX},
|
||||||
geometry::{Alignment2D, Offset, Rect},
|
geometry::{Alignment2D, Offset, Rect},
|
||||||
model_mercury::shapes::render_loader,
|
model_mercury::shapes::{render_loader, LoaderRange},
|
||||||
shape::{self, Renderer},
|
shape::{self, Renderer},
|
||||||
util::animation_disabled,
|
util::animation_disabled,
|
||||||
},
|
},
|
||||||
@ -231,9 +231,11 @@ impl Component for Loader {
|
|||||||
inactive_color,
|
inactive_color,
|
||||||
active_color,
|
active_color,
|
||||||
background_color,
|
background_color,
|
||||||
start,
|
if progress >= LOADER_MAX {
|
||||||
end,
|
LoaderRange::Full
|
||||||
progress >= LOADER_MAX,
|
} else {
|
||||||
|
LoaderRange::FromTo(start, end)
|
||||||
|
},
|
||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -11,7 +11,10 @@ use crate::{
|
|||||||
},
|
},
|
||||||
display::{self, Font, LOADER_MAX},
|
display::{self, Font, LOADER_MAX},
|
||||||
geometry::{Insets, Offset, Rect},
|
geometry::{Insets, Offset, Rect},
|
||||||
model_mercury::{constant, shapes::render_loader},
|
model_mercury::{
|
||||||
|
constant,
|
||||||
|
shapes::{render_loader, LoaderRange},
|
||||||
|
},
|
||||||
shape,
|
shape,
|
||||||
shape::Renderer,
|
shape::Renderer,
|
||||||
util::animation_disabled,
|
util::animation_disabled,
|
||||||
@ -116,15 +119,19 @@ impl Component for Progress {
|
|||||||
let background_color = theme::BG;
|
let background_color = theme::BG;
|
||||||
let inactive_color = theme::GREY_EXTRA_DARK;
|
let inactive_color = theme::GREY_EXTRA_DARK;
|
||||||
|
|
||||||
let (start, end) = if self.indeterminate {
|
let range = if self.indeterminate {
|
||||||
let start = (self.value - 100) % 1000;
|
let start = (self.value - 100) % 1000;
|
||||||
let end = (self.value + 100) % 1000;
|
let end = (self.value + 100) % 1000;
|
||||||
let start = ((start as i32 * 8 * shape::PI4 as i32) / 1000) as i16;
|
let start = ((start as i32 * 8 * shape::PI4 as i32) / 1000) as i16;
|
||||||
let end = ((end as i32 * 8 * shape::PI4 as i32) / 1000) as i16;
|
let end = ((end as i32 * 8 * shape::PI4 as i32) / 1000) as i16;
|
||||||
(start, end)
|
LoaderRange::FromTo(start, end)
|
||||||
} else {
|
} else {
|
||||||
let end = ((self.value as i32 * 8 * shape::PI4 as i32) / 1000) as i16;
|
let end = ((self.value as i32 * 8 * shape::PI4 as i32) / 1000) as i16;
|
||||||
(0, end)
|
if self.value >= LOADER_MAX {
|
||||||
|
LoaderRange::Full
|
||||||
|
} else {
|
||||||
|
LoaderRange::FromTo(0, end)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render_loader(
|
render_loader(
|
||||||
@ -132,9 +139,7 @@ impl Component for Progress {
|
|||||||
inactive_color,
|
inactive_color,
|
||||||
active_color,
|
active_color,
|
||||||
background_color,
|
background_color,
|
||||||
start,
|
range,
|
||||||
end,
|
|
||||||
!self.indeterminate && self.value >= LOADER_MAX,
|
|
||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
|
|||||||
let content_menu = if let Some(verb_cancel) = verb_cancel {
|
let content_menu = if let Some(verb_cancel) = verb_cancel {
|
||||||
Frame::left_aligned(
|
Frame::left_aligned(
|
||||||
"".into(),
|
"".into(),
|
||||||
VerticalMenu::empty().danger(theme::ICON_CANCEL, verb_cancel.into()),
|
VerticalMenu::empty().danger(theme::ICON_CANCEL, verb_cancel),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Frame::left_aligned(
|
Frame::left_aligned(
|
||||||
@ -172,7 +172,7 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
|
|||||||
if !prompt_screen {
|
if !prompt_screen {
|
||||||
let store = flow_store().add(content_intro)?.add(content_menu)?;
|
let store = flow_store().add(content_intro)?.add(content_menu)?;
|
||||||
let res = SwipeFlow::new(ConfirmActionSimple::Intro, store)?;
|
let res = SwipeFlow::new(ConfirmActionSimple::Intro, store)?;
|
||||||
return Ok(LayoutObj::new(res)?.into());
|
Ok(LayoutObj::new(res)?.into())
|
||||||
} else {
|
} else {
|
||||||
let (prompt, prompt_action) = if hold {
|
let (prompt, prompt_action) = if hold {
|
||||||
(
|
(
|
||||||
@ -205,6 +205,6 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
|
|||||||
.add(content_menu)?
|
.add(content_menu)?
|
||||||
.add(content_confirm)?;
|
.add(content_confirm)?;
|
||||||
let res = SwipeFlow::new(ConfirmAction::Intro, store)?;
|
let res = SwipeFlow::new(ConfirmAction::Intro, store)?;
|
||||||
return Ok(LayoutObj::new(res)?.into());
|
Ok(LayoutObj::new(res)?.into())
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,35 @@
|
|||||||
use crate::ui::{display::Color, geometry::Point, model_mercury::constant, shape, shape::Renderer};
|
use crate::ui::{display::Color, geometry::Point, model_mercury::constant, shape, shape::Renderer};
|
||||||
|
|
||||||
|
pub enum LoaderRange {
|
||||||
|
Full,
|
||||||
|
FromTo(i16, i16),
|
||||||
|
}
|
||||||
|
|
||||||
pub fn render_loader<'s>(
|
pub fn render_loader<'s>(
|
||||||
center: Point,
|
center: Point,
|
||||||
inactive_color: Color,
|
inactive_color: Color,
|
||||||
active_color: Color,
|
active_color: Color,
|
||||||
background_color: Color,
|
background_color: Color,
|
||||||
start: i16,
|
range: LoaderRange,
|
||||||
end: i16,
|
|
||||||
full: bool,
|
|
||||||
target: &mut impl Renderer<'s>,
|
target: &mut impl Renderer<'s>,
|
||||||
) {
|
) {
|
||||||
shape::Circle::new(center, constant::LOADER_OUTER)
|
shape::Circle::new(center, constant::LOADER_OUTER)
|
||||||
.with_bg(inactive_color)
|
.with_bg(inactive_color)
|
||||||
.render(target);
|
.render(target);
|
||||||
|
|
||||||
if full {
|
match range {
|
||||||
shape::Circle::new(center, constant::LOADER_OUTER)
|
LoaderRange::Full => {
|
||||||
.with_bg(active_color)
|
shape::Circle::new(center, constant::LOADER_OUTER)
|
||||||
.render(target);
|
.with_bg(active_color)
|
||||||
} else {
|
.render(target);
|
||||||
shape::Circle::new(center, constant::LOADER_OUTER)
|
}
|
||||||
.with_bg(active_color)
|
LoaderRange::FromTo(start, end) => {
|
||||||
.with_start_angle(start)
|
shape::Circle::new(center, constant::LOADER_OUTER)
|
||||||
.with_end_angle(end)
|
.with_bg(active_color)
|
||||||
.render(target);
|
.with_start_angle(start)
|
||||||
|
.with_end_angle(end)
|
||||||
|
.render(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shape::Circle::new(center, constant::LOADER_INNER + 2)
|
shape::Circle::new(center, constant::LOADER_INNER + 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user