mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
use trezor.ui.{BG,FG}
This commit is contained in:
parent
2c73a3f0a8
commit
808317424d
@ -123,7 +123,7 @@ protect_by_pin = protect_by_pin_or_fail
|
||||
def _render_pin_failure(sleep_ms: int):
|
||||
ui.display.clear()
|
||||
ui.display.text_center(240, 240, 'Sleeping for %d seconds' % (sleep_ms / 1000),
|
||||
ui.BOLD, ui.RED, ui.BLACK)
|
||||
ui.BOLD, ui.RED, ui.BG)
|
||||
|
||||
|
||||
def _get_code_and_label(code: int):
|
||||
|
@ -425,9 +425,9 @@ class ConfirmContent(ui.Widget):
|
||||
header = 'U2F Register'
|
||||
else:
|
||||
header = 'U2F Authenticate'
|
||||
ui.header(header, ui.ICON_RESET, ui.GREEN, ui.BLACK)
|
||||
ui.header(header, ui.ICON_RESET, ui.GREEN, ui.BG)
|
||||
ui.display.image((240 - 64) // 2, 90, self.app_icon)
|
||||
ui.display.text_center(120, 185, self.app_name, ui.MONO, ui.WHITE, ui.BLACK)
|
||||
ui.display.text_center(120, 185, self.app_name, ui.MONO, ui.FG, ui.BG)
|
||||
|
||||
|
||||
_CONFIRM_STATE_TIMEOUT_MS = const(10 * 1000)
|
||||
|
@ -20,7 +20,7 @@ def display_homescreen():
|
||||
from apps.common import storage
|
||||
|
||||
image = res.load('apps/homescreen/res/trezor_logo.toig')
|
||||
ui.display.icon(0, 0, image, ui.WHITE, ui.BLACK)
|
||||
ui.display.icon(0, 0, image, ui.FG, ui.BG)
|
||||
|
||||
if not storage.is_initialized():
|
||||
label = 'Go to trezor.io/start'
|
||||
@ -28,7 +28,7 @@ def display_homescreen():
|
||||
label = storage.get_label()
|
||||
if not label:
|
||||
label = 'My TREZOR'
|
||||
ui.display.text_center(120, 210, label, ui.BOLD, ui.WHITE, ui.BLACK)
|
||||
ui.display.text_center(120, 210, label, ui.BOLD, ui.FG, ui.BG)
|
||||
|
||||
|
||||
@unimport
|
||||
|
@ -16,8 +16,8 @@ async def layout_recovery_device(ctx, msg):
|
||||
msg = 'Please enter ' + nth(msg.word_count) + ' word'
|
||||
|
||||
ui.display.clear()
|
||||
ui.header('Recovery device', ui.ICON_RECOVERY, ui.BLACK, ui.LIGHT_GREEN)
|
||||
ui.display.text(10, 74, msg, ui.BOLD, ui.WHITE, ui.BLACK)
|
||||
ui.display.text(10, 104, 'of your mnemonic.', ui.BOLD, ui.WHITE, ui.BLACK)
|
||||
ui.header('Recovery device', ui.ICON_RECOVERY, ui.BG, ui.LIGHT_GREEN)
|
||||
ui.display.text(10, 74, msg, ui.BOLD, ui.FG, ui.BG)
|
||||
ui.display.text(10, 104, 'of your mnemonic.', ui.BOLD, ui.FG, ui.BG)
|
||||
|
||||
# TODO
|
||||
|
@ -104,11 +104,11 @@ async def show_mnemonic(mnemonic):
|
||||
|
||||
|
||||
async def show_mnemonic_page(page, page_count, mnemonic):
|
||||
from trezor.ui.button import Button, CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE
|
||||
from trezor.ui.button import Button
|
||||
from trezor.ui.scroll import render_scrollbar, animate_swipe
|
||||
|
||||
ui.display.clear()
|
||||
ui.header('Write down your seed', ui.ICON_RESET, ui.BLACK, ui.LIGHT_GREEN)
|
||||
ui.header('Write down your seed', ui.ICON_RESET, ui.BG, ui.LIGHT_GREEN)
|
||||
render_scrollbar(page, page_count)
|
||||
|
||||
for pi, (wi, word) in enumerate(mnemonic[page]):
|
||||
@ -118,14 +118,14 @@ async def show_mnemonic_page(page, page_count, mnemonic):
|
||||
if pos > 9:
|
||||
offset += 12
|
||||
ui.display.text(
|
||||
10, top, '%d.' % pos, ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
|
||||
10, top, '%d.' % pos, ui.BOLD, ui.LIGHT_GREEN, ui.BG)
|
||||
ui.display.text(
|
||||
30 + offset, top, '%s' % word, ui.BOLD, ui.WHITE, ui.BLACK)
|
||||
30 + offset, top, '%s' % word, ui.BOLD, ui.FG, ui.BG)
|
||||
|
||||
if page + 1 == page_count:
|
||||
await Button(
|
||||
(0, 240 - 48, 240, 48), 'Finish',
|
||||
normal_style=CONFIRM_BUTTON,
|
||||
active_style=CONFIRM_BUTTON_ACTIVE)
|
||||
normal_style=ui.BTN_CONFIRM,
|
||||
active_style=ui.BTN_CONFIRM_ACTIVE)
|
||||
else:
|
||||
await animate_swipe()
|
||||
|
@ -35,8 +35,8 @@ async def layout_cipher_key_value(ctx, msg):
|
||||
|
||||
ui.display.clear()
|
||||
ui.display.text(10, 30, 'CipherKeyValue',
|
||||
ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
|
||||
ui.display.text(10, 60, msg.key, ui.MONO, ui.WHITE, ui.BLACK)
|
||||
ui.BOLD, ui.LIGHT_GREEN, ui.BG)
|
||||
ui.display.text(10, 60, msg.key, ui.MONO, ui.FG, ui.BG)
|
||||
|
||||
node = await seed.get_root(ctx)
|
||||
node.derive_path(msg.address_n)
|
||||
|
@ -20,9 +20,9 @@ def serialize_identity(identity):
|
||||
def display_identity(identity: str, challenge_visual: str):
|
||||
ui.display.clear()
|
||||
ui.display.text(10, 30, 'Identity:',
|
||||
ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
|
||||
ui.display.text(10, 60, challenge_visual, ui.MONO, ui.WHITE, ui.BLACK)
|
||||
ui.display.text(10, 80, identity, ui.MONO, ui.WHITE, ui.BLACK)
|
||||
ui.BOLD, ui.LIGHT_GREEN, ui.BG)
|
||||
ui.display.text(10, 60, challenge_visual, ui.MONO, ui.FG, ui.BG)
|
||||
ui.display.text(10, 80, identity, ui.MONO, ui.FG, ui.BG)
|
||||
|
||||
|
||||
def get_identity_path(identity: str, index: int):
|
||||
|
@ -12,8 +12,8 @@ async def layout_sign_message(ctx, msg):
|
||||
|
||||
ui.display.clear()
|
||||
ui.display.text(10, 30, 'Signing message',
|
||||
ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
|
||||
ui.display.text(10, 60, msg.message, ui.MONO, ui.WHITE, ui.BLACK)
|
||||
ui.BOLD, ui.LIGHT_GREEN, ui.BG)
|
||||
ui.display.text(10, 60, msg.message, ui.MONO, ui.FG, ui.BG)
|
||||
|
||||
coin_name = msg.coin_name or 'Bitcoin'
|
||||
coin = coins.by_name(coin_name)
|
||||
|
@ -30,8 +30,8 @@ async def layout_verify_message(ctx, msg):
|
||||
|
||||
ui.display.clear()
|
||||
ui.display.text(10, 30, 'Verifying message',
|
||||
ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
|
||||
ui.display.text(10, 60, msg.message, ui.MONO, ui.WHITE, ui.BLACK)
|
||||
ui.display.text(10, 80, msg.address, ui.MONO, ui.WHITE, ui.BLACK)
|
||||
ui.BOLD, ui.LIGHT_GREEN, ui.BG)
|
||||
ui.display.text(10, 60, msg.message, ui.MONO, ui.FG, ui.BG)
|
||||
ui.display.text(10, 80, msg.address, ui.MONO, ui.FG, ui.BG)
|
||||
|
||||
return Success(message='Message verified')
|
||||
|
@ -101,7 +101,7 @@ def layout(f):
|
||||
return inner
|
||||
|
||||
|
||||
def header(title: str, icon: bytes=ICON_RESET, fg: int=BLACK, bg: int=BLACK):
|
||||
def header(title: str, icon: bytes=ICON_RESET, fg: int=BG, bg: int=BG):
|
||||
display.bar(0, 0, 240, 32, bg)
|
||||
if icon is not None:
|
||||
display.icon(8, 4, res.load(icon), fg, bg)
|
||||
|
@ -56,7 +56,7 @@ class Button(Widget):
|
||||
ty = ay + ah // 2 + 8
|
||||
display.bar_radius(ax, ay, aw, ah,
|
||||
s['border-color'],
|
||||
ui.BLACK,
|
||||
ui.BG,
|
||||
s['radius'])
|
||||
display.bar_radius(ax + 1, ay + 1, aw - 2, ah - 2,
|
||||
s['bg-color'],
|
||||
|
@ -49,29 +49,29 @@ class KeyboardMultiTap(ui.Widget):
|
||||
def render(self):
|
||||
|
||||
# clear canvas under input line
|
||||
display.bar(0, 0, 205, 40, ui.BLACK)
|
||||
display.bar(0, 0, 205, 40, ui.BG)
|
||||
|
||||
# input line
|
||||
content_width = display.text_width(self.content, ui.BOLD)
|
||||
display.text(20, 30, self.content, ui.BOLD, ui.WHITE, ui.BLACK)
|
||||
display.text(20, 30, self.content, ui.BOLD, ui.FG, ui.BG)
|
||||
|
||||
# pending marker
|
||||
if self.pending_button is not None:
|
||||
pending_width = display.text_width(self.content[-1:], ui.BOLD)
|
||||
pending_x = 20 + content_width - pending_width
|
||||
display.bar(pending_x, 33, pending_width + 2, 3, ui.WHITE)
|
||||
display.bar(pending_x, 33, pending_width + 2, 3, ui.FG)
|
||||
|
||||
# auto-suggest
|
||||
if self.sugg_word is not None:
|
||||
sugg_rest = self.sugg_word[len(self.content):]
|
||||
sugg_x = 20 + content_width
|
||||
display.text(sugg_x, 30, sugg_rest, ui.BOLD, ui.GREY, ui.BLACK)
|
||||
display.text(sugg_x, 30, sugg_rest, ui.BOLD, ui.GREY, ui.BG)
|
||||
|
||||
# render backspace button
|
||||
if self.content:
|
||||
self.bs_button.render()
|
||||
else:
|
||||
display.bar(240 - 48, 0, 48, 42, ui.BLACK)
|
||||
display.bar(240 - 48, 0, 48, 42, ui.BG)
|
||||
|
||||
# key buttons
|
||||
for btn in self.key_buttons:
|
||||
@ -173,10 +173,10 @@ class KeyboardZooming(ui.Widget):
|
||||
|
||||
def render_input(self):
|
||||
if self.content:
|
||||
display.bar(0, 0, 200, 40, ui.BLACK)
|
||||
display.bar(0, 0, 200, 40, ui.BG)
|
||||
else:
|
||||
display.bar(0, 0, 240, 40, ui.BLACK)
|
||||
display.text(20, 30, self.content, ui.BOLD, ui.GREY, ui.BLACK)
|
||||
display.bar(0, 0, 240, 40, ui.BG)
|
||||
display.text(20, 30, self.content, ui.BOLD, ui.GREY, ui.BG)
|
||||
if self.content:
|
||||
self.bs_button.render()
|
||||
|
||||
|
@ -14,10 +14,10 @@ class Loader(ui.Widget):
|
||||
|
||||
def start(self):
|
||||
self.start_ticks_ms = utime.ticks_ms()
|
||||
ui.display.bar(0, 32, 240, 240 - 80, ui.BLACK)
|
||||
ui.display.bar(0, 32, 240, 240 - 80, ui.BG)
|
||||
|
||||
def stop(self):
|
||||
ui.display.bar(0, 32, 240, 240 - 80, ui.BLACK)
|
||||
ui.display.bar(0, 32, 240, 240 - 80, ui.BG)
|
||||
ticks_diff = utime.ticks_ms() - self.start_ticks_ms
|
||||
self.start_ticks_ms = None
|
||||
return ticks_diff >= self.target_ms
|
||||
|
@ -45,10 +45,10 @@ class PinMatrix(ui.Widget):
|
||||
header = '*' * len(self.pin) if self.pin else self.label
|
||||
|
||||
# clear canvas under input line
|
||||
display.bar(0, 0, 205, 48, ui.BLACK)
|
||||
display.bar(0, 0, 205, 48, ui.BG)
|
||||
|
||||
# input line with a header
|
||||
display.text_center(120, 30, header, ui.BOLD, ui.GREY, ui.BLACK)
|
||||
display.text_center(120, 30, header, ui.BOLD, ui.GREY, ui.BG)
|
||||
|
||||
# pin matrix buttons
|
||||
for btn in self.pin_buttons:
|
||||
|
@ -37,9 +37,9 @@ async def animate_swipe():
|
||||
sleep = loop.sleep(time_delay)
|
||||
for t in ui.pulse(draw_delay):
|
||||
fg = ui.blend(ui.GREY, ui.DARK_GREY, t)
|
||||
ui.display.bar_radius(102, 214, 36, 4, fg, ui.BLACK, 2)
|
||||
ui.display.bar_radius(106, 222, 28, 4, fg, ui.BLACK, 2)
|
||||
ui.display.bar_radius(110, 230, 20, 4, fg, ui.BLACK, 2)
|
||||
ui.display.bar_radius(102, 214, 36, 4, fg, ui.BG, 2)
|
||||
ui.display.bar_radius(106, 222, 28, 4, fg, ui.BG, 2)
|
||||
ui.display.bar_radius(110, 230, 20, 4, fg, ui.BG, 2)
|
||||
await sleep
|
||||
|
||||
|
||||
@ -57,6 +57,6 @@ def render_scrollbar(page, page_count):
|
||||
for i in range(0, page_count):
|
||||
if i != page:
|
||||
ui.display.bar_radius(x, y + i * padding, size,
|
||||
size, ui.DARK_GREY, ui.BLACK, 4)
|
||||
size, ui.DARK_GREY, ui.BG, 4)
|
||||
ui.display.bar_radius(x, y + page * padding, size,
|
||||
size, ui.WHITE, ui.BLACK, 4)
|
||||
size, ui.FG, ui.BG, 4)
|
||||
|
@ -17,9 +17,9 @@ class Text(ui.Widget):
|
||||
offset_x = TEXT_MARGIN_LEFT
|
||||
offset_y = TEXT_LINE_HEIGHT + TEXT_HEADER_HEIGHT
|
||||
style = ui.NORMAL
|
||||
fg = ui.WHITE
|
||||
bg = ui.BLACK
|
||||
ui.header(self.header_text, self.header_icon, ui.GREEN, ui.BLACK)
|
||||
fg = ui.FG
|
||||
bg = ui.BG
|
||||
ui.header(self.header_text, self.header_icon, ui.GREEN, ui.BG)
|
||||
|
||||
for item in self.content:
|
||||
if isinstance(item, str):
|
||||
|
Loading…
Reference in New Issue
Block a user