mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-27 14:52:10 +00:00
refactor(core/rust): propagate footer button message everywhere
this generally simplifies the mappings of Frame messages, but also relies on the button actions being properly set up.
This commit is contained in:
parent
f0746e44fe
commit
2982f6db37
@ -20,10 +20,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{Footer, Frame, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg},
|
||||||
Footer, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu,
|
|
||||||
VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -314,11 +311,7 @@ fn new_confirm_action_uni<T: Component + PaginateFull + MaybeTrace + 'static>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let content = content
|
let content = content
|
||||||
.map(move |msg| match msg {
|
.map_to_button_msg()
|
||||||
FrameMsg::Button(FlowMsg::Info) => Some(FlowMsg::Info),
|
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.with_pages(move |intro_pages| intro_pages + prompt_pages);
|
.with_pages(move |intro_pages| intro_pages + prompt_pages);
|
||||||
|
|
||||||
let flow = flow?.with_page(page, content)?;
|
let flow = flow?.with_page(page, content)?;
|
||||||
@ -378,11 +371,10 @@ fn create_menu(
|
|||||||
.with_swipe(Direction::Right, SwipeSettings::immediate());
|
.with_swipe(Direction::Right, SwipeSettings::immediate());
|
||||||
|
|
||||||
let content_menu = content_menu.map(move |msg| match msg {
|
let content_menu = content_menu.map(move |msg| match msg {
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => {
|
VerticalMenuChoiceMsg::Selected(i) => {
|
||||||
let selected_item = menu_items[i];
|
let selected_item = menu_items[i];
|
||||||
Some(FlowMsg::Choice(selected_item))
|
Some(FlowMsg::Choice(selected_item))
|
||||||
}
|
}
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if prompt_screen.is_some() {
|
if prompt_screen.is_some() {
|
||||||
@ -429,11 +421,7 @@ fn create_confirm(
|
|||||||
content_confirm = content_confirm.with_subtitle(subtitle);
|
content_confirm = content_confirm.with_subtitle(subtitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
let content_confirm = content_confirm.map(move |msg| match msg {
|
let content_confirm = content_confirm.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
flow.with_page(
|
flow.with_page(
|
||||||
&ConfirmActionWithMenuAndConfirmation::Confirmation,
|
&ConfirmActionWithMenuAndConfirmation::Confirmation,
|
||||||
|
@ -8,7 +8,7 @@ use crate::{
|
|||||||
paginated::PaginateFull as _,
|
paginated::PaginateFull as _,
|
||||||
swipe_detect::SwipeSettings,
|
swipe_detect::SwipeSettings,
|
||||||
text::paragraphs::{Paragraph, Paragraphs},
|
text::paragraphs::{Paragraph, Paragraphs},
|
||||||
ComponentExt, EventCtx,
|
EventCtx,
|
||||||
},
|
},
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
@ -20,8 +20,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{
|
||||||
FidoCredential, Footer, Frame, FrameMsg, PagedVerticalMenu, PromptMsg, PromptScreen,
|
FidoCredential, Footer, Frame, PagedVerticalMenu, PromptScreen, SwipeContent, VerticalMenu,
|
||||||
SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
|
|
||||||
},
|
},
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
@ -122,7 +121,7 @@ pub fn new_confirm_fido(
|
|||||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info));
|
.map_to_button_msg();
|
||||||
|
|
||||||
// Closure to lazy-load the information on given page index.
|
// Closure to lazy-load the information on given page index.
|
||||||
// Done like this to allow arbitrarily many pages without
|
// Done like this to allow arbitrarily many pages without
|
||||||
@ -153,10 +152,7 @@ pub fn new_confirm_fido(
|
|||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.with_vertical_pages()
|
.with_vertical_pages()
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
});
|
|
||||||
|
|
||||||
let get_account = move || {
|
let get_account = move || {
|
||||||
let current = CRED_SELECTED.load(Ordering::Relaxed);
|
let current = CRED_SELECTED.load(Ordering::Relaxed);
|
||||||
@ -175,21 +171,14 @@ pub fn new_confirm_fido(
|
|||||||
} else {
|
} else {
|
||||||
content_details.with_cancel_button()
|
content_details.with_cancel_button()
|
||||||
}
|
}
|
||||||
.map(|msg| match msg {
|
.map_to_button_msg();
|
||||||
FrameMsg::Button(bm) => Some(bm),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_tap = Frame::left_aligned(title, PromptScreen::new_tap_to_confirm())
|
let content_tap = Frame::left_aligned(title, PromptScreen::new_tap_to_confirm())
|
||||||
.with_menu_button()
|
.with_menu_button()
|
||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
"".into(),
|
"".into(),
|
||||||
@ -197,10 +186,7 @@ pub fn new_confirm_fido(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
let initial_page = if single_cred() {
|
let initial_page = if single_cred() {
|
||||||
&ConfirmFido::Details
|
&ConfirmFido::Details
|
||||||
|
@ -6,7 +6,6 @@ use crate::{
|
|||||||
component::{
|
component::{
|
||||||
swipe_detect::SwipeSettings,
|
swipe_detect::SwipeSettings,
|
||||||
text::paragraphs::{Paragraph, Paragraphs},
|
text::paragraphs::{Paragraph, Paragraphs},
|
||||||
ComponentExt,
|
|
||||||
},
|
},
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
@ -17,9 +16,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{Frame, PromptScreen, SwipeContent, VerticalMenu},
|
||||||
Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,7 +73,7 @@ pub fn new_confirm_firmware_update(
|
|||||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(FlowMsg::Info)).then_some(FlowMsg::Info));
|
.map_to_button_msg();
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
TString::empty(),
|
TString::empty(),
|
||||||
@ -89,10 +86,7 @@ pub fn new_confirm_firmware_update(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
let paragraphs_fingerprint =
|
let paragraphs_fingerprint =
|
||||||
Paragraphs::new(Paragraph::new(&theme::TEXT_MONO_GREY_LIGHT, fingerprint));
|
Paragraphs::new(Paragraph::new(&theme::TEXT_MONO_GREY_LIGHT, fingerprint));
|
||||||
@ -102,7 +96,7 @@ pub fn new_confirm_firmware_update(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::default())
|
.with_swipe(Direction::Right, SwipeSettings::default())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(FlowMsg::Cancelled)).then_some(FlowMsg::Cancelled));
|
.map_to_button_msg();
|
||||||
|
|
||||||
let content_confirm = Frame::left_aligned(
|
let content_confirm = Frame::left_aligned(
|
||||||
TR::firmware_update__title.into(),
|
TR::firmware_update__title.into(),
|
||||||
@ -112,11 +106,7 @@ pub fn new_confirm_firmware_update(
|
|||||||
.with_footer(TR::instructions__hold_to_confirm.into(), None)
|
.with_footer(TR::instructions__hold_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = SwipeFlow::new(&ConfirmFirmwareUpdate::Intro)?
|
let res = SwipeFlow::new(&ConfirmFirmwareUpdate::Intro)?
|
||||||
.with_page(&ConfirmFirmwareUpdate::Intro, content_intro)?
|
.with_page(&ConfirmFirmwareUpdate::Intro, content_intro)?
|
||||||
|
@ -13,9 +13,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{Frame, PromptScreen, SwipeContent, VerticalMenu},
|
||||||
Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,12 +66,9 @@ pub fn new_confirm_homescreen(
|
|||||||
Some(TR::buttons__change.into()),
|
Some(TR::buttons__change.into()),
|
||||||
)
|
)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
|
.map_to_button_msg()
|
||||||
// Homescreen + Tap to confirm
|
// Homescreen + Tap to confirm
|
||||||
.with_pages(|_| 2)
|
.with_pages(|_| 2);
|
||||||
.map(|msg| match msg {
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
TString::empty(),
|
TString::empty(),
|
||||||
@ -81,10 +76,7 @@ pub fn new_confirm_homescreen(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_confirm = Frame::left_aligned(
|
let content_confirm = Frame::left_aligned(
|
||||||
TR::homescreen__title_set.into(),
|
TR::homescreen__title_set.into(),
|
||||||
@ -94,11 +86,7 @@ pub fn new_confirm_homescreen(
|
|||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = SwipeFlow::new(&ConfirmHomescreen::Homescreen)?
|
let res = SwipeFlow::new(&ConfirmHomescreen::Homescreen)?
|
||||||
.with_page(&ConfirmHomescreen::Homescreen, content_homescreen)?
|
.with_page(&ConfirmHomescreen::Homescreen, content_homescreen)?
|
||||||
|
@ -212,11 +212,7 @@ fn get_cancel_page(
|
|||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Right, SwipeSettings::default())
|
.with_swipe(Direction::Right, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm)
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
@ -263,11 +259,10 @@ pub fn new_confirm_output(
|
|||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(move |msg| match msg {
|
.map(move |msg| match msg {
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => {
|
VerticalMenuChoiceMsg::Selected(i) => {
|
||||||
let selected_item = main_menu_items[i];
|
let selected_item = main_menu_items[i];
|
||||||
Some(FlowMsg::Choice(selected_item))
|
Some(FlowMsg::Choice(selected_item))
|
||||||
}
|
}
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// AccountInfo
|
// AccountInfo
|
||||||
@ -304,11 +299,7 @@ pub fn new_confirm_output(
|
|||||||
.with_footer(TR::instructions__hold_to_sign.into(), None)
|
.with_footer(TR::instructions__hold_to_sign.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
// FeeInfo
|
// FeeInfo
|
||||||
let has_fee_info = !fee_items_params.is_empty();
|
let has_fee_info = !fee_items_params.is_empty();
|
||||||
@ -337,11 +328,10 @@ pub fn new_confirm_output(
|
|||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(move |msg| match msg {
|
.map(move |msg| match msg {
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => {
|
VerticalMenuChoiceMsg::Selected(i) => {
|
||||||
let selected_item = summary_menu_items[i];
|
let selected_item = summary_menu_items[i];
|
||||||
Some(FlowMsg::Choice(selected_item))
|
Some(FlowMsg::Choice(selected_item))
|
||||||
}
|
}
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// HoldMenu
|
// HoldMenu
|
||||||
@ -352,12 +342,7 @@ pub fn new_confirm_output(
|
|||||||
let content_hold_menu = Frame::left_aligned(TString::empty(), hold_menu)
|
let content_hold_menu = Frame::left_aligned(TString::empty(), hold_menu)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(move |msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(_)) => {
|
|
||||||
Some(FlowMsg::Choice(MENU_ITEM_CANCEL))
|
|
||||||
}
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut flow = SwipeFlow::new(&ConfirmOutputWithSummary::Main)?
|
let mut flow = SwipeFlow::new(&ConfirmOutputWithSummary::Main)?
|
||||||
.with_page(&ConfirmOutputWithSummary::Main, main_content)?
|
.with_page(&ConfirmOutputWithSummary::Main, main_content)?
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
component::{
|
component::{
|
||||||
swipe_detect::SwipeSettings,
|
swipe_detect::SwipeSettings,
|
||||||
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort},
|
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort},
|
||||||
ButtonRequestExt, ComponentExt,
|
ButtonRequestExt,
|
||||||
},
|
},
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
@ -18,9 +18,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{Frame, PromptScreen, SwipeContent, VerticalMenu},
|
||||||
Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,7 +116,7 @@ pub fn new_confirm_reset(recovery: bool) -> Result<SwipeFlow, error::Error> {
|
|||||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info))
|
.map_to_button_msg()
|
||||||
.one_button_request(br);
|
.one_button_request(br);
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
@ -127,10 +125,7 @@ pub fn new_confirm_reset(recovery: bool) -> Result<SwipeFlow, error::Error> {
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = if recovery {
|
let res = if recovery {
|
||||||
SwipeFlow::new(&ConfirmResetRecover::Intro)?
|
SwipeFlow::new(&ConfirmResetRecover::Intro)?
|
||||||
@ -145,11 +140,7 @@ pub fn new_confirm_reset(recovery: bool) -> Result<SwipeFlow, error::Error> {
|
|||||||
.with_footer(TR::instructions__hold_to_confirm.into(), None)
|
.with_footer(TR::instructions__hold_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm)
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.one_button_request(ButtonRequestCode::ResetDevice.with_name("confirm_setup_device"));
|
.one_button_request(ButtonRequestCode::ResetDevice.with_name("confirm_setup_device"));
|
||||||
|
|
||||||
SwipeFlow::new(&ConfirmResetCreate::Intro)?
|
SwipeFlow::new(&ConfirmResetCreate::Intro)?
|
||||||
|
@ -6,7 +6,6 @@ use crate::{
|
|||||||
component::{
|
component::{
|
||||||
swipe_detect::SwipeSettings,
|
swipe_detect::SwipeSettings,
|
||||||
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs},
|
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs},
|
||||||
ComponentExt,
|
|
||||||
},
|
},
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
@ -17,9 +16,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{Frame, PromptScreen, SwipeContent, VerticalMenu},
|
||||||
Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,10 +71,7 @@ pub fn new_set_new_pin(
|
|||||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map_to_button_msg();
|
||||||
FrameMsg::Button(bm) => Some(bm),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
"".into(),
|
"".into(),
|
||||||
@ -85,11 +79,7 @@ pub fn new_set_new_pin(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
FrameMsg::Button(_) => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let paragraphs_cancel_intro = ParagraphVecShort::from_iter([
|
let paragraphs_cancel_intro = ParagraphVecShort::from_iter([
|
||||||
Paragraph::new(&theme::TEXT_WARNING, TR::words__not_recommended),
|
Paragraph::new(&theme::TEXT_WARNING, TR::words__not_recommended),
|
||||||
@ -107,10 +97,7 @@ pub fn new_set_new_pin(
|
|||||||
)
|
)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map_to_button_msg();
|
||||||
FrameMsg::Button(bm) => Some(bm),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_cancel_confirm = Frame::left_aligned(
|
let content_cancel_confirm = Frame::left_aligned(
|
||||||
TR::pin__cancel_setup.into(),
|
TR::pin__cancel_setup.into(),
|
||||||
@ -120,11 +107,7 @@ pub fn new_set_new_pin(
|
|||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = SwipeFlow::new(&SetNewPin::Intro)?
|
let res = SwipeFlow::new(&SetNewPin::Intro)?
|
||||||
.with_page(&SetNewPin::Intro, content_intro)?
|
.with_page(&SetNewPin::Intro, content_intro)?
|
||||||
|
@ -17,10 +17,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
super::{
|
super::{
|
||||||
component::{
|
component::{Frame, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg},
|
||||||
Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu,
|
|
||||||
VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
},
|
},
|
||||||
util::ShowInfoParams,
|
util::ShowInfoParams,
|
||||||
@ -100,11 +97,7 @@ pub fn new_confirm_summary(
|
|||||||
.with_footer(TR::instructions__hold_to_sign.into(), None)
|
.with_footer(TR::instructions__hold_to_sign.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
// ExtraInfo
|
// ExtraInfo
|
||||||
let content_extra = extra_params
|
let content_extra = extra_params
|
||||||
@ -141,11 +134,10 @@ pub fn new_confirm_summary(
|
|||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(move |msg| match msg {
|
.map(move |msg| match msg {
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => {
|
VerticalMenuChoiceMsg::Selected(i) => {
|
||||||
let selected_item = menu_items[i];
|
let selected_item = menu_items[i];
|
||||||
Some(FlowMsg::Choice(selected_item))
|
Some(FlowMsg::Choice(selected_item))
|
||||||
}
|
}
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// CancelTap
|
// CancelTap
|
||||||
@ -156,11 +148,7 @@ pub fn new_confirm_summary(
|
|||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut res = SwipeFlow::new(&ConfirmSummary::Summary)?
|
let mut res = SwipeFlow::new(&ConfirmSummary::Summary)?
|
||||||
.with_page(&ConfirmSummary::Summary, content_summary)?
|
.with_page(&ConfirmSummary::Summary, content_summary)?
|
||||||
|
@ -22,10 +22,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{Footer, Frame, PromptScreen, SwipeContent, VerticalMenu},
|
||||||
Footer, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu,
|
|
||||||
VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -198,7 +195,7 @@ pub fn new_continue_recovery_homepage(
|
|||||||
.with_footer(footer_instruction, footer_description)
|
.with_footer(footer_instruction, footer_description)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info))
|
.map_to_button_msg()
|
||||||
.repeated_button_request(ButtonRequest::new(
|
.repeated_button_request(ButtonRequest::new(
|
||||||
ButtonRequestCode::RecoveryHomepage,
|
ButtonRequestCode::RecoveryHomepage,
|
||||||
"recovery".into(),
|
"recovery".into(),
|
||||||
@ -219,10 +216,7 @@ pub fn new_continue_recovery_homepage(
|
|||||||
)
|
)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map_to_button_msg()
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.repeated_button_request(ButtonRequest::new(
|
.repeated_button_request(ButtonRequest::new(
|
||||||
ButtonRequestCode::ProtectCall,
|
ButtonRequestCode::ProtectCall,
|
||||||
"abort_recovery".into(),
|
"abort_recovery".into(),
|
||||||
@ -236,11 +230,7 @@ pub fn new_continue_recovery_homepage(
|
|||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = if show_instructions {
|
let res = if show_instructions {
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
@ -249,10 +239,7 @@ pub fn new_continue_recovery_homepage(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
SwipeFlow::new(&ContinueRecoveryBeforeShares::Main)?
|
SwipeFlow::new(&ContinueRecoveryBeforeShares::Main)?
|
||||||
.with_page(&ContinueRecoveryBeforeShares::Main, content_main)?
|
.with_page(&ContinueRecoveryBeforeShares::Main, content_main)?
|
||||||
@ -264,10 +251,7 @@ pub fn new_continue_recovery_homepage(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
SwipeFlow::new(&ContinueRecoveryBetweenShares::Main)?
|
SwipeFlow::new(&ContinueRecoveryBetweenShares::Main)?
|
||||||
.with_page(&ContinueRecoveryBetweenShares::Main, content_main)?
|
.with_page(&ContinueRecoveryBetweenShares::Main, content_main)?
|
||||||
@ -292,10 +276,7 @@ pub fn new_continue_recovery_homepage(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
let (footer_instruction, footer_description) = (
|
let (footer_instruction, footer_description) = (
|
||||||
TR::instructions__swipe_up.into(),
|
TR::instructions__swipe_up.into(),
|
||||||
@ -317,7 +298,7 @@ pub fn new_continue_recovery_homepage(
|
|||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.with_vertical_pages()
|
.with_vertical_pages()
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled))
|
.map_to_button_msg()
|
||||||
.repeated_button_request(ButtonRequest::new(
|
.repeated_button_request(ButtonRequest::new(
|
||||||
ButtonRequestCode::Other,
|
ButtonRequestCode::Other,
|
||||||
"show_shares".into(),
|
"show_shares".into(),
|
||||||
|
@ -20,10 +20,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{AddressDetails, Frame, PromptScreen, StatusScreen, SwipeContent, VerticalMenu},
|
||||||
AddressDetails, Frame, FrameMsg, PromptMsg, PromptScreen, StatusScreen, SwipeContent,
|
|
||||||
VerticalMenu, VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,7 +119,7 @@ pub fn new_get_address(
|
|||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.with_vertical_pages()
|
.with_vertical_pages()
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info))
|
.map_to_button_msg()
|
||||||
.one_button_request(ButtonRequest::from_num(br_code, br_name))
|
.one_button_request(ButtonRequest::from_num(br_code, br_name))
|
||||||
// Count tap-to-confirm screen towards page count
|
// Count tap-to-confirm screen towards page count
|
||||||
.with_pages(|address_pages| address_pages + 1);
|
.with_pages(|address_pages| address_pages + 1);
|
||||||
@ -133,11 +130,7 @@ pub fn new_get_address(
|
|||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_confirmed = Frame::left_aligned(
|
let content_confirmed = Frame::left_aligned(
|
||||||
TR::words__title_success.into(),
|
TR::words__title_success.into(),
|
||||||
@ -160,10 +153,7 @@ pub fn new_get_address(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
// QrCode
|
// QrCode
|
||||||
let content_qr = Frame::left_aligned(
|
let content_qr = Frame::left_aligned(
|
||||||
@ -174,7 +164,7 @@ pub fn new_get_address(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled));
|
.map_to_button_msg();
|
||||||
|
|
||||||
// AccountInfo
|
// AccountInfo
|
||||||
let mut ad = AddressDetails::new(TR::address_details__account_info.into(), account, path)?;
|
let mut ad = AddressDetails::new(TR::address_details__account_info.into(), account, path)?;
|
||||||
@ -196,7 +186,7 @@ pub fn new_get_address(
|
|||||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled));
|
.map_to_button_msg();
|
||||||
|
|
||||||
// CancelTap
|
// CancelTap
|
||||||
let content_cancel_tap = Frame::left_aligned(
|
let content_cancel_tap = Frame::left_aligned(
|
||||||
@ -207,11 +197,7 @@ pub fn new_get_address(
|
|||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = SwipeFlow::new(&GetAddress::Address)?
|
let res = SwipeFlow::new(&GetAddress::Address)?
|
||||||
.with_page(&GetAddress::Address, content_address)?
|
.with_page(&GetAddress::Address, content_address)?
|
||||||
|
@ -6,7 +6,6 @@ use crate::{
|
|||||||
component::{
|
component::{
|
||||||
swipe_detect::SwipeSettings,
|
swipe_detect::SwipeSettings,
|
||||||
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs},
|
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs},
|
||||||
ComponentExt,
|
|
||||||
},
|
},
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
@ -17,9 +16,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{Frame, PromptScreen, SwipeContent, VerticalMenu},
|
||||||
Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,10 +70,7 @@ pub fn new_prompt_backup() -> Result<SwipeFlow, error::Error> {
|
|||||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map_to_button_msg();
|
||||||
FrameMsg::Button(bm) => Some(bm),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
"".into(),
|
"".into(),
|
||||||
@ -84,11 +78,7 @@ pub fn new_prompt_backup() -> Result<SwipeFlow, error::Error> {
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
FrameMsg::Button(_) => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let paragraphs_skip_intro = ParagraphVecShort::from_iter([
|
let paragraphs_skip_intro = ParagraphVecShort::from_iter([
|
||||||
Paragraph::new(&theme::TEXT_WARNING, TR::words__not_recommended),
|
Paragraph::new(&theme::TEXT_WARNING, TR::words__not_recommended),
|
||||||
@ -109,10 +99,7 @@ pub fn new_prompt_backup() -> Result<SwipeFlow, error::Error> {
|
|||||||
)
|
)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map_to_button_msg();
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_skip_confirm = Frame::left_aligned(
|
let content_skip_confirm = Frame::left_aligned(
|
||||||
TR::backup__title_skip.into(),
|
TR::backup__title_skip.into(),
|
||||||
@ -122,11 +109,7 @@ pub fn new_prompt_backup() -> Result<SwipeFlow, error::Error> {
|
|||||||
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
.with_footer(TR::instructions__tap_to_confirm.into(), None)
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_confirm);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = SwipeFlow::new(&PromptBackup::Intro)?
|
let res = SwipeFlow::new(&PromptBackup::Intro)?
|
||||||
.with_page(&PromptBackup::Intro, content_intro)?
|
.with_page(&PromptBackup::Intro, content_intro)?
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
strutil::TString,
|
strutil::TString,
|
||||||
translations::TR,
|
translations::TR,
|
||||||
ui::{
|
ui::{
|
||||||
component::{swipe_detect::SwipeSettings, ComponentExt},
|
component::swipe_detect::SwipeSettings,
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
FlowController, FlowMsg, SwipeFlow,
|
FlowController, FlowMsg, SwipeFlow,
|
||||||
@ -16,8 +16,8 @@ use core::sync::atomic::{AtomicU16, Ordering};
|
|||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{
|
||||||
Frame, FrameMsg, NumberInputDialog, NumberInputDialogMsg, SwipeContent, UpdatableMoreInfo,
|
Frame, NumberInputDialog, NumberInputDialogMsg, SwipeContent, UpdatableMoreInfo,
|
||||||
VerticalMenu, VerticalMenuChoiceMsg,
|
VerticalMenu,
|
||||||
},
|
},
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
@ -82,12 +82,11 @@ pub fn new_request_number(
|
|||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(|msg| match msg {
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
NumberInputDialogMsg::Changed(n) => {
|
||||||
FrameMsg::Content(NumberInputDialogMsg::Changed(n)) => {
|
|
||||||
NUM_DISPLAYED.store(n as u16, Ordering::Relaxed);
|
NUM_DISPLAYED.store(n as u16, Ordering::Relaxed);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
FrameMsg::Content(NumberInputDialogMsg::Confirmed(n)) => {
|
NumberInputDialogMsg::Confirmed(n) => {
|
||||||
NUM_DISPLAYED.store(n as u16, Ordering::Relaxed);
|
NUM_DISPLAYED.store(n as u16, Ordering::Relaxed);
|
||||||
Some(FlowMsg::Choice(n as usize))
|
Some(FlowMsg::Choice(n as usize))
|
||||||
}
|
}
|
||||||
@ -99,20 +98,13 @@ pub fn new_request_number(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
FrameMsg::Button(_) => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let updatable_info = UpdatableMoreInfo::new(info_closure);
|
let updatable_info = UpdatableMoreInfo::new(info_closure);
|
||||||
let content_info = Frame::left_aligned(TString::empty(), SwipeContent::new(updatable_info))
|
let content_info = Frame::left_aligned(TString::empty(), SwipeContent::new(updatable_info))
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map_to_button_msg();
|
||||||
FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = SwipeFlow::new(&RequestNumber::Number)?
|
let res = SwipeFlow::new(&RequestNumber::Number)?
|
||||||
.with_page(&RequestNumber::Number, content_number_input)?
|
.with_page(&RequestNumber::Number, content_number_input)?
|
||||||
|
@ -12,9 +12,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::super::component::{
|
use super::super::component::{Frame, PassphraseKeyboard, PassphraseKeyboardMsg, PromptScreen};
|
||||||
Frame, FrameMsg, PassphraseKeyboard, PassphraseKeyboardMsg, PromptMsg, PromptScreen,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum RequestPassphrase {
|
pub enum RequestPassphrase {
|
||||||
@ -56,11 +54,7 @@ pub fn new_request_passphrase() -> Result<SwipeFlow, error::Error> {
|
|||||||
TR::passphrase__continue_with_empty_passphrase.into(),
|
TR::passphrase__continue_with_empty_passphrase.into(),
|
||||||
PromptScreen::new_yes_or_no(),
|
PromptScreen::new_yes_or_no(),
|
||||||
)
|
)
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_prompt);
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
|
|
||||||
FrameMsg::Content(PromptMsg::Cancelled) => Some(FlowMsg::Cancelled),
|
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_keypad = PassphraseKeyboard::new().map(|msg| match msg {
|
let content_keypad = PassphraseKeyboard::new().map(|msg| match msg {
|
||||||
PassphraseKeyboardMsg::Confirmed(s) => Some(FlowMsg::Text(s)),
|
PassphraseKeyboardMsg::Confirmed(s) => Some(FlowMsg::Text(s)),
|
||||||
|
@ -6,7 +6,7 @@ use crate::{
|
|||||||
translations::TR,
|
translations::TR,
|
||||||
trezorhal::display,
|
trezorhal::display,
|
||||||
ui::{
|
ui::{
|
||||||
component::{base::ComponentExt, swipe_detect::SwipeSettings, FlowMsg},
|
component::{swipe_detect::SwipeSettings, FlowMsg},
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
FlowController, SwipeFlow,
|
FlowController, SwipeFlow,
|
||||||
@ -18,8 +18,7 @@ use crate::{
|
|||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{
|
||||||
number_input_slider::{NumberInputSliderDialog, NumberInputSliderDialogMsg},
|
number_input_slider::{NumberInputSliderDialog, NumberInputSliderDialogMsg},
|
||||||
Frame, FrameMsg, PromptMsg, PromptScreen, StatusScreen, SwipeContent, VerticalMenu,
|
Frame, PromptMsg, PromptScreen, StatusScreen, SwipeContent, VerticalMenu,
|
||||||
VerticalMenuChoiceMsg,
|
|
||||||
},
|
},
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
@ -78,12 +77,11 @@ pub fn new_set_brightness(brightness: Option<u8>) -> Result<SwipeFlow, Error> {
|
|||||||
.with_menu_button()
|
.with_menu_button()
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.map(|msg| match msg {
|
.map(|msg| match msg {
|
||||||
FrameMsg::Content(NumberInputSliderDialogMsg::Changed(n)) => {
|
NumberInputSliderDialogMsg::Changed(n) => {
|
||||||
display::backlight(n as _);
|
display::backlight(n as _);
|
||||||
BRIGHTNESS.store(n as u8, Ordering::Relaxed);
|
BRIGHTNESS.store(n as u8, Ordering::Relaxed);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
@ -92,10 +90,7 @@ pub fn new_set_brightness(brightness: Option<u8>) -> Result<SwipeFlow, Error> {
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(move |msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_confirm = Frame::left_aligned(
|
let content_confirm = Frame::left_aligned(
|
||||||
TR::brightness__change_title.into(),
|
TR::brightness__change_title.into(),
|
||||||
@ -106,11 +101,10 @@ pub fn new_set_brightness(brightness: Option<u8>) -> Result<SwipeFlow, Error> {
|
|||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(move |msg| match msg {
|
.map(move |msg| match msg {
|
||||||
FrameMsg::Content(PromptMsg::Confirmed) => {
|
PromptMsg::Confirmed => {
|
||||||
let _ = storage::set_brightness(BRIGHTNESS.load(Ordering::Relaxed));
|
let _ = storage::set_brightness(BRIGHTNESS.load(Ordering::Relaxed));
|
||||||
Some(FlowMsg::Confirmed)
|
Some(FlowMsg::Confirmed)
|
||||||
}
|
}
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ use crate::{
|
|||||||
component::{
|
component::{
|
||||||
swipe_detect::SwipeSettings,
|
swipe_detect::SwipeSettings,
|
||||||
text::paragraphs::{Paragraph, ParagraphSource},
|
text::paragraphs::{Paragraph, ParagraphSource},
|
||||||
ComponentExt,
|
|
||||||
},
|
},
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
@ -17,7 +16,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{Frame, FrameMsg, StatusScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg},
|
component::{Frame, StatusScreen, SwipeContent, VerticalMenu},
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ pub fn new_show_danger(
|
|||||||
.with_danger()
|
.with_danger()
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info));
|
.map_to_button_msg();
|
||||||
// .one_button_request(ButtonRequestCode::Warning, br_name);
|
// .one_button_request(ButtonRequestCode::Warning, br_name);
|
||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
@ -92,10 +91,7 @@ pub fn new_show_danger(
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Cancelled
|
// Cancelled
|
||||||
let content_cancelled = Frame::left_aligned(
|
let content_cancelled = Frame::left_aligned(
|
||||||
|
@ -20,8 +20,7 @@ use heapless::Vec;
|
|||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{
|
||||||
Footer, Frame, FrameMsg, Header, InternallySwipableContent, PromptScreen, ShareWords,
|
Footer, Frame, Header, InternallySwipableContent, PromptScreen, ShareWords, SwipeContent,
|
||||||
SwipeContent,
|
|
||||||
},
|
},
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
@ -99,7 +98,7 @@ pub fn new_show_share_words(
|
|||||||
.with_subtitle(TR::words__instructions.into())
|
.with_subtitle(TR::words__instructions.into())
|
||||||
.with_footer(TR::instructions__swipe_up.into(), text_footer)
|
.with_footer(TR::instructions__swipe_up.into(), text_footer)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Content(_)).then_some(FlowMsg::Confirmed))
|
.map_to_button_msg()
|
||||||
.one_button_request(ButtonRequestCode::ResetDevice.with_name("share_words"))
|
.one_button_request(ButtonRequestCode::ResetDevice.with_name("share_words"))
|
||||||
.with_pages(move |_| nwords + 2);
|
.with_pages(move |_| nwords + 2);
|
||||||
|
|
||||||
@ -114,7 +113,7 @@ pub fn new_show_share_words(
|
|||||||
.register_header_update_fn(header_updating_func)
|
.register_header_update_fn(header_updating_func)
|
||||||
.with_footer_counter(TR::instructions__swipe_up.into())
|
.with_footer_counter(TR::instructions__swipe_up.into())
|
||||||
.register_footer_update_fn(footer_updating_func)
|
.register_footer_update_fn(footer_updating_func)
|
||||||
.map(|_| None);
|
.map_to_button_msg();
|
||||||
|
|
||||||
let content_confirm = Frame::left_aligned(
|
let content_confirm = Frame::left_aligned(
|
||||||
text_confirm,
|
text_confirm,
|
||||||
|
@ -5,7 +5,6 @@ use crate::{
|
|||||||
component::{
|
component::{
|
||||||
swipe_detect::SwipeSettings,
|
swipe_detect::SwipeSettings,
|
||||||
text::paragraphs::{Paragraph, Paragraphs},
|
text::paragraphs::{Paragraph, Paragraphs},
|
||||||
ComponentExt,
|
|
||||||
},
|
},
|
||||||
flow::{
|
flow::{
|
||||||
base::{Decision, DecisionBuilder as _},
|
base::{Decision, DecisionBuilder as _},
|
||||||
@ -16,9 +15,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
component::{
|
component::{Frame, PromptScreen, SwipeContent, VerticalMenu},
|
||||||
Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
|
|
||||||
},
|
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,9 +76,7 @@ pub fn new_show_tutorial() -> Result<SwipeFlow, error::Error> {
|
|||||||
SwipeContent::new(PromptScreen::new_tap_to_start()),
|
SwipeContent::new(PromptScreen::new_tap_to_start()),
|
||||||
)
|
)
|
||||||
.with_footer(TR::instructions__tap_to_start.into(), None)
|
.with_footer(TR::instructions__tap_to_start.into(), None)
|
||||||
.map(|msg| {
|
.map(super::util::map_to_confirm);
|
||||||
matches!(msg, FrameMsg::Content(PromptMsg::Confirmed)).then_some(FlowMsg::Confirmed)
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_step_begin = Frame::left_aligned(
|
let content_step_begin = Frame::left_aligned(
|
||||||
TR::tutorial__title_lets_begin.into(),
|
TR::tutorial__title_lets_begin.into(),
|
||||||
@ -95,7 +90,7 @@ pub fn new_show_tutorial() -> Result<SwipeFlow, error::Error> {
|
|||||||
Some(TR::tutorial__get_started.into()),
|
Some(TR::tutorial__get_started.into()),
|
||||||
)
|
)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.map(|_| None);
|
.map_to_button_msg();
|
||||||
|
|
||||||
let content_step_navigation = Frame::left_aligned(
|
let content_step_navigation = Frame::left_aligned(
|
||||||
TR::tutorial__title_easy_navigation.into(),
|
TR::tutorial__title_easy_navigation.into(),
|
||||||
@ -110,7 +105,7 @@ pub fn new_show_tutorial() -> Result<SwipeFlow, error::Error> {
|
|||||||
)
|
)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.map(|_| None);
|
.map_to_button_msg();
|
||||||
|
|
||||||
let content_step_menu = Frame::left_aligned(
|
let content_step_menu = Frame::left_aligned(
|
||||||
TR::tutorial__title_handy_menu.into(),
|
TR::tutorial__title_handy_menu.into(),
|
||||||
@ -127,16 +122,14 @@ pub fn new_show_tutorial() -> Result<SwipeFlow, error::Error> {
|
|||||||
)
|
)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Down, SwipeSettings::default())
|
.with_swipe(Direction::Down, SwipeSettings::default())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info));
|
.map_to_button_msg();
|
||||||
|
|
||||||
let content_step_hold = Frame::left_aligned(
|
let content_step_hold = Frame::left_aligned(
|
||||||
TR::tutorial__title_hold.into(),
|
TR::tutorial__title_hold.into(),
|
||||||
SwipeContent::new(PromptScreen::new_hold_to_confirm()),
|
SwipeContent::new(PromptScreen::new_hold_to_confirm()),
|
||||||
)
|
)
|
||||||
.with_footer(TR::instructions__hold_to_exit_tutorial.into(), None)
|
.with_footer(TR::instructions__hold_to_exit_tutorial.into(), None)
|
||||||
.map(|msg| {
|
.map(super::util::map_to_confirm);
|
||||||
matches!(msg, FrameMsg::Content(PromptMsg::Confirmed)).then_some(FlowMsg::Confirmed)
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_step_done = Frame::left_aligned(
|
let content_step_done = Frame::left_aligned(
|
||||||
TR::tutorial__title_well_done.into(),
|
TR::tutorial__title_well_done.into(),
|
||||||
@ -147,7 +140,7 @@ pub fn new_show_tutorial() -> Result<SwipeFlow, error::Error> {
|
|||||||
)
|
)
|
||||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.map(|_| None);
|
.map_to_button_msg();
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
"".into(),
|
"".into(),
|
||||||
@ -159,10 +152,7 @@ pub fn new_show_tutorial() -> Result<SwipeFlow, error::Error> {
|
|||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::immediate())
|
.with_swipe(Direction::Left, SwipeSettings::immediate())
|
||||||
.map(|msg| match msg {
|
.map(super::util::map_to_choice);
|
||||||
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
|
||||||
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_did_you_know = Frame::left_aligned(
|
let content_did_you_know = Frame::left_aligned(
|
||||||
"".into(),
|
"".into(),
|
||||||
@ -173,16 +163,14 @@ pub fn new_show_tutorial() -> Result<SwipeFlow, error::Error> {
|
|||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
.with_swipe(Direction::Right, SwipeSettings::immediate())
|
||||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled));
|
.map_to_button_msg();
|
||||||
|
|
||||||
let content_hold_to_exit = Frame::left_aligned(
|
let content_hold_to_exit = Frame::left_aligned(
|
||||||
TR::tutorial__title_hold.into(),
|
TR::tutorial__title_hold.into(),
|
||||||
SwipeContent::new(PromptScreen::new_hold_to_confirm_danger()),
|
SwipeContent::new(PromptScreen::new_hold_to_confirm_danger()),
|
||||||
)
|
)
|
||||||
.with_footer(TR::instructions__hold_to_exit_tutorial.into(), None)
|
.with_footer(TR::instructions__hold_to_exit_tutorial.into(), None)
|
||||||
.map(|msg| {
|
.map(super::util::map_to_confirm);
|
||||||
matches!(msg, FrameMsg::Content(PromptMsg::Confirmed)).then_some(FlowMsg::Confirmed)
|
|
||||||
});
|
|
||||||
|
|
||||||
let res = SwipeFlow::new(&ShowTutorial::StepWelcome)?
|
let res = SwipeFlow::new(&ShowTutorial::StepWelcome)?
|
||||||
.with_page(&ShowTutorial::StepWelcome, content_step_welcome)?
|
.with_page(&ShowTutorial::StepWelcome, content_step_welcome)?
|
||||||
|
@ -6,13 +6,12 @@ use crate::{
|
|||||||
translations::TR,
|
translations::TR,
|
||||||
ui::{
|
ui::{
|
||||||
component::{
|
component::{
|
||||||
base::ComponentExt,
|
|
||||||
swipe_detect::SwipeSettings,
|
swipe_detect::SwipeSettings,
|
||||||
text::{
|
text::{
|
||||||
paragraphs::{Paragraph, ParagraphSource, ParagraphVecLong, VecExt},
|
paragraphs::{Paragraph, ParagraphSource, ParagraphVecLong, VecExt},
|
||||||
TextStyle,
|
TextStyle,
|
||||||
},
|
},
|
||||||
Component,
|
Component, MsgMap, PaginateFull,
|
||||||
},
|
},
|
||||||
flow::{FlowMsg, Swipable, SwipeFlow, SwipePage},
|
flow::{FlowMsg, Swipable, SwipeFlow, SwipePage},
|
||||||
geometry::Direction,
|
geometry::Direction,
|
||||||
@ -23,7 +22,7 @@ use heapless::Vec;
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
super::{
|
super::{
|
||||||
component::{Frame, FrameMsg, SwipeContent},
|
component::{Frame, FrameMsg, PromptMsg, SwipeContent, VerticalMenuChoiceMsg},
|
||||||
flow, theme,
|
flow, theme,
|
||||||
},
|
},
|
||||||
ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionStrings,
|
ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionStrings,
|
||||||
@ -253,7 +252,7 @@ impl ConfirmValue {
|
|||||||
|
|
||||||
frame = frame.with_vertical_pages();
|
frame = frame.with_vertical_pages();
|
||||||
|
|
||||||
Ok(frame.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)))
|
Ok(frame.map_to_button_msg())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_flow(self) -> Result<SwipeFlow, Error> {
|
pub fn into_flow(self) -> Result<SwipeFlow, Error> {
|
||||||
@ -442,12 +441,26 @@ impl ShowInfoParams {
|
|||||||
|
|
||||||
frame = frame.with_vertical_pages();
|
frame = frame.with_vertical_pages();
|
||||||
|
|
||||||
Ok(frame.map(move |msg| {
|
Ok(frame.map_to_button_msg())
|
||||||
matches!(msg, FrameMsg::Button(_)).then_some(if self.cancel_button {
|
}
|
||||||
FlowMsg::Cancelled
|
}
|
||||||
} else {
|
|
||||||
FlowMsg::Info
|
pub fn map_to_confirm(msg: PromptMsg) -> Option<FlowMsg> {
|
||||||
})
|
match msg {
|
||||||
}))
|
PromptMsg::Confirmed => Some(FlowMsg::Confirmed),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn map_to_prompt(msg: PromptMsg) -> Option<FlowMsg> {
|
||||||
|
match msg {
|
||||||
|
PromptMsg::Confirmed => Some(FlowMsg::Confirmed),
|
||||||
|
PromptMsg::Cancelled => Some(FlowMsg::Cancelled),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn map_to_choice(msg: VerticalMenuChoiceMsg) -> Option<FlowMsg> {
|
||||||
|
match msg {
|
||||||
|
VerticalMenuChoiceMsg::Selected(i) => Some(FlowMsg::Choice(i)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user