mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-07 15:18:08 +00:00
fixup! feat(core/ui): rust-based UI flows
This commit is contained in:
parent
40862e89be
commit
c741b2baba
@ -203,9 +203,7 @@ static void _librust_qstrs(void) {
|
||||
MP_QSTR_fingerprint;
|
||||
MP_QSTR_firmware_update__title;
|
||||
MP_QSTR_firmware_update__title_fingerprint;
|
||||
MP_QSTR_flow;
|
||||
MP_QSTR_flow_get_address;
|
||||
MP_QSTR_get_address;
|
||||
MP_QSTR_get_language;
|
||||
MP_QSTR_hold;
|
||||
MP_QSTR_hold_danger;
|
||||
|
@ -18,7 +18,7 @@ const ANIMATION_DURATION: Duration = Duration::from_millis(333);
|
||||
/// If a swipe is detected:
|
||||
/// - currently active component is asked to handle the event,
|
||||
/// - if it can't then FlowState::handle_swipe is consulted.
|
||||
pub struct Flow<Q, S> {
|
||||
pub struct SwipeFlow<Q, S> {
|
||||
/// Current state.
|
||||
state: Q,
|
||||
/// FlowStore with all screens/components.
|
||||
@ -37,7 +37,7 @@ struct Transition<Q> {
|
||||
direction: SwipeDirection,
|
||||
}
|
||||
|
||||
impl<Q: FlowState, S: FlowStore> Flow<Q, S> {
|
||||
impl<Q: FlowState, S: FlowStore> SwipeFlow<Q, S> {
|
||||
pub fn new(init: Q, store: S) -> Result<Self, error::Error> {
|
||||
Ok(Self {
|
||||
state: init,
|
||||
@ -126,7 +126,7 @@ impl<Q: FlowState, S: FlowStore> Flow<Q, S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Q: FlowState, S: FlowStore> Component for Flow<Q, S> {
|
||||
impl<Q: FlowState, S: FlowStore> Component for SwipeFlow<Q, S> {
|
||||
type Msg = FlowMsg;
|
||||
|
||||
fn place(&mut self, bounds: Rect) -> Rect {
|
||||
@ -178,14 +178,14 @@ impl<Q: FlowState, S: FlowStore> Component for Flow<Q, S> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "ui_debug")]
|
||||
impl<Q: FlowState, S: FlowStore> crate::trace::Trace for Flow<Q, S> {
|
||||
impl<Q: FlowState, S: FlowStore> crate::trace::Trace for SwipeFlow<Q, S> {
|
||||
fn trace(&self, t: &mut dyn crate::trace::Tracer) {
|
||||
self.store.trace(self.state.index(), t)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "micropython")]
|
||||
impl<Q: FlowState, S: FlowStore> crate::ui::layout::obj::ComponentMsgObj for Flow<Q, S> {
|
||||
impl<Q: FlowState, S: FlowStore> crate::ui::layout::obj::ComponentMsgObj for SwipeFlow<Q, S> {
|
||||
fn msg_try_into_obj(
|
||||
&self,
|
||||
msg: Self::Msg,
|
||||
|
@ -5,6 +5,6 @@ mod store;
|
||||
mod swipe;
|
||||
|
||||
pub use base::{FlowMsg, FlowState, Swipable, SwipeDirection};
|
||||
pub use flow::Flow;
|
||||
pub use flow::SwipeFlow;
|
||||
pub use page::{IgnoreSwipe, SwipePage};
|
||||
pub use store::{flow_store, FlowStore};
|
||||
|
@ -6,7 +6,7 @@ pub mod component;
|
||||
pub mod constant;
|
||||
pub mod display;
|
||||
pub mod event;
|
||||
#[cfg(feature = "micropython")]
|
||||
#[cfg(all(feature = "micropython", feature = "model_mercury"))]
|
||||
pub mod flow;
|
||||
pub mod geometry;
|
||||
pub mod lerp;
|
||||
|
@ -7,7 +7,7 @@ use crate::{
|
||||
Qr, Timeout,
|
||||
},
|
||||
flow::{
|
||||
base::Decision, flow_store, Flow, FlowMsg, FlowState, FlowStore, SwipeDirection,
|
||||
base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeDirection, SwipeFlow,
|
||||
SwipePage,
|
||||
},
|
||||
},
|
||||
@ -103,8 +103,7 @@ pub extern "C" fn new_get_address(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
}
|
||||
|
||||
impl GetAddress {
|
||||
fn new(args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
|
||||
// Result<Flow<GetAddress, impl FlowStore>, error::Error> {
|
||||
fn new(_args: &[Obj], _kwargs: &Map) -> Result<Obj, error::Error> {
|
||||
let store = flow_store()
|
||||
.add(
|
||||
Frame::left_aligned(
|
||||
@ -179,7 +178,7 @@ impl GetAddress {
|
||||
),
|
||||
|_| Some(FlowMsg::Confirmed),
|
||||
)?;
|
||||
let res = Flow::new(GetAddress::Address, store)?;
|
||||
let res = SwipeFlow::new(GetAddress::Address, store)?;
|
||||
Ok(LayoutObj::new(res)?.into())
|
||||
}
|
||||
}
|
||||
|
@ -1336,10 +1336,7 @@ extern "C" fn new_show_tx_context_menu(n_args: usize, args: *const Obj, kwargs:
|
||||
|
||||
let options: [(StrBuffer, Icon); 3] = [
|
||||
(StrBuffer::from("Address QR code"), theme::ICON_QR_CODE),
|
||||
(
|
||||
StrBuffer::from("Fee info"),
|
||||
theme::ICON_CHEVRON_RIGHT,
|
||||
),
|
||||
(StrBuffer::from("Fee info"), theme::ICON_CHEVRON_RIGHT),
|
||||
(StrBuffer::from("Cancel transaction"), theme::ICON_CANCEL),
|
||||
];
|
||||
let content = VerticalMenu::context_menu(options);
|
||||
@ -2197,7 +2194,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
Qstr::MP_QSTR_show_wait_text => obj_fn_1!(new_show_wait_text).as_obj(),
|
||||
|
||||
/// def flow_get_address() -> LayoutObj[UiResult]:
|
||||
/// """Get address / receive funds."
|
||||
/// """Get address / receive funds."""
|
||||
Qstr::MP_QSTR_flow_get_address => obj_fn_kw!(0, flow::get_address::new_get_address).as_obj(),
|
||||
};
|
||||
|
||||
|
@ -70,11 +70,6 @@ def check_homescreen_format(data: bytes) -> bool:
|
||||
"""Check homescreen format and dimensions."""
|
||||
|
||||
|
||||
# rust/src/ui/model_mercury/layout.rs
|
||||
def flow_get_address() -> LayoutObj[UiResult]:
|
||||
"""Get address / receive funds."
|
||||
|
||||
|
||||
# rust/src/ui/model_mercury/layout.rs
|
||||
def confirm_action(
|
||||
*,
|
||||
@ -528,6 +523,11 @@ def confirm_firmware_update(
|
||||
# rust/src/ui/model_mercury/layout.rs
|
||||
def show_wait_text(message: str, /) -> LayoutObj[None]:
|
||||
"""Show single-line text in the middle of the screen."""
|
||||
|
||||
|
||||
# rust/src/ui/model_mercury/layout.rs
|
||||
def flow_get_address() -> LayoutObj[UiResult]:
|
||||
"""Get address / receive funds."""
|
||||
CONFIRMED: UiResult
|
||||
CANCELLED: UiResult
|
||||
INFO: UiResult
|
||||
|
@ -239,7 +239,6 @@ async def handle_EndSession(msg: EndSession) -> Success:
|
||||
|
||||
async def handle_Ping(msg: Ping) -> Success:
|
||||
if msg.button_protection:
|
||||
from trezor.enums import ButtonRequestType as B
|
||||
from trezor.ui.layouts.mercury import flow_demo
|
||||
|
||||
await flow_demo()
|
||||
|
Loading…
Reference in New Issue
Block a user