From a074dd3e542c5e70ef79e4f02982996fd513b6eb Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Tue, 23 Oct 2018 17:07:07 +0200 Subject: [PATCH] eth: make confirmation layouts more compact Fixes #210 --- src/apps/ethereum/layout.py | 16 ++++++++++------ src/trezor/ui/text.py | 4 +--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/apps/ethereum/layout.py b/src/apps/ethereum/layout.py index 2e0e6791d..a94b94f49 100644 --- a/src/apps/ethereum/layout.py +++ b/src/apps/ethereum/layout.py @@ -16,10 +16,12 @@ async def require_confirm_tx(ctx, to, value, chain_id, token=None, tx_type=None) to_str = _ethereum_address_hex(to, networks.by_chain_id(chain_id)) else: to_str = "new contract?" - text = Text("Confirm sending", ui.ICON_SEND, icon_color=ui.GREEN) + text = Text("Confirm sending", ui.ICON_SEND, icon_color=ui.GREEN, new_lines=False) text.bold(format_ethereum_amount(value, token, chain_id, tx_type)) - text.normal("to") - text.mono(*split_address(to_str)) + text.normal(ui.GREY, "to", ui.FG) + for to_line in split_address(to_str): + text.br() + text.mono(to_line) # we use SignTx, not ConfirmOutput, for compatibility with T1 await require_confirm(ctx, text, ButtonRequestType.SignTx) @@ -27,11 +29,13 @@ async def require_confirm_tx(ctx, to, value, chain_id, token=None, tx_type=None) async def require_confirm_fee( ctx, spending, gas_price, gas_limit, chain_id, token=None, tx_type=None ): - text = Text("Confirm transaction", ui.ICON_SEND, icon_color=ui.GREEN) + text = Text( + "Confirm transaction", ui.ICON_SEND, icon_color=ui.GREEN, new_lines=False + ) text.bold(format_ethereum_amount(spending, token, chain_id, tx_type)) - text.normal("Gas price:") + text.normal(ui.GREY, "Gas price:", ui.FG) text.bold(format_ethereum_amount(gas_price, None, chain_id, tx_type)) - text.normal("Maximum fee:") + text.normal(ui.GREY, "Maximum fee:", ui.FG) text.bold(format_ethereum_amount(gas_price * gas_limit, None, chain_id, tx_type)) await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx) diff --git a/src/trezor/ui/text.py b/src/trezor/ui/text.py index 5e5917a4a..ab461370f 100644 --- a/src/trezor/ui/text.py +++ b/src/trezor/ui/text.py @@ -123,22 +123,20 @@ class Text(ui.LazyWidget): self.content = [] def normal(self, *content): + self.content.append(ui.NORMAL) self.content.extend(content) def bold(self, *content): self.content.append(ui.BOLD) self.content.extend(content) - self.content.append(ui.NORMAL) def mono(self, *content): self.content.append(ui.MONO) self.content.extend(content) - self.content.append(ui.NORMAL) def mono_bold(self, *content): self.content.append(ui.MONO_BOLD) self.content.extend(content) - self.content.append(ui.NORMAL) def br(self): self.content.append(BR)