mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 00:28:10 +00:00
minor design changes
This commit is contained in:
parent
420516c5de
commit
8d4cd85659
@ -25,17 +25,14 @@ async def confirm(session_id, content=None, code=None, *args, **kwargs):
|
||||
|
||||
@unimport
|
||||
async def hold_to_confirm(session_id, content=None, code=None, *args, **kwargs):
|
||||
from trezor.ui.button import Button, CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE
|
||||
from trezor.ui.confirm import HoldToConfirmDialog, CONFIRMED
|
||||
from trezor.messages.ButtonRequest import ButtonRequest
|
||||
from trezor.messages.ButtonRequestType import Other
|
||||
from trezor.messages.wire_types import ButtonAck
|
||||
|
||||
ui.display.clear()
|
||||
button = Button((0, 240 - 48, 240, 48), 'Hold to confirm',
|
||||
normal_style=CONFIRM_BUTTON,
|
||||
active_style=CONFIRM_BUTTON_ACTIVE)
|
||||
dialog = HoldToConfirmDialog(button, content, *args, **kwargs)
|
||||
|
||||
dialog = HoldToConfirmDialog(content, 'Hold to confirm', *args, **kwargs)
|
||||
|
||||
if code is None:
|
||||
code = Other
|
||||
|
@ -25,7 +25,7 @@ BLUE = rgbcolor(0x21, 0x96, 0xF3)
|
||||
LIGHT_BLUE = rgbcolor(0x03, 0xA9, 0xF4)
|
||||
CYAN = rgbcolor(0x00, 0xBC, 0xD4)
|
||||
TEAL = rgbcolor(0x00, 0x96, 0x88)
|
||||
GREEN = rgbcolor(0x44, 0x55, 0x14)
|
||||
GREEN = rgbcolor(0x4C, 0xC1, 0x48)
|
||||
LIGHT_GREEN = rgbcolor(0x87, 0xCE, 0x26)
|
||||
LIME = rgbcolor(0xCD, 0xDC, 0x39)
|
||||
YELLOW = rgbcolor(0xFF, 0xEB, 0x3B)
|
||||
@ -49,6 +49,9 @@ MONO = Display.FONT_MONO
|
||||
NORMAL = Display.FONT_NORMAL
|
||||
BOLD = Display.FONT_BOLD
|
||||
|
||||
# radius for buttons and other elemts
|
||||
BTN_RADIUS = const(2)
|
||||
|
||||
BACKLIGHT_NORMAL = const(60)
|
||||
BACKLIGHT_DIM = const(5)
|
||||
BACKLIGHT_MAX = const(255)
|
||||
|
@ -8,18 +8,21 @@ DEFAULT_BUTTON = {
|
||||
'fg-color': ui.WHITE,
|
||||
'text-style': ui.NORMAL,
|
||||
'border-color': ui.BLACK,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
DEFAULT_BUTTON_ACTIVE = {
|
||||
'bg-color': ui.GREY,
|
||||
'fg-color': ui.BLACK,
|
||||
'text-style': ui.BOLD,
|
||||
'border-color': ui.GREY,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
DEFAULT_BUTTON_DISABLED = {
|
||||
'bg-color': ui.BLACK,
|
||||
'fg-color': ui.GREY,
|
||||
'text-style': ui.NORMAL,
|
||||
'border-color': ui.BLACK,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
|
||||
CANCEL_BUTTON = {
|
||||
@ -27,25 +30,29 @@ CANCEL_BUTTON = {
|
||||
'fg-color': ui.LIGHT_RED,
|
||||
'text-style': ui.BOLD,
|
||||
'border-color': ui.RED,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
CANCEL_BUTTON_ACTIVE = {
|
||||
'bg-color': ui.RED,
|
||||
'fg-color': ui.WHITE,
|
||||
'text-style': ui.BOLD,
|
||||
'border-color': ui.RED,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
|
||||
CONFIRM_BUTTON = {
|
||||
'bg-color': ui.GREEN,
|
||||
'fg-color': ui.LIGHT_GREEN,
|
||||
'fg-color': ui.WHITE,
|
||||
'text-style': ui.BOLD,
|
||||
'border-color': ui.GREEN,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
CONFIRM_BUTTON_ACTIVE = {
|
||||
'bg-color': ui.GREEN,
|
||||
'fg-color': ui.WHITE,
|
||||
'text-style': ui.BOLD,
|
||||
'border-color': ui.GREEN,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
|
||||
CLEAR_BUTTON = {
|
||||
@ -53,12 +60,14 @@ CLEAR_BUTTON = {
|
||||
'fg-color': ui.WHITE,
|
||||
'text-style': ui.NORMAL,
|
||||
'border-color': ui.BLACK,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
CLEAR_BUTTON_ACTIVE = {
|
||||
'bg-color': ui.BLACK,
|
||||
'fg-color': ui.GREY,
|
||||
'text-style': ui.NORMAL,
|
||||
'border-color': ui.BLACK,
|
||||
'radius': ui.BTN_RADIUS,
|
||||
}
|
||||
|
||||
BTN_CLICKED = const(1)
|
||||
@ -107,8 +116,8 @@ class Button(Widget):
|
||||
ax, ay, aw, ah = self.area
|
||||
tx = ax + aw // 2
|
||||
ty = ay + ah // 2 + 8
|
||||
display.bar(ax, ay, aw, ah, style['border-color'])
|
||||
display.bar(ax + 1, ay + 1, aw - 2, ah - 2, style['bg-color'])
|
||||
display.bar_radius(ax, ay, aw, ah, style['border-color'], ui.BLACK, style['radius'])
|
||||
display.bar_radius(ax + 1, ay + 1, aw - 2, ah - 2, style['bg-color'], style['border-color'], style['radius'])
|
||||
|
||||
if isinstance(self.content, str):
|
||||
display.text_center(tx, ty, self.content,
|
||||
|
@ -38,8 +38,10 @@ class ConfirmDialog(Widget):
|
||||
|
||||
class HoldToConfirmDialog():
|
||||
|
||||
def __init__(self, button, content=None, *args, **kwargs):
|
||||
self.button = button
|
||||
def __init__(self, content=None, hold='Hold to confirm', *args, **kwargs):
|
||||
self.button = Button((0, 240 - 48, 240, 48), hold,
|
||||
normal_style=CONFIRM_BUTTON,
|
||||
active_style=CONFIRM_BUTTON_ACTIVE)
|
||||
self.content = content
|
||||
self.loader = Loader(*args, **kwargs)
|
||||
|
||||
@ -53,7 +55,7 @@ class HoldToConfirmDialog():
|
||||
def send(self, event, pos):
|
||||
button = self.button
|
||||
was_started = button.state & BTN_STARTED
|
||||
button.send(event, pos)
|
||||
button.touch(event, pos)
|
||||
is_started = button.state & BTN_STARTED
|
||||
if is_started:
|
||||
if not was_started:
|
||||
|
@ -19,7 +19,7 @@ class Text:
|
||||
style = ui.NORMAL
|
||||
fg = ui.WHITE
|
||||
bg = ui.BLACK
|
||||
ui.header(self.header_text, self.header_icon, ui.BLACK, ui.LIGHT_GREEN)
|
||||
ui.header(self.header_text, self.header_icon, ui.GREEN, ui.BLACK)
|
||||
|
||||
for item in self.content:
|
||||
if isinstance(item, str):
|
||||
|
Loading…
Reference in New Issue
Block a user