mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-21 09:39:02 +00:00
feat(eckhart): use gradients in ActionBar
This commit is contained in:
parent
ee7b021244
commit
773eba2216
@ -350,7 +350,7 @@ impl Button {
|
||||
.render(target);
|
||||
}
|
||||
// Gradient bar is rendered only in `normal` state, not `active` or `disabled`
|
||||
(None, true) if self.state == State::Initial || self.state == State::Released => {
|
||||
(None, true) if self.state.is_normal() => {
|
||||
self.render_gradient_bar(target, style);
|
||||
}
|
||||
_ => {
|
||||
@ -609,6 +609,14 @@ enum State {
|
||||
Disabled,
|
||||
}
|
||||
|
||||
impl State {
|
||||
/// Returns true if the button is in a normal state (not pressed or
|
||||
/// disabled).
|
||||
fn is_normal(&self) -> bool {
|
||||
matches!(self, State::Initial | State::Released)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
pub enum ButtonContent {
|
||||
Empty,
|
||||
|
@ -71,12 +71,13 @@ impl ActionBar {
|
||||
/// component automatically shows navigation up/down buttons for
|
||||
/// paginated content.
|
||||
pub fn new_single(button: Button) -> Self {
|
||||
Self::new(
|
||||
Mode::Single,
|
||||
None,
|
||||
Some(button.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)),
|
||||
None,
|
||||
)
|
||||
let mut right_button = button
|
||||
.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)
|
||||
.with_gradient();
|
||||
if right_button.stylesheet() == &theme::button_default() {
|
||||
right_button = right_button.styled(theme::firmware::button_default_actionbar_right());
|
||||
};
|
||||
Self::new(Mode::Single, None, Some(right_button), None)
|
||||
}
|
||||
|
||||
/// Create action bar with single button confirming the layout
|
||||
@ -93,17 +94,21 @@ impl ActionBar {
|
||||
/// automatically shows navigation up/down buttons for paginated
|
||||
/// content.
|
||||
pub fn new_double(left: Button, right: Button) -> Self {
|
||||
let left_button = left
|
||||
.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)
|
||||
.with_content_offset(Self::BUTTON_CONTENT_OFFSET);
|
||||
let mut right_button = right
|
||||
.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)
|
||||
.with_content_offset(Self::BUTTON_CONTENT_OFFSET.neg())
|
||||
.with_gradient();
|
||||
if right_button.stylesheet() == &theme::button_default() {
|
||||
right_button = right_button.styled(theme::firmware::button_default_actionbar_right());
|
||||
};
|
||||
|
||||
Self::new(
|
||||
Mode::Double { left_short: true },
|
||||
Some(
|
||||
left.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)
|
||||
.with_content_offset(Self::BUTTON_CONTENT_OFFSET),
|
||||
),
|
||||
Some(
|
||||
right
|
||||
.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)
|
||||
.with_content_offset(Self::BUTTON_CONTENT_OFFSET.neg()),
|
||||
),
|
||||
Some(left_button),
|
||||
Some(right_button),
|
||||
None,
|
||||
)
|
||||
}
|
||||
@ -112,7 +117,6 @@ impl ActionBar {
|
||||
Self::new_double(
|
||||
Button::with_icon(theme::ICON_CROSS),
|
||||
Button::with_text(TR::buttons__confirm.into())
|
||||
.with_gradient()
|
||||
.styled(theme::firmware::button_confirm()),
|
||||
)
|
||||
}
|
||||
|
@ -221,6 +221,32 @@ pub const fn button_cancel() -> ButtonStyleSheet {
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn button_default_actionbar_right() -> ButtonStyleSheet {
|
||||
ButtonStyleSheet {
|
||||
normal: &ButtonStyle {
|
||||
font: fonts::FONT_SATOSHI_MEDIUM_26,
|
||||
text_color: GREY_LIGHT,
|
||||
button_color: GREY_EXTRA_DARK,
|
||||
icon_color: GREY_LIGHT,
|
||||
background_color: GREY_EXTRA_DARK,
|
||||
},
|
||||
active: &ButtonStyle {
|
||||
font: fonts::FONT_SATOSHI_MEDIUM_26,
|
||||
text_color: GREY_DARK,
|
||||
button_color: GREY_SUPER_DARK,
|
||||
icon_color: GREY_DARK,
|
||||
background_color: BG,
|
||||
},
|
||||
disabled: &ButtonStyle {
|
||||
font: fonts::FONT_SATOSHI_MEDIUM_26,
|
||||
text_color: GREY_EXTRA_DARK,
|
||||
button_color: BG,
|
||||
icon_color: GREY_EXTRA_DARK,
|
||||
background_color: BG,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn button_warning_high() -> ButtonStyleSheet {
|
||||
ButtonStyleSheet {
|
||||
normal: &ButtonStyle {
|
||||
|
@ -74,9 +74,7 @@ impl FirmwareUI for UIEckhart {
|
||||
};
|
||||
|
||||
let verb = verb.unwrap_or(TR::buttons__confirm.into());
|
||||
let mut right_button = Button::with_text(verb)
|
||||
.with_gradient()
|
||||
.styled(theme::firmware::button_confirm());
|
||||
let mut right_button = Button::with_text(verb).styled(theme::firmware::button_confirm());
|
||||
if hold {
|
||||
right_button = right_button.with_long_press(theme::CONFIRM_HOLD_DURATION);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user