mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-26 09:52:34 +00:00
feat(eckhart): use gradients in ActionBar
This commit is contained in:
parent
c48e8f8a90
commit
ae02d77852
@ -350,7 +350,7 @@ impl Button {
|
|||||||
.render(target);
|
.render(target);
|
||||||
}
|
}
|
||||||
// Gradient bar is rendered only in `normal` state, not `active` or `disabled`
|
// 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);
|
self.render_gradient_bar(target, style);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -609,6 +609,14 @@ enum State {
|
|||||||
Disabled,
|
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)]
|
#[derive(PartialEq, Eq, Clone)]
|
||||||
pub enum ButtonContent {
|
pub enum ButtonContent {
|
||||||
Empty,
|
Empty,
|
||||||
|
@ -71,12 +71,13 @@ impl ActionBar {
|
|||||||
/// component automatically shows navigation up/down buttons for
|
/// component automatically shows navigation up/down buttons for
|
||||||
/// paginated content.
|
/// paginated content.
|
||||||
pub fn new_single(button: Button) -> Self {
|
pub fn new_single(button: Button) -> Self {
|
||||||
Self::new(
|
let mut right_button = button
|
||||||
Mode::Single,
|
.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)
|
||||||
None,
|
.with_gradient();
|
||||||
Some(button.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)),
|
if right_button.stylesheet() == &theme::button_default() {
|
||||||
None,
|
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
|
/// Create action bar with single button confirming the layout
|
||||||
@ -93,17 +94,21 @@ impl ActionBar {
|
|||||||
/// automatically shows navigation up/down buttons for paginated
|
/// automatically shows navigation up/down buttons for paginated
|
||||||
/// content.
|
/// content.
|
||||||
pub fn new_double(left: Button, right: Button) -> Self {
|
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(
|
Self::new(
|
||||||
Mode::Double { left_short: true },
|
Mode::Double { left_short: true },
|
||||||
Some(
|
Some(left_button),
|
||||||
left.with_expanded_touch_area(Self::BUTTON_EXPAND_TOUCH)
|
Some(right_button),
|
||||||
.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()),
|
|
||||||
),
|
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -112,7 +117,6 @@ impl ActionBar {
|
|||||||
Self::new_double(
|
Self::new_double(
|
||||||
Button::with_icon(theme::ICON_CROSS),
|
Button::with_icon(theme::ICON_CROSS),
|
||||||
Button::with_text(TR::buttons__confirm.into())
|
Button::with_text(TR::buttons__confirm.into())
|
||||||
.with_gradient()
|
|
||||||
.styled(theme::firmware::button_confirm()),
|
.styled(theme::firmware::button_confirm()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -217,6 +217,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 {
|
pub const fn button_warning_high() -> ButtonStyleSheet {
|
||||||
ButtonStyleSheet {
|
ButtonStyleSheet {
|
||||||
normal: &ButtonStyle {
|
normal: &ButtonStyle {
|
||||||
|
@ -74,9 +74,7 @@ impl FirmwareUI for UIEckhart {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let verb = verb.unwrap_or(TR::buttons__confirm.into());
|
let verb = verb.unwrap_or(TR::buttons__confirm.into());
|
||||||
let mut right_button = Button::with_text(verb)
|
let mut right_button = Button::with_text(verb).styled(theme::firmware::button_confirm());
|
||||||
.with_gradient()
|
|
||||||
.styled(theme::firmware::button_confirm());
|
|
||||||
if hold {
|
if hold {
|
||||||
right_button = right_button.with_long_press(theme::CONFIRM_HOLD_DURATION);
|
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