mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
src/apps/wallet/get_address: update receive dialog
This commit is contained in:
parent
22c9296aac
commit
c34ee98731
@ -1,3 +1,4 @@
|
||||
from micropython import const
|
||||
from trezor import wire, ui
|
||||
|
||||
|
||||
@ -16,11 +17,14 @@ async def layout_get_address(ctx, msg):
|
||||
coin = coins.by_name(coin_name)
|
||||
|
||||
node = await seed.derive_node(ctx, address_n)
|
||||
|
||||
address = addresses.get_address(msg.script_type, coin, node)
|
||||
|
||||
if msg.show_display:
|
||||
await _show_address(ctx, address)
|
||||
while True:
|
||||
if await _show_address(ctx, address):
|
||||
break
|
||||
if await _show_qr(ctx, address):
|
||||
break
|
||||
|
||||
return Address(address=address)
|
||||
|
||||
@ -28,15 +32,29 @@ async def layout_get_address(ctx, msg):
|
||||
async def _show_address(ctx, address):
|
||||
from trezor.messages.ButtonRequestType import Address
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.qr import Qr
|
||||
from trezor.ui.container import Container
|
||||
from ..common.confirm import require_confirm
|
||||
from ..common.confirm import confirm
|
||||
|
||||
lines = _split_address(address)
|
||||
content = Container(Text('Confirm address', ui.ICON_RESET, ui.MONO, *lines))
|
||||
return await confirm(ctx, content, code=Address, cancel='QR', cancel_style=ui.BTN_KEY)
|
||||
|
||||
|
||||
async def _show_qr(ctx, address):
|
||||
from trezor.messages.ButtonRequestType import Address
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.qr import Qr
|
||||
from trezor.ui.container import Container
|
||||
from ..common.confirm import confirm
|
||||
|
||||
qr_x = const(120)
|
||||
qr_y = const(115)
|
||||
qr_coef = const(4)
|
||||
|
||||
content = Container(
|
||||
Qr(address, (120, 135), 3),
|
||||
Text('Confirm address', ui.ICON_RESET, ui.MONO, *lines))
|
||||
await require_confirm(ctx, content, code=Address)
|
||||
Qr(address, (qr_x, qr_y), qr_coef),
|
||||
Text('Confirm address', ui.ICON_RESET, ui.MONO))
|
||||
return await confirm(ctx, content, code=Address, cancel='Address', cancel_style=ui.BTN_KEY)
|
||||
|
||||
|
||||
def _split_address(address):
|
||||
|
@ -12,16 +12,16 @@ DEFAULT_CANCEL = res.load(ui.ICON_CLEAR)
|
||||
|
||||
class ConfirmDialog(Widget):
|
||||
|
||||
def __init__(self, content, confirm=DEFAULT_CONFIRM, cancel=DEFAULT_CANCEL):
|
||||
def __init__(self, content, confirm=DEFAULT_CONFIRM, cancel=DEFAULT_CANCEL, confirm_style=ui.BTN_CONFIRM, cancel_style=ui.BTN_CANCEL):
|
||||
self.content = content
|
||||
if cancel is not None:
|
||||
self.confirm = Button(
|
||||
ui.grid(9, n_x=2), confirm, style=ui.BTN_CONFIRM)
|
||||
ui.grid(9, n_x=2), confirm, style=confirm_style)
|
||||
self.cancel = Button(
|
||||
ui.grid(8, n_x=2), cancel, style=ui.BTN_CANCEL)
|
||||
ui.grid(8, n_x=2), cancel, style=cancel_style)
|
||||
else:
|
||||
self.confirm = Button(
|
||||
ui.grid(4, n_x=1), confirm, style=ui.BTN_CONFIRM)
|
||||
ui.grid(4, n_x=1), confirm, style=confirm_style)
|
||||
self.cancel = None
|
||||
|
||||
def render(self):
|
||||
|
Loading…
Reference in New Issue
Block a user