Skip to content

Commit

Permalink
refactor(core): consistent naming for UI traits
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
obrusvit committed Dec 18, 2024
1 parent 0e1696b commit 7e1f160
Show file tree
Hide file tree
Showing 25 changed files with 167 additions and 169 deletions.
3 changes: 2 additions & 1 deletion core/embed/rust/src/ui/api/bootloader_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use crate::{
strutil::hexlify,
trezorhal::secbool::secbool,
ui::{
ui_features::{ModelUI, UIFeaturesBootloader},
ui_bootloader::BootloaderUI,
util::{from_c_array, from_c_str},
ModelUI,
},
};

Expand Down
2 changes: 1 addition & 1 deletion core/embed/rust/src/ui/api/common_c.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Reexporting the `screens` module according to the
//! current feature (Trezor model)
use crate::ui::ui_features::{ModelUI, UIFeaturesCommon};
use crate::ui::{CommonUI, ModelUI};

use crate::ui::shape;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use crate::{
result::{CANCELLED, CONFIRMED, INFO},
util::{upy_disable_animation, RecoveryType},
},
ui_features::ModelUI,
ui_features_fw::{
UIFeaturesFirmware, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
ui_firmware::{
FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
},
ModelUI,
},
};
use heapless::Vec;
Expand Down
2 changes: 1 addition & 1 deletion core/embed/rust/src/ui/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pub mod common_c;
pub mod bootloader_c;

#[cfg(feature = "micropython")]
pub mod firmware_upy;
pub mod firmware_micropython;
2 changes: 1 addition & 1 deletion core/embed/rust/src/ui/backlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
micropython::{
ffi, macros::obj_type, obj::Obj, qstr::Qstr, simple_type::SimpleTypeObj, typ::Type, util,
},
ui::{ui_features::ModelUI, UIFeaturesCommon},
ui::{CommonUI, ModelUI},
};

/*
Expand Down
3 changes: 1 addition & 2 deletions core/embed/rust/src/ui/flow/swipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ use crate::{
geometry::{Direction, Rect},
layout::base::{Layout, LayoutState},
shape::{render_on_display, ConcreteRenderer, Renderer, ScopedRenderer},
ui_features::ModelUI,
util::animation_disabled,
UIFeaturesCommon,
CommonUI, ModelUI,
},
};

Expand Down
7 changes: 3 additions & 4 deletions core/embed/rust/src/ui/layout/obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ use crate::{
},
display,
event::USBEvent,
ui_features::ModelUI,
UIFeaturesCommon,
CommonUI, ModelUI,
},
};

Expand Down Expand Up @@ -97,7 +96,7 @@ impl<T> ComponentMaybeTrace for T where T: Component + ComponentMsgObj + MaybeTr
pub struct RootComponent<T, M>
where
T: Component,
M: UIFeaturesCommon,
M: CommonUI,
{
inner: T,
returned_value: Option<Result<Obj, Error>>,
Expand All @@ -107,7 +106,7 @@ where
impl<T, M> RootComponent<T, M>
where
T: ComponentMaybeTrace,
M: UIFeaturesCommon,
M: CommonUI,
{
pub fn new(component: T) -> Self {
Self {
Expand Down
4 changes: 1 addition & 3 deletions core/embed/rust/src/ui/layout/simplified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use crate::ui::event::ButtonEvent;
use crate::ui::event::TouchEvent;
use crate::ui::{
component::{Component, Event, EventCtx, Never},
display,
ui_features::ModelUI,
UIFeaturesCommon,
display, CommonUI, ModelUI,
};

use num_traits::ToPrimitive;
Expand Down
21 changes: 18 additions & 3 deletions core/embed/rust/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,23 @@ pub mod model_tr;
#[cfg(feature = "model_tt")]
pub mod model_tt;

pub mod ui_features;
#[cfg(feature = "bootloader")]
pub mod ui_bootloader;
pub mod ui_common;
#[cfg(feature = "micropython")]
pub mod ui_features_fw;
pub mod ui_firmware;

pub use ui_features::UIFeaturesCommon;
pub use ui_common::CommonUI;

#[cfg(all(
feature = "model_mercury",
not(feature = "model_tr"),
not(feature = "model_tt")
))]
pub type ModelUI = crate::ui::model_mercury::UIMercury;

#[cfg(all(feature = "model_tr", not(feature = "model_tt")))]
pub type ModelUI = crate::ui::model_tr::UIModelTR;

#[cfg(feature = "model_tt")]
pub type ModelUI = crate::ui::model_tt::UIModelTT;
10 changes: 5 additions & 5 deletions core/embed/rust/src/ui/model_mercury/bootloader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use super::{
},
GREEN_LIGHT, GREY,
},
ModelMercuryFeatures,
UIMercury,
};

use crate::ui::{ui_features::UIFeaturesBootloader, UIFeaturesCommon};
use crate::ui::{ui_bootloader::BootloaderUI, CommonUI};

use crate::ui::{
display::{toif::Toif, LOADER_MAX},
Expand All @@ -53,10 +53,10 @@ pub type BootloaderString = String<128>;

const RECONNECT_MESSAGE: &str = "PLEASE RECONNECT\nTHE DEVICE";

const SCREEN: Rect = ModelMercuryFeatures::SCREEN;
const SCREEN: Rect = UIMercury::SCREEN;
const PROGRESS_TEXT_ORIGIN: Point = Point::new(2, 28);

impl ModelMercuryFeatures {
impl UIMercury {
fn screen_progress(
text: &str,
progress: u16,
Expand Down Expand Up @@ -122,7 +122,7 @@ impl ModelMercuryFeatures {
}
}

impl UIFeaturesBootloader for ModelMercuryFeatures {
impl BootloaderUI for UIMercury {
fn screen_welcome() {
let mut frame = Welcome::new();
show(&mut frame, true);
Expand Down
12 changes: 6 additions & 6 deletions core/embed/rust/src/ui/model_mercury/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{geometry::Rect, UIFeaturesCommon};
use super::{geometry::Rect, CommonUI};
use crate::ui::model_mercury::theme::backlight;

#[cfg(feature = "bootloader")]
Expand All @@ -7,18 +7,18 @@ pub mod component;
pub mod constant;
pub mod theme;

#[cfg(feature = "micropython")]
pub mod component_msg_obj;
pub mod cshape;
#[cfg(feature = "micropython")]
pub mod flow;
#[cfg(feature = "micropython")]
pub mod layout;
pub mod screens;
#[cfg(feature = "micropython")]
pub mod ui_features_fw;
pub mod ui_firmware;

pub struct ModelMercuryFeatures;
pub struct UIMercury;

impl UIFeaturesCommon for ModelMercuryFeatures {
impl CommonUI for UIMercury {
#[cfg(feature = "backlight")]
fn fadein() {
crate::ui::display::fade_backlight_duration(backlight::get_backlight_normal(), 150);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ use crate::{
obj::{LayoutMaybeTrace, LayoutObj, RootComponent},
util::{PropsList, RecoveryType},
},
ui_features::ModelUI,
ui_features_fw::{
UIFeaturesFirmware, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
ui_firmware::{
FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
},
ModelUI,
},
};

Expand All @@ -42,10 +42,10 @@ use super::{
self, new_confirm_action_simple, ConfirmActionExtra, ConfirmActionMenuStrings,
ConfirmActionStrings, ConfirmBlobParams, ShowInfoParams,
},
theme, ModelMercuryFeatures,
theme, UIMercury,
};

impl UIFeaturesFirmware for ModelMercuryFeatures {
impl FirmwareUI for UIMercury {
fn confirm_action(
title: TString<'static>,
action: Option<TString<'static>>,
Expand Down
8 changes: 4 additions & 4 deletions core/embed/rust/src/ui/model_tr/bootloader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{
bootloader::{BLD_BG, BLD_FG, ICON_ALERT, ICON_SPINNER, ICON_SUCCESS},
ICON_ARM_LEFT, ICON_ARM_RIGHT, TEXT_BOLD, TEXT_NORMAL,
},
ModelTRFeatures,
UIModelTR,
};

use crate::ui::{
Expand All @@ -34,7 +34,7 @@ mod intro;
mod menu;
mod welcome;

use crate::ui::ui_features::UIFeaturesBootloader;
use crate::ui::ui_bootloader::BootloaderUI;
use intro::Intro;
use menu::Menu;
use welcome::Welcome;
Expand All @@ -47,7 +47,7 @@ impl ReturnToC for ConfirmMsg {
}
}

impl ModelTRFeatures {
impl UIModelTR {
fn screen_progress(
text: &str,
text2: &str,
Expand Down Expand Up @@ -92,7 +92,7 @@ impl ModelTRFeatures {
}
}

impl UIFeaturesBootloader for ModelTRFeatures {
impl BootloaderUI for UIModelTR {
fn screen_welcome() {
let mut frame = Welcome::new();
show(&mut frame, true);
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions core/embed/rust/src/ui/model_tr/mod.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
use super::{geometry::Rect, UIFeaturesCommon};
use super::{geometry::Rect, CommonUI};

#[cfg(feature = "bootloader")]
pub mod bootloader;
pub mod common_messages;
pub mod component;
#[cfg(feature = "micropython")]
pub mod component_msg_obj;
pub mod constant;
pub mod cshape;
#[cfg(feature = "micropython")]
pub mod layout;
mod screens;
pub mod theme;

pub struct ModelTRFeatures {}
pub struct UIModelTR {}

#[cfg(feature = "micropython")]
pub mod ui_features_fw;
pub mod ui_firmware;

impl UIFeaturesCommon for ModelTRFeatures {
impl CommonUI for UIModelTR {
const SCREEN: Rect = constant::SCREEN;

fn screen_fatal_error(title: &str, msg: &str, footer: &str) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ use crate::{
component::{ButtonActions, ButtonLayout, Page},
constant,
},
ui_features::ModelUI,
ui_features_fw::{
UIFeaturesFirmware, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
ui_firmware::{
FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
},
ModelUI,
},
};

Expand All @@ -43,12 +43,12 @@ use super::{
FlowPages, Frame, Homescreen, Lockscreen, NumberInput, PassphraseEntry, PinEntry, Progress,
ScrollableFrame, ShareWords, ShowMore, SimpleChoice, WordlistEntry, WordlistType,
},
theme, ModelTRFeatures,
theme, UIModelTR,
};

use heapless::Vec;

impl UIFeaturesFirmware for ModelTRFeatures {
impl FirmwareUI for UIModelTR {
fn confirm_action(
title: TString<'static>,
action: Option<TString<'static>>,
Expand Down
10 changes: 5 additions & 5 deletions core/embed/rust/src/ui/model_tt/bootloader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use super::{
},
FG,
},
ModelTTFeatures,
UIModelTT,
};

use crate::ui::{ui_features::UIFeaturesBootloader, UIFeaturesCommon};
use crate::ui::{ui_bootloader::BootloaderUI, CommonUI};

use crate::ui::{
display::toif::Toif,
Expand All @@ -56,9 +56,9 @@ pub type BootloaderString = String<128>;

const RECONNECT_MESSAGE: &str = "PLEASE RECONNECT\nTHE DEVICE";

const SCREEN: Rect = ModelTTFeatures::SCREEN;
const SCREEN: Rect = UIModelTT::SCREEN;

impl ModelTTFeatures {
impl UIModelTT {
fn screen_progress(
text: &str,
progress: u16,
Expand Down Expand Up @@ -133,7 +133,7 @@ impl ModelTTFeatures {
}
}

impl UIFeaturesBootloader for ModelTTFeatures {
impl BootloaderUI for UIModelTT {
fn screen_welcome() {
let mut frame = Welcome::new();
show(&mut frame, true);
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions core/embed/rust/src/ui/model_tt/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{geometry::Rect, UIFeaturesCommon};
use super::{geometry::Rect, CommonUI};

#[cfg(feature = "bootloader")]
pub mod bootloader;
Expand All @@ -9,21 +9,21 @@ pub mod theme;
#[cfg(feature = "backlight")]
use crate::ui::model_tt::theme::backlight;

pub mod cshape;
#[cfg(feature = "micropython")]
pub mod layout;
pub mod component_msg_obj;
pub mod cshape;

use crate::ui::{
layout::simplified::show,
model_tt::component::{ErrorScreen, WelcomeScreen},
};

pub struct ModelTTFeatures;
pub struct UIModelTT;

#[cfg(feature = "micropython")]
pub mod ui_features_fw;
pub mod ui_firmware;

impl UIFeaturesCommon for ModelTTFeatures {
impl CommonUI for UIModelTT {
#[cfg(feature = "backlight")]
fn fadein() {
crate::ui::display::fade_backlight_duration(backlight::get_backlight_normal(), 150);
Expand Down
Loading

0 comments on commit 7e1f160

Please sign in to comment.