1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-03 16:56:07 +00:00

refactor(eckhart): separate firmware components

This commit is contained in:
obrusvit 2025-02-20 13:58:57 +01:00
parent 33de234c7a
commit a453c9de90
34 changed files with 124 additions and 125 deletions

View File

@ -11,7 +11,8 @@ use crate::{
}, },
}; };
use super::{ use super::super::{
component::{Button, ButtonMsg::Clicked, ButtonStyleSheet},
constant::WIDTH, constant::WIDTH,
theme::{ theme::{
bootloader::{ bootloader::{
@ -20,9 +21,6 @@ use super::{
}, },
WHITE, WHITE,
}, },
Button,
ButtonMsg::Clicked,
ButtonStyleSheet,
}; };
const ICON_TOP: i16 = 17; const ICON_TOP: i16 = 17;
@ -51,7 +49,7 @@ pub struct ConfirmInfo<'a> {
pub close_button: Child<Button>, pub close_button: Child<Button>,
} }
pub struct Confirm<'a> { pub struct ConfirmScreen<'a> {
bg: Pad, bg: Pad,
content_pad: Pad, content_pad: Pad,
bg_color: Color, bg_color: Color,
@ -64,7 +62,7 @@ pub struct Confirm<'a> {
show_info: bool, show_info: bool,
} }
impl<'a> Confirm<'a> { impl<'a> ConfirmScreen<'a> {
pub fn new( pub fn new(
bg_color: Color, bg_color: Color,
left_button: Button, left_button: Button,
@ -119,7 +117,7 @@ impl<'a> Confirm<'a> {
} }
} }
impl Component for Confirm<'_> { impl Component for ConfirmScreen<'_> {
type Msg = ConfirmMsg; type Msg = ConfirmMsg;
fn place(&mut self, bounds: Rect) -> Rect { fn place(&mut self, bounds: Rect) -> Rect {
@ -241,7 +239,7 @@ impl Component for Confirm<'_> {
} }
#[cfg(feature = "ui_debug")] #[cfg(feature = "ui_debug")]
impl crate::trace::Trace for Confirm<'_> { impl crate::trace::Trace for ConfirmScreen<'_> {
fn trace(&self, t: &mut dyn crate::trace::Tracer) { fn trace(&self, t: &mut dyn crate::trace::Tracer) {
t.component("BlConfirm"); t.component("BlConfirm");
} }

View File

@ -11,10 +11,7 @@ use heapless::String;
use super::{ use super::{
bootloader::welcome::Welcome, bootloader::welcome::Welcome,
component::{ component::{Button, ResultScreen, WelcomeScreen},
bl_confirm::{Confirm, ConfirmTitle},
Button, ResultScreen, WelcomeScreen,
},
cshape::{render_loader, LoaderRange}, cshape::{render_loader, LoaderRange},
fonts, fonts,
theme::{ theme::{
@ -45,9 +42,11 @@ use super::theme::bootloader::BLD_WARN_COLOR;
use intro::Intro; use intro::Intro;
use menu::Menu; use menu::Menu;
mod confirm;
pub mod intro; pub mod intro;
pub mod menu; pub mod menu;
pub mod welcome; pub mod welcome;
use confirm::{Confirm, ConfirmTitle};
pub type BootloaderString = String<128>; pub type BootloaderString = String<128>;

View File

@ -13,7 +13,7 @@ use crate::{
}, },
}; };
use super::theme; use super::super::theme;
pub enum ButtonMsg { pub enum ButtonMsg {
Pressed, Pressed,

View File

@ -10,8 +10,10 @@ use crate::{
}; };
use super::{ use super::{
constant::WIDTH, super::{
theme::{FATAL_ERROR_COLOR, ICON_WARNING40, RESULT_FOOTER_START, RESULT_PADDING, WHITE}, constant::WIDTH,
theme::{FATAL_ERROR_COLOR, ICON_WARNING40, RESULT_FOOTER_START, RESULT_PADDING, WHITE},
},
ResultFooter, ResultStyle, ResultFooter, ResultStyle,
}; };
@ -22,7 +24,7 @@ const MESSAGE_AREA_START: i16 = 90;
#[cfg(feature = "bootloader")] #[cfg(feature = "bootloader")]
const STYLE: &ResultStyle = &crate::ui::layout_eckhart::theme::bootloader::RESULT_WIPE; const STYLE: &ResultStyle = &crate::ui::layout_eckhart::theme::bootloader::RESULT_WIPE;
#[cfg(not(feature = "bootloader"))] #[cfg(not(feature = "bootloader"))]
const STYLE: &ResultStyle = &super::theme::RESULT_ERROR; const STYLE: &ResultStyle = &super::super::theme::RESULT_ERROR;
pub struct ErrorScreen<'a> { pub struct ErrorScreen<'a> {
bg: Pad, bg: Pad,

View File

@ -1,43 +1,9 @@
mod action_bar;
pub mod bl_confirm;
mod button; mod button;
mod error; mod error;
mod header;
mod hint;
mod hold_to_confirm;
mod keyboard;
mod number_input_screen;
mod result; mod result;
mod select_word_screen;
mod share_words;
mod text_screen;
mod vertical_menu;
mod vertical_menu_screen;
mod welcome_screen; mod welcome_screen;
pub use action_bar::{ActionBar, ActionBarMsg};
pub use button::{Button, ButtonContent, ButtonMsg, ButtonStyle, ButtonStyleSheet, IconText}; pub use button::{Button, ButtonContent, ButtonMsg, ButtonStyle, ButtonStyleSheet, IconText};
pub use error::ErrorScreen; pub use error::ErrorScreen;
pub use header::{Header, HeaderMsg};
pub use hint::Hint;
pub use hold_to_confirm::HoldToConfirmAnim;
#[cfg(feature = "translations")]
pub use keyboard::{
bip39::Bip39Input,
mnemonic::{MnemonicInput, MnemonicKeyboard, MnemonicKeyboardMsg},
passphrase::{PassphraseKeyboard, PassphraseKeyboardMsg},
pin::{PinKeyboard, PinKeyboardMsg},
slip39::Slip39Input,
word_count_screen::{SelectWordCountMsg, SelectWordCountScreen},
};
pub use number_input_screen::{NumberInputScreenMsg, NumberInputScreen};
pub use result::{ResultFooter, ResultScreen, ResultStyle}; pub use result::{ResultFooter, ResultScreen, ResultStyle};
pub use select_word_screen::{SelectWordMsg, SelectWordScreen};
#[cfg(feature = "translations")]
pub use share_words::{ShareWordsScreen, ShareWordsScreenMsg};
pub use text_screen::{AllowedTextContent, TextScreen, TextScreenMsg};
pub use vertical_menu::{VerticalMenu, VerticalMenuMsg, MENU_MAX_ITEMS};
pub use vertical_menu_screen::{VerticalMenuScreen, VerticalMenuScreenMsg};
pub use welcome_screen::WelcomeScreen; pub use welcome_screen::WelcomeScreen;
use super::{constant, theme};

View File

@ -10,9 +10,9 @@ use crate::{
}, },
}; };
use super::{ use super::super::{
super::fonts,
constant::WIDTH, constant::WIDTH,
fonts,
theme::{FG, RESULT_FOOTER_START, RESULT_PADDING}, theme::{FG, RESULT_FOOTER_START, RESULT_PADDING},
}; };

View File

@ -5,7 +5,7 @@ use crate::ui::{
shape::Renderer, shape::Renderer,
}; };
use super::{super::fonts, theme}; use super::super::{fonts, theme};
const TEXT_BOTTOM_MARGIN: i16 = 54; const TEXT_BOTTOM_MARGIN: i16 = 54;
const ICON_TOP_MARGIN: i16 = 48; const ICON_TOP_MARGIN: i16 = 48;

View File

@ -13,7 +13,7 @@ use crate::{
}, },
}; };
use super::component::{ use super::firmware::{
AllowedTextContent, MnemonicInput, MnemonicKeyboard, MnemonicKeyboardMsg, NumberInputScreen, AllowedTextContent, MnemonicInput, MnemonicKeyboard, MnemonicKeyboardMsg, NumberInputScreen,
NumberInputScreenMsg, PinKeyboard, PinKeyboardMsg, SelectWordCountMsg, SelectWordCountScreen, NumberInputScreenMsg, PinKeyboard, PinKeyboardMsg, SelectWordCountMsg, SelectWordCountScreen,
SelectWordMsg, SelectWordScreen, TextScreen, TextScreenMsg, SelectWordMsg, SelectWordScreen, TextScreen, TextScreenMsg,

View File

@ -9,8 +9,8 @@ use crate::{
}; };
use super::{ use super::{
button::{Button, ButtonContent, ButtonMsg}, super::component::{Button, ButtonContent, ButtonMsg, ButtonStyleSheet},
theme, ButtonStyleSheet, HoldToConfirmAnim, theme, HoldToConfirmAnim,
}; };
/// Component for control buttons in the bottom of the screen. /// Component for control buttons in the bottom of the screen.

View File

@ -5,7 +5,6 @@ use crate::{
component::{text::TextStyle, Component, Event, EventCtx, Label}, component::{text::TextStyle, Component, Event, EventCtx, Label},
display::{Color, Icon}, display::{Color, Icon},
geometry::{Alignment2D, Insets, Offset, Rect}, geometry::{Alignment2D, Insets, Offset, Rect},
layout_eckhart::constant,
lerp::Lerp, lerp::Lerp,
shape::{self, Renderer}, shape::{self, Renderer},
util::animation_disabled, util::animation_disabled,
@ -13,8 +12,8 @@ use crate::{
}; };
use super::{ use super::{
button::{Button, ButtonContent, ButtonMsg}, super::component::{Button, ButtonContent, ButtonMsg},
theme, constant, theme,
}; };
const ANIMATION_TIME_MS: u32 = 1000; const ANIMATION_TIME_MS: u32 = 1000;

View File

@ -11,7 +11,7 @@ use crate::{
}; };
use super::{ use super::{
super::{component::Header, cshape::ScreenBorder, theme}, super::{cshape::ScreenBorder, firmware::Header, theme},
constant::SCREEN, constant::SCREEN,
}; };

View File

@ -8,14 +8,12 @@ use crate::{
}; };
use super::super::super::{ use super::super::super::{
component::{ component::{Button, ButtonMsg},
keyboard::{
common::{render_pending_marker, MultiTapKeyboard},
mnemonic::{MnemonicInput, MnemonicInputMsg, MNEMONIC_KEY_COUNT},
},
Button, ButtonMsg,
},
constant::WIDTH, constant::WIDTH,
firmware::keyboard::{
common::{render_pending_marker, MultiTapKeyboard},
mnemonic::{MnemonicInput, MnemonicInputMsg, MNEMONIC_KEY_COUNT},
},
theme, theme,
}; };

View File

@ -9,7 +9,7 @@ use crate::{
use super::{ use super::{
super::super::{ super::super::{
component::button::{Button, ButtonContent, ButtonMsg, ButtonStyleSheet}, component::{Button, ButtonContent, ButtonMsg, ButtonStyleSheet},
constant::SCREEN, constant::SCREEN,
theme, theme,
}, },

View File

@ -8,14 +8,12 @@ use crate::{
}; };
use super::super::super::{ use super::super::super::{
component::{ component::ButtonContent,
button::ButtonContent,
keyboard::{
common::{INPUT_TOUCH_HEIGHT, KEYBOARD_INPUT_INSETS, KEYPAD_VISIBLE_HEIGHT},
keypad::{ButtonState, Keypad, KeypadButton, KeypadMsg},
},
},
constant::SCREEN, constant::SCREEN,
firmware::keyboard::{
common::{INPUT_TOUCH_HEIGHT, KEYBOARD_INPUT_INSETS, KEYPAD_VISIBLE_HEIGHT},
keypad::{ButtonState, Keypad, KeypadButton, KeypadMsg},
},
theme, theme,
}; };

View File

@ -22,7 +22,7 @@ use crate::{
}; };
use super::super::{ use super::super::{
button::{Button, ButtonContent, ButtonMsg, ButtonStyleSheet}, super::component::{Button, ButtonContent, ButtonMsg, ButtonStyleSheet},
constant::SCREEN, constant::SCREEN,
keyboard::{ keyboard::{
common::{ common::{

View File

@ -16,19 +16,13 @@ use crate::{
}, },
}; };
use super::super::super::{ use super::{
component::{ super::super::{component::ButtonContent, constant::SCREEN, theme},
button::ButtonContent, common::{
constant::SCREEN, DisplayStyle, FADING_ICON_COLORS, FADING_ICON_COUNT, INPUT_TOUCH_HEIGHT,
keyboard::{ KEYBOARD_INPUT_INSETS, KEYBOARD_INPUT_RADIUS, KEYPAD_VISIBLE_HEIGHT,
common::{
DisplayStyle, FADING_ICON_COLORS, FADING_ICON_COUNT, INPUT_TOUCH_HEIGHT,
KEYBOARD_INPUT_INSETS, KEYBOARD_INPUT_RADIUS, KEYPAD_VISIBLE_HEIGHT,
},
keypad::{ButtonState, Keypad, KeypadMsg, KeypadState},
},
}, },
theme, keypad::{ButtonState, Keypad, KeypadMsg, KeypadState},
}; };
pub enum PinKeyboardMsg { pub enum PinKeyboardMsg {

View File

@ -14,12 +14,10 @@ use crate::{
}; };
use super::super::super::{ use super::super::super::{
component::{ component::{Button, ButtonMsg},
keyboard::{ firmware::keyboard::{
common::{render_pending_marker, MultiTapKeyboard}, common::{render_pending_marker, MultiTapKeyboard},
mnemonic::{MnemonicInput, MnemonicInputMsg, MNEMONIC_KEY_COUNT}, mnemonic::{MnemonicInput, MnemonicInputMsg, MNEMONIC_KEY_COUNT},
},
Button, ButtonMsg,
}, },
theme, theme,
}; };

View File

@ -8,8 +8,12 @@ use crate::{
}; };
use super::super::{ use super::super::{
super::{super::constant::SCREEN, theme}, super::{
Button, ButtonMsg, Header, super::constant::SCREEN,
component::{Button, ButtonMsg},
theme,
},
Header,
}; };
use heapless::Vec; use heapless::Vec;

View File

@ -0,0 +1,34 @@
mod action_bar;
mod header;
mod hint;
mod hold_to_confirm;
mod keyboard;
mod number_input_screen;
mod select_word_screen;
mod share_words;
mod text_screen;
mod vertical_menu;
mod vertical_menu_screen;
pub use action_bar::{ActionBar, ActionBarMsg};
pub use header::{Header, HeaderMsg};
pub use hint::Hint;
pub use hold_to_confirm::HoldToConfirmAnim;
#[cfg(feature = "translations")]
pub use keyboard::{
bip39::Bip39Input,
mnemonic::{MnemonicInput, MnemonicKeyboard, MnemonicKeyboardMsg},
passphrase::{PassphraseKeyboard, PassphraseKeyboardMsg},
pin::{PinKeyboard, PinKeyboardMsg},
slip39::Slip39Input,
word_count_screen::{SelectWordCountMsg, SelectWordCountScreen},
};
pub use number_input_screen::{NumberInputScreen, NumberInputScreenMsg};
pub use select_word_screen::{SelectWordMsg, SelectWordScreen};
#[cfg(feature = "translations")]
pub use share_words::{ShareWordsScreen, ShareWordsScreenMsg};
pub use text_screen::{AllowedTextContent, TextScreen, TextScreenMsg};
pub use vertical_menu::{VerticalMenu, VerticalMenuMsg, MENU_MAX_ITEMS};
pub use vertical_menu_screen::{VerticalMenuScreen, VerticalMenuScreenMsg};
use super::{constant, theme};

View File

@ -9,8 +9,12 @@ use crate::{
}; };
use super::{ use super::{
super::{super::constant::SCREEN, fonts, theme}, super::{
ActionBar, ActionBarMsg, Button, ButtonMsg, Header, HeaderMsg, super::constant::SCREEN,
component::{Button, ButtonMsg},
fonts, theme,
},
ActionBar, ActionBarMsg, Header, HeaderMsg,
}; };
pub enum NumberInputScreenMsg { pub enum NumberInputScreenMsg {

View File

@ -9,8 +9,9 @@ use crate::{
}; };
use super::super::{ use super::super::{
component::{Button, Header, HeaderMsg, VerticalMenu, VerticalMenuMsg}, component::Button,
constant::SCREEN, constant::SCREEN,
firmware::{Header, HeaderMsg, VerticalMenu, VerticalMenuMsg},
theme, theme,
}; };

View File

@ -15,8 +15,9 @@ use crate::{
use heapless::Vec; use heapless::Vec;
use super::super::{ use super::super::{
component::{button::Button, ActionBar, ActionBarMsg, Header, HeaderMsg, Hint}, component::Button,
constant::SCREEN, constant::SCREEN,
firmware::{ActionBar, ActionBarMsg, Header, HeaderMsg, Hint},
fonts, theme, fonts, theme,
}; };

View File

@ -10,7 +10,7 @@ use crate::ui::{
util::Pager, util::Pager,
}; };
pub(crate) use super::{action_bar::ActionBarMsg, ActionBar, Header, HeaderMsg, Hint}; use super::{action_bar::ActionBarMsg, ActionBar, Header, HeaderMsg, Hint};
/// Full-screen component for rendering text. /// Full-screen component for rendering text.
/// ///

View File

@ -4,12 +4,11 @@ use crate::ui::{
shape::{Bar, Renderer}, shape::{Bar, Renderer},
}; };
use heapless::Vec; use super::{
super::component::{Button, ButtonMsg},
use super::super::{
component::{Button, ButtonMsg},
theme, theme,
}; };
use heapless::Vec;
/// Number of buttons. /// Number of buttons.
/// Presently, VerticalMenu holds only fixed number of buttons. /// Presently, VerticalMenu holds only fixed number of buttons.

View File

@ -14,10 +14,7 @@ use crate::{
}, },
}; };
use super::super::{ use super::{constant::SCREEN, theme, Header, HeaderMsg, VerticalMenu, VerticalMenuMsg};
component::{constant::SCREEN, Header, HeaderMsg, VerticalMenu, VerticalMenuMsg},
theme,
};
pub struct VerticalMenuScreen { pub struct VerticalMenuScreen {
header: Header, header: Header,

View File

@ -13,7 +13,7 @@ use crate::{
}; };
use super::super::{ use super::super::{
component::{ firmware::{
ActionBar, Header, HeaderMsg, Hint, TextScreen, TextScreenMsg, VerticalMenu, ActionBar, Header, HeaderMsg, Hint, TextScreen, TextScreenMsg, VerticalMenu,
VerticalMenuScreen, VerticalMenuScreenMsg, VerticalMenuScreen, VerticalMenuScreenMsg,
}, },

View File

@ -16,8 +16,9 @@ use crate::{
}; };
use super::super::{ use super::super::{
component::{ component::Button,
ActionBar, Button, Header, HeaderMsg, Hint, TextScreen, TextScreenMsg, VerticalMenu, firmware::{
ActionBar, Header, HeaderMsg, Hint, TextScreen, TextScreenMsg, VerticalMenu,
VerticalMenuScreen, VerticalMenuScreenMsg, VerticalMenuScreen, VerticalMenuScreenMsg,
}, },
theme, theme,

View File

@ -9,16 +9,17 @@ use crate::{
FlowController, FlowMsg, SwipeFlow, FlowController, FlowMsg, SwipeFlow,
}, },
geometry::Direction, geometry::Direction,
layout_eckhart::{
component::{
ActionBar, Button, Header, PassphraseKeyboard, PassphraseKeyboardMsg, TextScreen,
TextScreenMsg,
},
fonts, theme,
},
}, },
}; };
use super::super::{
component::Button,
firmware::{
ActionBar, Header, PassphraseKeyboard, PassphraseKeyboardMsg, TextScreen, TextScreenMsg,
},
fonts, theme,
};
#[derive(Copy, Clone, PartialEq, Eq)] #[derive(Copy, Clone, PartialEq, Eq)]
pub enum RequestPassphrase { pub enum RequestPassphrase {
Keypad, Keypad,

View File

@ -18,8 +18,9 @@ use crate::{
use heapless::Vec; use heapless::Vec;
use super::super::{ use super::super::{
component::{ component::Button,
ActionBar, Button, Header, ShareWordsScreen, ShareWordsScreenMsg, TextScreen, TextScreenMsg, firmware::{
ActionBar, Header, ShareWordsScreen, ShareWordsScreenMsg, TextScreen, TextScreenMsg,
}, },
theme, theme,
}; };

View File

@ -15,6 +15,8 @@ use crate::strutil::ShortString;
pub mod bootloader; pub mod bootloader;
pub mod component; pub mod component;
pub mod constant; pub mod constant;
#[cfg(feature = "micropython")]
pub mod firmware;
pub mod theme; pub mod theme;
#[cfg(feature = "micropython")] #[cfg(feature = "micropython")]
@ -24,6 +26,8 @@ pub mod cshape;
pub mod flow; pub mod flow;
pub mod fonts; pub mod fonts;
pub mod screens; pub mod screens;
#[cfg(feature = "bootloader")]
pub mod ui_bootloader;
#[cfg(feature = "micropython")] #[cfg(feature = "micropython")]
pub mod ui_firmware; pub mod ui_firmware;

View File

@ -25,10 +25,10 @@ use crate::{
}; };
use super::{ use super::{
component::{ component::Button,
ActionBar, Bip39Input, Button, Header, HeaderMsg, Hint, MnemonicKeyboard, firmware::{
NumberInputScreen, PinKeyboard, SelectWordCountScreen, SelectWordScreen, Slip39Input, ActionBar, Bip39Input, Header, HeaderMsg, Hint, MnemonicKeyboard, NumberInputScreen,
TextScreen, PinKeyboard, SelectWordCountScreen, SelectWordScreen, Slip39Input, TextScreen,
}, },
flow, fonts, theme, UIEckhart, flow, fonts, theme, UIEckhart,
}; };