mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-14 03:30:02 +00:00
added remove input line
This commit is contained in:
parent
c6c69ba8c8
commit
c6ed52a7c9
@ -5,7 +5,6 @@ from .button import Button, BTN_CLICKED
|
||||
from .button import CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE
|
||||
from .button import CANCEL_BUTTON, CANCEL_BUTTON_ACTIVE
|
||||
|
||||
|
||||
def digit_area(i):
|
||||
width = const(80)
|
||||
height = const(48)
|
||||
@ -25,6 +24,7 @@ class PinMatrix():
|
||||
def __init__(self, label='Enter PIN', pin=''):
|
||||
self.label = label
|
||||
self.pin = pin
|
||||
self.clear_button = Button((240 - 48, 0, 48, 42), 'X')
|
||||
self.buttons = [Button(digit_area(i), str(d))
|
||||
for i, d in enumerate(generate_digits())]
|
||||
|
||||
@ -32,10 +32,16 @@ class PinMatrix():
|
||||
|
||||
header = ''.join(['*' for _ in self.pin]) if self.pin else self.label
|
||||
|
||||
# clear canvas under input line
|
||||
display.bar(48, 0, 144, 48, ui.BLACK)
|
||||
|
||||
# input line with a header
|
||||
display.bar(0, 0, 240, 48, ui.BLACK)
|
||||
display.text_center(120, 30, header, ui.BOLD, ui.GREY, ui.BLACK)
|
||||
|
||||
# render clear button
|
||||
if self.pin:
|
||||
self.clear_button.render()
|
||||
|
||||
# pin matrix buttons
|
||||
for btn in self.buttons:
|
||||
btn.render()
|
||||
@ -49,6 +55,11 @@ class PinMatrix():
|
||||
display.bar(0, 142, 240, 2, ui.blend(ui.BLACK, ui.WHITE, 0.25))
|
||||
|
||||
def send(self, event, pos):
|
||||
if self.clear_button.send(event, pos) == BTN_CLICKED:
|
||||
self.pin = ''
|
||||
self.label = 'Enter PIN'
|
||||
|
||||
|
||||
for btn in self.buttons:
|
||||
if btn.send(event, pos) == BTN_CLICKED:
|
||||
self.pin += btn.text
|
||||
|
Loading…
Reference in New Issue
Block a user