|
|
|
@ -10,6 +10,7 @@ use crate::ui::{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
use super::CancelConfirmMsg;
|
|
|
|
|
use core::cell::Cell;
|
|
|
|
|
|
|
|
|
|
const ICON_HEIGHT: i16 = 70;
|
|
|
|
|
const SCROLLBAR_INSET_TOP: i16 = 5;
|
|
|
|
@ -30,7 +31,7 @@ pub struct FidoConfirm<F: Fn(usize) -> T, T, U> {
|
|
|
|
|
/// Function/closure that will return appropriate page on demand.
|
|
|
|
|
get_account: F,
|
|
|
|
|
scrollbar: ScrollBar,
|
|
|
|
|
fade: bool,
|
|
|
|
|
fade: Cell<bool>,
|
|
|
|
|
controls: U,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -59,14 +60,27 @@ where
|
|
|
|
|
page_swipe.allow_right = scrollbar.has_previous_page();
|
|
|
|
|
page_swipe.allow_left = scrollbar.has_next_page();
|
|
|
|
|
|
|
|
|
|
// NOTE: This is an ugly hotfix for the erroneous behavior of
|
|
|
|
|
// TextLayout used in the account_name Label. In this
|
|
|
|
|
// particular case, TextLayout calculates the wrong height of
|
|
|
|
|
// fitted text that's higher than the TextLayout bound itself.
|
|
|
|
|
//
|
|
|
|
|
// The following two lines should be swapped when the problem with
|
|
|
|
|
// TextLayout is fixed.
|
|
|
|
|
//
|
|
|
|
|
// See also, continuation of this hotfix in the place() function.
|
|
|
|
|
|
|
|
|
|
// let current_account = get_account(scrollbar.active_page);
|
|
|
|
|
let current_account = "".into();
|
|
|
|
|
|
|
|
|
|
Self {
|
|
|
|
|
app_name: Label::centered(app_name, theme::TEXT_DEMIBOLD),
|
|
|
|
|
account_name: Label::centered("".into(), theme::TEXT_DEMIBOLD),
|
|
|
|
|
account_name: Label::centered(current_account, theme::TEXT_DEMIBOLD),
|
|
|
|
|
page_swipe,
|
|
|
|
|
icon: Child::new(Image::new(icon_data)),
|
|
|
|
|
get_account,
|
|
|
|
|
scrollbar,
|
|
|
|
|
fade: false,
|
|
|
|
|
fade: Cell::new(false),
|
|
|
|
|
controls,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -87,11 +101,14 @@ where
|
|
|
|
|
self.page_swipe.allow_right = self.scrollbar.has_previous_page();
|
|
|
|
|
self.page_swipe.allow_left = self.scrollbar.has_next_page();
|
|
|
|
|
|
|
|
|
|
let current_account = (self.get_account)(self.active_page());
|
|
|
|
|
self.account_name.set_text(current_account);
|
|
|
|
|
|
|
|
|
|
// Redraw the page.
|
|
|
|
|
ctx.request_paint();
|
|
|
|
|
|
|
|
|
|
// Reset backlight to normal level on next paint.
|
|
|
|
|
self.fade = true;
|
|
|
|
|
self.fade.set(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn active_page(&self) -> usize {
|
|
|
|
@ -139,6 +156,12 @@ where
|
|
|
|
|
self.app_name.place(app_name_area);
|
|
|
|
|
self.account_name.place(account_name_area);
|
|
|
|
|
|
|
|
|
|
// NOTE: This is a hotfix used due to the erroneous behavior of TextLayout.
|
|
|
|
|
// This line should be removed when the problem with TextLayout is fixed.
|
|
|
|
|
// See also the code for FidoConfirm::new().
|
|
|
|
|
self.account_name
|
|
|
|
|
.set_text((self.get_account)(self.scrollbar.active_page));
|
|
|
|
|
|
|
|
|
|
bounds
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,8 +189,6 @@ where
|
|
|
|
|
self.scrollbar.paint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let current_account = (self.get_account)(self.active_page());
|
|
|
|
|
|
|
|
|
|
// Erasing the old text content before writing the new one.
|
|
|
|
|
let account_name_area = self.account_name.area();
|
|
|
|
|
let real_area = account_name_area
|
|
|
|
@ -177,15 +198,13 @@ where
|
|
|
|
|
// Account name is optional.
|
|
|
|
|
// Showing it only if it differs from app name.
|
|
|
|
|
// (Dummy requests usually have some text as both app_name and account_name.)
|
|
|
|
|
if !current_account.as_ref().is_empty()
|
|
|
|
|
&& current_account.as_ref() != self.app_name.text().as_ref()
|
|
|
|
|
{
|
|
|
|
|
self.account_name.set_text(current_account);
|
|
|
|
|
let account_name = self.account_name.text().as_ref();
|
|
|
|
|
let app_name = self.app_name.text().as_ref();
|
|
|
|
|
if !account_name.is_empty() && account_name != app_name {
|
|
|
|
|
self.account_name.paint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if self.fade {
|
|
|
|
|
self.fade = false;
|
|
|
|
|
if self.fade.take() {
|
|
|
|
|
// Note that this is blocking and takes some time.
|
|
|
|
|
display::fade_backlight(theme::BACKLIGHT_NORMAL);
|
|
|
|
|
}
|
|
|
|
|