From b28b950b0a85805fd52186c18264f01763fe8e7c Mon Sep 17 00:00:00 2001 From: Lukas Bielesch Date: Fri, 22 Nov 2024 15:12:12 +0100 Subject: [PATCH] fix(core): fix broken flow for changing brightness [no changelog] --- core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs | 4 +++- core/embed/rust/src/ui/model_mercury/layout.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs b/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs index 8461eaa078..938a96d3a6 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs @@ -64,7 +64,8 @@ impl FlowController for SetBrightness { static BRIGHTNESS: AtomicU8 = AtomicU8::new(0); -pub fn new_set_brightness(brightness: u8) -> Result { +pub fn new_set_brightness(brightness: Option) -> Result { + let brightness = brightness.unwrap_or(theme::backlight::get_backlight_normal()); let content_slider = Frame::left_aligned( TR::brightness__title.into(), NumberInputSliderDialog::new( @@ -122,6 +123,7 @@ pub fn new_set_brightness(brightness: u8) -> Result { ) .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) + .with_result_icon(theme::ICON_BULLET_CHECKMARK, theme::GREEN_LIGHT) .map(move |_msg| Some(FlowMsg::Confirmed)); let res = SwipeFlow::new(&SetBrightness::Slider)? diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 65358ce6c0..b2e39603a6 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -676,7 +676,7 @@ extern "C" fn new_confirm_summary(n_args: usize, args: *const Obj, kwargs: *mut extern "C" fn new_set_brightness(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { - let current: u8 = kwargs.get(Qstr::MP_QSTR_current)?.try_into()?; + let current: Option = kwargs.get(Qstr::MP_QSTR_current)?.try_into_option()?; let flow = flow::set_brightness::new_set_brightness(current)?; Ok(LayoutObj::new_root(flow)?.into()) };