mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
refactor(core): move show_group_share_success
This commit is contained in:
parent
99b450545a
commit
6bb6ce401c
@ -299,6 +299,21 @@ extern "C" fn new_show_checklist(n_args: usize, args: *const Obj, kwargs: *mut M
|
||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||
}
|
||||
|
||||
extern "C" fn new_show_group_share_success(
|
||||
n_args: usize,
|
||||
args: *const Obj,
|
||||
kwargs: *mut Map,
|
||||
) -> Obj {
|
||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||
let lines_iterable: Obj = kwargs.get(Qstr::MP_QSTR_lines)?;
|
||||
let lines: [TString; 4] = util::iter_into_array(lines_iterable)?;
|
||||
|
||||
let layout = ModelUI::show_group_share_success(lines)?;
|
||||
Ok(LayoutObj::new_root(layout)?.into())
|
||||
};
|
||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||
}
|
||||
|
||||
extern "C" fn new_show_homescreen(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||
let label: TString<'static> = kwargs
|
||||
@ -676,6 +691,13 @@ pub static mp_module_trezorui_api: Module = obj_module! {
|
||||
/// mark next to them. Limited to 3 items."""
|
||||
Qstr::MP_QSTR_show_checklist => obj_fn_kw!(0, new_show_checklist).as_obj(),
|
||||
|
||||
/// def show_group_share_success(
|
||||
/// *,
|
||||
/// lines: Iterable[str],
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Shown after successfully finishing a group."""
|
||||
Qstr::MP_QSTR_show_group_share_success => obj_fn_kw!(0, new_show_group_share_success).as_obj(),
|
||||
|
||||
/// def show_homescreen(
|
||||
/// *,
|
||||
/// label: str | None,
|
||||
|
@ -909,35 +909,6 @@ extern "C" fn new_prompt_backup() -> Obj {
|
||||
unsafe { util::try_or_raise(block) }
|
||||
}
|
||||
|
||||
extern "C" fn new_show_group_share_success(
|
||||
n_args: usize,
|
||||
args: *const Obj,
|
||||
kwargs: *mut Map,
|
||||
) -> Obj {
|
||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||
let lines_iterable: Obj = kwargs.get(Qstr::MP_QSTR_lines)?;
|
||||
let lines: [TString; 4] = util::iter_into_array(lines_iterable)?;
|
||||
|
||||
let paragraphs = ParagraphVecShort::from_iter([
|
||||
Paragraph::new(&theme::TEXT_NORMAL_GREY_EXTRA_LIGHT, lines[0]).centered(),
|
||||
Paragraph::new(&theme::TEXT_DEMIBOLD, lines[1]).centered(),
|
||||
Paragraph::new(&theme::TEXT_NORMAL_GREY_EXTRA_LIGHT, lines[2]).centered(),
|
||||
Paragraph::new(&theme::TEXT_DEMIBOLD, lines[3]).centered(),
|
||||
])
|
||||
.into_paragraphs()
|
||||
.with_placement(geometry::LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let obj = LayoutObj::new(SwipeUpScreen::new(
|
||||
Frame::left_aligned("".into(), SwipeContent::new(paragraphs))
|
||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||
.with_swipe(Direction::Up, SwipeSettings::default()),
|
||||
))?;
|
||||
|
||||
Ok(obj.into())
|
||||
};
|
||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||
}
|
||||
|
||||
extern "C" fn new_confirm_fido(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
||||
#[cfg(feature = "universal_fw")]
|
||||
return flow::confirm_fido::new_confirm_fido(n_args, args, kwargs);
|
||||
@ -1173,13 +1144,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// """Device recovery homescreen."""
|
||||
Qstr::MP_QSTR_flow_continue_recovery => obj_fn_kw!(0, new_continue_recovery).as_obj(),
|
||||
|
||||
/// def show_group_share_success(
|
||||
/// *,
|
||||
/// lines: Iterable[str]
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Shown after successfully finishing a group."""
|
||||
Qstr::MP_QSTR_show_group_share_success => obj_fn_kw!(0, new_show_group_share_success).as_obj(),
|
||||
|
||||
/// def flow_get_address(
|
||||
/// *,
|
||||
/// address: str | bytes,
|
||||
|
@ -16,7 +16,7 @@ use crate::{
|
||||
},
|
||||
CachedJpeg, ComponentExt, Never, Timeout,
|
||||
},
|
||||
geometry::Direction,
|
||||
geometry::{self, Direction},
|
||||
layout::{
|
||||
obj::{LayoutMaybeTrace, LayoutObj, RootComponent},
|
||||
util::RecoveryType,
|
||||
@ -359,6 +359,26 @@ impl UIFeaturesFirmware for ModelMercuryFeatures {
|
||||
Ok(layout)
|
||||
}
|
||||
|
||||
fn show_group_share_success(
|
||||
lines: [TString<'static>; 4],
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
let paragraphs = ParagraphVecShort::from_iter([
|
||||
Paragraph::new(&theme::TEXT_NORMAL_GREY_EXTRA_LIGHT, lines[0]).centered(),
|
||||
Paragraph::new(&theme::TEXT_DEMIBOLD, lines[1]).centered(),
|
||||
Paragraph::new(&theme::TEXT_NORMAL_GREY_EXTRA_LIGHT, lines[2]).centered(),
|
||||
Paragraph::new(&theme::TEXT_DEMIBOLD, lines[3]).centered(),
|
||||
])
|
||||
.into_paragraphs()
|
||||
.with_placement(geometry::LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let layout = RootComponent::new(SwipeUpScreen::new(
|
||||
Frame::left_aligned("".into(), SwipeContent::new(paragraphs))
|
||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||
.with_swipe(Direction::Up, SwipeSettings::default()),
|
||||
));
|
||||
Ok(layout)
|
||||
}
|
||||
|
||||
fn show_homescreen(
|
||||
label: TString<'static>,
|
||||
hold: bool,
|
||||
|
@ -1014,35 +1014,6 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||
}
|
||||
|
||||
extern "C" fn new_show_group_share_success(
|
||||
n_args: usize,
|
||||
args: *const Obj,
|
||||
kwargs: *mut Map,
|
||||
) -> Obj {
|
||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||
let lines_iterable: Obj = kwargs.get(Qstr::MP_QSTR_lines)?;
|
||||
let lines: [TString; 4] = util::iter_into_array(lines_iterable)?;
|
||||
|
||||
let [l0, l1, l2, l3] = lines;
|
||||
|
||||
let paragraphs = Paragraphs::new([
|
||||
Paragraph::new(&theme::TEXT_MONO, l0),
|
||||
Paragraph::new(&theme::TEXT_BOLD, l1),
|
||||
Paragraph::new(&theme::TEXT_MONO, l2),
|
||||
Paragraph::new(&theme::TEXT_BOLD, l3),
|
||||
]);
|
||||
|
||||
content_in_button_page(
|
||||
"".into(),
|
||||
paragraphs,
|
||||
TR::buttons__continue.into(),
|
||||
None,
|
||||
false,
|
||||
)
|
||||
};
|
||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// from trezor import utils
|
||||
@ -1246,11 +1217,4 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Device recovery homescreen."""
|
||||
Qstr::MP_QSTR_confirm_recovery => obj_fn_kw!(0, new_confirm_recovery).as_obj(),
|
||||
|
||||
/// def show_group_share_success(
|
||||
/// *,
|
||||
/// lines: Iterable[str],
|
||||
/// ) -> LayoutObj[int]:
|
||||
/// """Shown after successfully finishing a group."""
|
||||
Qstr::MP_QSTR_show_group_share_success => obj_fn_kw!(0, new_show_group_share_success).as_obj(),
|
||||
};
|
||||
|
@ -375,6 +375,24 @@ impl UIFeaturesFirmware for ModelTRFeatures {
|
||||
Ok(layout)
|
||||
}
|
||||
|
||||
fn show_group_share_success(
|
||||
lines: [TString<'static>; 4],
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
let paragraphs = Paragraphs::new([
|
||||
Paragraph::new(&theme::TEXT_MONO, lines[0]),
|
||||
Paragraph::new(&theme::TEXT_BOLD, lines[1]),
|
||||
Paragraph::new(&theme::TEXT_MONO, lines[2]),
|
||||
Paragraph::new(&theme::TEXT_BOLD, lines[3]),
|
||||
]);
|
||||
content_in_button_page(
|
||||
"".into(),
|
||||
paragraphs,
|
||||
TR::buttons__continue.into(),
|
||||
None,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
fn show_homescreen(
|
||||
label: TString<'static>,
|
||||
hold: bool,
|
||||
|
@ -1023,26 +1023,6 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||
}
|
||||
|
||||
extern "C" fn new_show_group_share_success(
|
||||
n_args: usize,
|
||||
args: *const Obj,
|
||||
kwargs: *mut Map,
|
||||
) -> Obj {
|
||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||
let lines_iterable: Obj = kwargs.get(Qstr::MP_QSTR_lines)?;
|
||||
let lines: [TString; 4] = util::iter_into_array(lines_iterable)?;
|
||||
|
||||
let obj = LayoutObj::new(IconDialog::new_shares(
|
||||
lines,
|
||||
theme::button_bar(Button::with_text(TR::buttons__continue.into()).map(|msg| {
|
||||
(matches!(msg, ButtonMsg::Clicked)).then(|| CancelConfirmMsg::Confirmed)
|
||||
})),
|
||||
))?;
|
||||
Ok(obj.into())
|
||||
};
|
||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||
}
|
||||
|
||||
extern "C" fn new_show_remaining_shares(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||
let pages_iterable: Obj = kwargs.get(Qstr::MP_QSTR_pages)?;
|
||||
@ -1275,13 +1255,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// """Device recovery homescreen."""
|
||||
Qstr::MP_QSTR_confirm_recovery => obj_fn_kw!(0, new_confirm_recovery).as_obj(),
|
||||
|
||||
/// def show_group_share_success(
|
||||
/// *,
|
||||
/// lines: Iterable[str]
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Shown after successfully finishing a group."""
|
||||
Qstr::MP_QSTR_show_group_share_success => obj_fn_kw!(0, new_show_group_share_success).as_obj(),
|
||||
|
||||
/// def show_remaining_shares(
|
||||
/// *,
|
||||
/// pages: Iterable[tuple[str, str]],
|
||||
|
@ -406,6 +406,18 @@ impl UIFeaturesFirmware for ModelTTFeatures {
|
||||
Ok(layout)
|
||||
}
|
||||
|
||||
fn show_group_share_success(
|
||||
lines: [TString<'static>; 4],
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
let layout = RootComponent::new(IconDialog::new_shares(
|
||||
lines,
|
||||
theme::button_bar(Button::with_text(TR::buttons__continue.into()).map(|msg| {
|
||||
(matches!(msg, ButtonMsg::Clicked)).then(|| CancelConfirmMsg::Confirmed)
|
||||
})),
|
||||
));
|
||||
Ok(layout)
|
||||
}
|
||||
|
||||
fn show_homescreen(
|
||||
label: TString<'static>,
|
||||
hold: bool,
|
||||
|
@ -103,6 +103,10 @@ pub trait UIFeaturesFirmware {
|
||||
items: [TString<'static>; 3],
|
||||
) -> Result<impl LayoutMaybeTrace, Error>;
|
||||
|
||||
fn show_group_share_success(
|
||||
lines: [TString<'static>; 4],
|
||||
) -> Result<impl LayoutMaybeTrace, Error>;
|
||||
|
||||
fn show_homescreen(
|
||||
label: TString<'static>,
|
||||
hold: bool,
|
||||
|
@ -223,14 +223,6 @@ def flow_continue_recovery(
|
||||
"""Device recovery homescreen."""
|
||||
|
||||
|
||||
# rust/src/ui/model_mercury/layout.rs
|
||||
def show_group_share_success(
|
||||
*,
|
||||
lines: Iterable[str]
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Shown after successfully finishing a group."""
|
||||
|
||||
|
||||
# rust/src/ui/model_mercury/layout.rs
|
||||
def flow_get_address(
|
||||
*,
|
||||
@ -515,44 +507,7 @@ def confirm_recovery(
|
||||
info_button: bool, # unused on TR
|
||||
show_instructions: bool,
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Device recovery homescreen."""
|
||||
|
||||
|
||||
# rust/src/ui/model_tr/layout.rs
|
||||
def show_group_share_success(
|
||||
*,
|
||||
lines: Iterable[str],
|
||||
) -> LayoutObj[int]:
|
||||
"""Shown after successfully finishing a group."""
|
||||
|
||||
|
||||
# rust/src/ui/model_tr/layout.rs
|
||||
def show_progress(
|
||||
*,
|
||||
description: str,
|
||||
indeterminate: bool = False,
|
||||
title: str | None = None,
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Show progress loader. Please note that the number of lines reserved on screen for
|
||||
description is determined at construction time. If you want multiline descriptions
|
||||
make sure the initial description has at least that amount of lines."""
|
||||
|
||||
|
||||
# rust/src/ui/model_tr/layout.rs
|
||||
def show_progress_coinjoin(
|
||||
*,
|
||||
title: str,
|
||||
indeterminate: bool = False,
|
||||
time_ms: int = 0,
|
||||
skip_first_paint: bool = False,
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Show progress loader for coinjoin. Returns CANCELLED after a specified time when
|
||||
time_ms timeout is passed."""
|
||||
|
||||
|
||||
# rust/src/ui/model_tr/layout.rs
|
||||
def show_wait_text(message: str, /) -> None:
|
||||
"""Show single-line text in the middle of the screen."""
|
||||
"""Device recovery homescreen."""
|
||||
from trezor import utils
|
||||
from trezorui_api import *
|
||||
|
||||
@ -774,14 +729,6 @@ def confirm_recovery(
|
||||
"""Device recovery homescreen."""
|
||||
|
||||
|
||||
# rust/src/ui/model_tt/layout.rs
|
||||
def show_group_share_success(
|
||||
*,
|
||||
lines: Iterable[str]
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Shown after successfully finishing a group."""
|
||||
|
||||
|
||||
# rust/src/ui/model_tt/layout.rs
|
||||
def show_remaining_shares(
|
||||
*,
|
||||
|
@ -244,6 +244,14 @@ def show_checklist(
|
||||
mark next to them. Limited to 3 items."""
|
||||
|
||||
|
||||
# rust/src/ui/api/firmware_upy.rs
|
||||
def show_group_share_success(
|
||||
*,
|
||||
lines: Iterable[str],
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Shown after successfully finishing a group."""
|
||||
|
||||
|
||||
# rust/src/ui/api/firmware_upy.rs
|
||||
def show_homescreen(
|
||||
*,
|
||||
|
@ -86,7 +86,7 @@ def format_remaining_shares_info(
|
||||
|
||||
async def show_group_share_success(share_index: int, group_index: int) -> None:
|
||||
await raise_if_not_confirmed(
|
||||
trezorui2.show_group_share_success(
|
||||
trezorui_api.show_group_share_success(
|
||||
lines=[
|
||||
TR.recovery__you_have_entered,
|
||||
TR.recovery__share_num_template.format(share_index + 1),
|
||||
|
@ -65,7 +65,7 @@ def show_group_share_success(
|
||||
share_index: int, group_index: int
|
||||
) -> Awaitable[ui.UiResult]:
|
||||
return interact(
|
||||
trezorui2.show_group_share_success(
|
||||
trezorui_api.show_group_share_success(
|
||||
lines=[
|
||||
TR.recovery__you_have_entered,
|
||||
TR.recovery__share_num_template.format(share_index + 1),
|
||||
|
@ -92,7 +92,7 @@ def show_group_share_success(
|
||||
share_index: int, group_index: int
|
||||
) -> Awaitable[ui.UiResult]:
|
||||
return interact(
|
||||
trezorui2.show_group_share_success(
|
||||
trezorui_api.show_group_share_success(
|
||||
lines=[
|
||||
TR.recovery__you_have_entered,
|
||||
TR.recovery__share_num_template.format(share_index + 1),
|
||||
|
Loading…
Reference in New Issue
Block a user