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