refactor: use `ConfirmActionOptions` in `ConfirmValue`
What changed, and why it matters
This commit is a straightforward internal code cleanup in the Trezor firmware's user-interface layer. It replaces several individual settings inside a 'ConfirmValue' screen builder with a shared 'ConfirmActionOptions' object. There is no change to user-visible behavior or to security logic; it is purely a refactor to reduce duplicated code.
No security action required. Treat as normal code-quality refactor during review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff refactors ConfirmValue in the Delizia UI layout so that hold, swipe_down, swipe_up, page_limit, page_counter, and frame_margin are handled through a ConfirmActionOptions struct instead of separate fields and builder methods. The struct gains public visibility and a new swipe_up option. Call sites in ui_firmware.rs are updated to pass equivalent options via with_options(…). No functional behavior changes are visible in the diff.
Changed components
core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rscore/embed/rust/src/ui/layout_delizia/flow/util.rscore/embed/rust/src/ui/layout_delizia/ui_firmware.rsInspect captured patch +38 / −81
diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs
index ede9d9c2..bc2106c0 100644
--- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs
+++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs
@@ -69,11 +69,12 @@ impl ConfirmActionStrings {
}
pub struct ConfirmActionOptions {
- hold: bool,
- swipe_down: bool,
- page_limit: Option<u16>,
- page_counter: bool,
- frame_margin: usize,
+ pub hold: bool,
+ pub swipe_down: bool,
+ pub swipe_up: bool,
+ pub page_limit: Option<u16>,
+ pub page_counter: bool,
+ pub frame_margin: usize,
}
impl ConfirmActionOptions {
@@ -81,6 +82,7 @@ impl ConfirmActionOptions {
Self {
hold: false,
swipe_down: false,
+ swipe_up: false,
page_limit: None,
page_counter: false,
frame_margin: 0,
@@ -97,6 +99,11 @@ impl ConfirmActionOptions {
self
}
+ pub fn with_swipe_up(mut self, swipe_up: bool) -> Self {
+ self.swipe_up = swipe_up;
+ self
+ }
+
pub fn with_page_limit(mut self, page_limit: Option<u16>) -> Self {
self.page_limit = page_limit;
self
diff --git a/core/embed/rust/src/ui/layout_delizia/flow/util.rs b/core/embed/rust/src/ui/layout_delizia/flow/util.rs
index 6f363db5..c2cd09ac 100644
--- a/core/embed/rust/src/ui/layout_delizia/flow/util.rs
+++ b/core/embed/rust/src/ui/layout_delizia/flow/util.rs
@@ -46,19 +46,13 @@ pub struct ConfirmValue {
cancel_button: bool,
menu_button: bool,
prompt: bool,
- hold: bool,
chunkify: bool,
text_mono: bool,
- page_counter: bool,
- page_limit: Option<u16>,
classic_ellipsis: bool,
- swipe_up: bool,
- swipe_down: bool,
- swipe_right: bool,
- frame_margin: usize,
cancel: bool,
external_menu: bool,
flow_menu: bool,
+ options: ConfirmActionOptions,
}
impl ConfirmValue {
@@ -83,19 +77,13 @@ impl ConfirmValue {
cancel_button: false,
menu_button: false,
prompt: false,
- hold: false,
chunkify: false,
text_mono: true,
- page_counter: false,
- page_limit: None,
classic_ellipsis: false,
- swipe_up: false,
- swipe_down: false,
- swipe_right: false,
- frame_margin: 0,
cancel: false,
external_menu: false,
flow_menu: false,
+ options: ConfirmActionOptions::new(),
}
}
@@ -144,26 +132,6 @@ impl ConfirmValue {
self
}
- pub const fn with_hold(mut self, hold: bool) -> Self {
- self.hold = hold;
- self
- }
-
- pub const fn with_swipe_up(mut self) -> Self {
- self.swipe_up = true;
- self
- }
-
- pub const fn with_swipe_down(mut self, swipe_down: bool) -> Self {
- self.swipe_down = swipe_down;
- self
- }
-
- pub const fn with_frame_margin(mut self, frame_margin: usize) -> Self {
- self.frame_margin = frame_margin;
- self
- }
-
pub const fn with_footer_description(
mut self,
footer_description: Option<TString<'static>>,
@@ -187,24 +155,14 @@ impl ConfirmValue {
self
}
- pub const fn with_footer(
- mut self,
- instruction: TString<'static>,
- description: Option<TString<'static>>,
- ) -> Self {
- self.footer_instruction = Some(instruction);
+ pub fn with_swipeup_footer(mut self, description: Option<TString<'static>>) -> Self {
+ self.footer_instruction =
+ Some(TString::from_translation(TR::instructions__tap_to_continue));
self.footer_description = description;
+ self.options = self.options.with_swipe_up(true);
self
}
- pub const fn with_swipeup_footer(self, description: Option<TString<'static>>) -> Self {
- self.with_footer(
- TString::from_translation(TR::instructions__tap_to_continue),
- description,
- )
- .with_swipe_up()
- }
-
pub const fn with_chunkify(mut self, chunkify: bool) -> Self {
self.chunkify = chunkify;
self
@@ -215,16 +173,6 @@ impl ConfirmValue {
self
}
- pub fn with_page_counter(mut self, page_counter: bool) -> Self {
- self.page_counter = page_counter;
- self
- }
-
- pub const fn with_page_limit(mut self, page_limit: Option<u16>) -> Self {
- self.page_limit = page_limit;
- self
- }
-
pub const fn with_classic_ellipsis(mut self, classic_ellipsis: bool) -> Self {
self.classic_ellipsis = classic_ellipsis;
self
@@ -235,6 +183,11 @@ impl ConfirmValue {
self
}
+ pub fn with_options(mut self, options: ConfirmActionOptions) -> Self {
+ self.options = options;
+ self
+ }
+
pub fn into_layout(
self,
) -> Result<impl Component<Msg = FlowMsg> + Swipable + MaybeTrace, Error> {
@@ -276,18 +229,14 @@ impl ConfirmValue {
frame = frame.with_flow_menu();
}
- if self.swipe_up {
+ if self.options.swipe_up {
frame = frame.with_swipe(Direction::Up, SwipeSettings::Default);
}
- if self.swipe_down {
+ if self.options.swipe_down {
frame = frame.with_swipe(Direction::Down, SwipeSettings::Default);
}
- if self.swipe_right {
- frame = frame.with_swipe(Direction::Right, SwipeSettings::Default);
- }
-
frame = frame.with_vertical_pages();
Ok(frame.map_to_button_msg())
@@ -336,12 +285,7 @@ impl ConfirmValue {
self.prompt.then_some(self.title),
)
.with_footer_description(self.footer_description),
- ConfirmActionOptions::new()
- .with_hold(self.hold)
- .with_swipe_down(self.swipe_down)
- .with_page_limit(self.page_limit)
- .with_frame_margin(self.frame_margin)
- .with_page_counter(self.page_counter),
+ self.options,
)
}
diff --git a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
index 08a7cbb5..9427ac6d 100644
--- a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
@@ -141,12 +141,15 @@ impl FirmwareUI for UIDelizia {
})
.with_extra(extra)
.with_chunkify(chunkify)
- .with_page_counter(page_counter)
.with_cancel(cancel)
- .with_swipe_down(back_button)
.with_prompt(prompt_screen)
.with_external_menu(external_menu)
- .with_hold(hold)
+ .with_options(
+ ConfirmActionOptions::new()
+ .with_page_counter(page_counter)
+ .with_hold(hold)
+ .with_swipe_down(back_button),
+ )
.into_flow()
}
@@ -172,10 +175,13 @@ impl FirmwareUI for UIDelizia {
.with_verb_cancel(verb_cancel)
.with_footer_description(verb)
.with_chunkify(chunkify)
- .with_page_limit(Some(1))
.with_classic_ellipsis(true)
- .with_frame_margin(CONFIRM_VALUE_INTRO_MARGIN)
- .with_hold(hold)
+ .with_options(
+ ConfirmActionOptions::new()
+ .with_page_limit(Some(1))
+ .with_frame_margin(CONFIRM_VALUE_INTRO_MARGIN)
+ .with_hold(hold),
+ )
.into_flow()
.and_then(LayoutObj::new_root)
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.