mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-31 18:40:56 +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,
|
||||
display::{toif::Toif, LOADER_MAX},
|
||||
geometry::{Alignment, Alignment2D},
|
||||
model_mercury::shapes::render_loader,
|
||||
model_mercury::shapes::{render_loader, LoaderRange},
|
||||
shape,
|
||||
shape::render_on_display,
|
||||
};
|
||||
@ -130,9 +130,11 @@ impl ModelMercuryFeatures {
|
||||
inactive_color,
|
||||
fg_color,
|
||||
bg_color,
|
||||
0,
|
||||
end,
|
||||
progress >= LOADER_MAX,
|
||||
if progress >= LOADER_MAX {
|
||||
LoaderRange::Full
|
||||
} else {
|
||||
LoaderRange::FromTo(0, end)
|
||||
},
|
||||
target,
|
||||
);
|
||||
|
||||
|
@ -7,7 +7,7 @@ use crate::{
|
||||
component::{Component, Event, EventCtx, Pad},
|
||||
display::{self, toif::Icon, Color, LOADER_MAX},
|
||||
geometry::{Alignment2D, Offset, Rect},
|
||||
model_mercury::shapes::render_loader,
|
||||
model_mercury::shapes::{render_loader, LoaderRange},
|
||||
shape::{self, Renderer},
|
||||
util::animation_disabled,
|
||||
},
|
||||
@ -231,9 +231,11 @@ impl Component for Loader {
|
||||
inactive_color,
|
||||
active_color,
|
||||
background_color,
|
||||
start,
|
||||
end,
|
||||
progress >= LOADER_MAX,
|
||||
if progress >= LOADER_MAX {
|
||||
LoaderRange::Full
|
||||
} else {
|
||||
LoaderRange::FromTo(start, end)
|
||||
},
|
||||
target,
|
||||
);
|
||||
|
||||
|
@ -11,7 +11,10 @@ use crate::{
|
||||
},
|
||||
display::{self, Font, LOADER_MAX},
|
||||
geometry::{Insets, Offset, Rect},
|
||||
model_mercury::{constant, shapes::render_loader},
|
||||
model_mercury::{
|
||||
constant,
|
||||
shapes::{render_loader, LoaderRange},
|
||||
},
|
||||
shape,
|
||||
shape::Renderer,
|
||||
util::animation_disabled,
|
||||
@ -116,15 +119,19 @@ impl Component for Progress {
|
||||
let background_color = theme::BG;
|
||||
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 end = (self.value + 100) % 1000;
|
||||
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;
|
||||
(start, end)
|
||||
LoaderRange::FromTo(start, end)
|
||||
} else {
|
||||
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(
|
||||
@ -132,9 +139,7 @@ impl Component for Progress {
|
||||
inactive_color,
|
||||
active_color,
|
||||
background_color,
|
||||
start,
|
||||
end,
|
||||
!self.indeterminate && self.value >= LOADER_MAX,
|
||||
range,
|
||||
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 {
|
||||
Frame::left_aligned(
|
||||
"".into(),
|
||||
VerticalMenu::empty().danger(theme::ICON_CANCEL, verb_cancel.into()),
|
||||
VerticalMenu::empty().danger(theme::ICON_CANCEL, verb_cancel),
|
||||
)
|
||||
} else {
|
||||
Frame::left_aligned(
|
||||
@ -172,7 +172,7 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
|
||||
if !prompt_screen {
|
||||
let store = flow_store().add(content_intro)?.add(content_menu)?;
|
||||
let res = SwipeFlow::new(ConfirmActionSimple::Intro, store)?;
|
||||
return Ok(LayoutObj::new(res)?.into());
|
||||
Ok(LayoutObj::new(res)?.into())
|
||||
} else {
|
||||
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_confirm)?;
|
||||
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};
|
||||
|
||||
pub enum LoaderRange {
|
||||
Full,
|
||||
FromTo(i16, i16),
|
||||
}
|
||||
|
||||
pub fn render_loader<'s>(
|
||||
center: Point,
|
||||
inactive_color: Color,
|
||||
active_color: Color,
|
||||
background_color: Color,
|
||||
start: i16,
|
||||
end: i16,
|
||||
full: bool,
|
||||
range: LoaderRange,
|
||||
target: &mut impl Renderer<'s>,
|
||||
) {
|
||||
shape::Circle::new(center, constant::LOADER_OUTER)
|
||||
.with_bg(inactive_color)
|
||||
.render(target);
|
||||
|
||||
if full {
|
||||
shape::Circle::new(center, constant::LOADER_OUTER)
|
||||
.with_bg(active_color)
|
||||
.render(target);
|
||||
} else {
|
||||
shape::Circle::new(center, constant::LOADER_OUTER)
|
||||
.with_bg(active_color)
|
||||
.with_start_angle(start)
|
||||
.with_end_angle(end)
|
||||
.render(target);
|
||||
match range {
|
||||
LoaderRange::Full => {
|
||||
shape::Circle::new(center, constant::LOADER_OUTER)
|
||||
.with_bg(active_color)
|
||||
.render(target);
|
||||
}
|
||||
LoaderRange::FromTo(start, end) => {
|
||||
shape::Circle::new(center, constant::LOADER_OUTER)
|
||||
.with_bg(active_color)
|
||||
.with_start_angle(start)
|
||||
.with_end_angle(end)
|
||||
.render(target);
|
||||
}
|
||||
}
|
||||
|
||||
shape::Circle::new(center, constant::LOADER_INNER + 2)
|
||||
|
Loading…
Reference in New Issue
Block a user