mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
refactor(core): model-dependent UI component directories
They now live under trezor.ui.components.tt. Later trezor.ui.components.t1 will be added and application code will be rewritten to not use them directly in order to work on both TT and T1.
This commit is contained in:
parent
f46380147f
commit
f1382bf892
@ -492,6 +492,18 @@ if FROZEN:
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/crypto/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/res/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/common/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/__init__.py'))
|
||||
if TREZOR_MODEL == 'T':
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/tt/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/tt.py'))
|
||||
elif TREZOR_MODEL == '1':
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/t1/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/t1.py'))
|
||||
else:
|
||||
raise ValueError('Unknown Trezor model')
|
||||
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/*.py'))
|
||||
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'storage/*.py'))
|
||||
|
@ -443,6 +443,18 @@ if FROZEN:
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/crypto/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/res/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/common/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/__init__.py'))
|
||||
if TREZOR_MODEL == 'T':
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/tt/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/tt.py'))
|
||||
elif TREZOR_MODEL == '1':
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/t1/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/t1.py'))
|
||||
else:
|
||||
raise ValueError('Unknown Trezor model')
|
||||
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/*.py'))
|
||||
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'storage/*.py'))
|
||||
|
@ -131,7 +131,7 @@ async def handle_Ping(ctx: wire.Context, msg: Ping) -> Success:
|
||||
if msg.button_protection:
|
||||
from apps.common.confirm import require_confirm
|
||||
from trezor.messages.ButtonRequestType import ProtectCall
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
await require_confirm(ctx, Text("Confirm"), ProtectCall)
|
||||
return Success(message=msg.message)
|
||||
|
@ -8,8 +8,8 @@ from trezor.messages import (
|
||||
ButtonRequestType,
|
||||
)
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_hold_to_confirm
|
||||
from apps.common.layout import split_address
|
||||
|
@ -4,7 +4,7 @@ from trezor import ui
|
||||
from trezor.messages.AuthorizeCoinJoin import AuthorizeCoinJoin
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.base import set_authorization
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
|
@ -3,7 +3,7 @@ from ubinascii import hexlify
|
||||
from trezor import ui, wire
|
||||
from trezor.messages.GetOwnershipProof import GetOwnershipProof
|
||||
from trezor.messages.OwnershipProof import OwnershipProof
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.paths import validate_path
|
||||
|
@ -4,7 +4,7 @@ from ubinascii import hexlify
|
||||
from trezor import ui
|
||||
from trezor.messages import AmountUnit, ButtonRequestType, OutputScriptType
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
|
@ -8,9 +8,9 @@ from trezor.messages import (
|
||||
CardanoCertificateType,
|
||||
)
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.button import ButtonDefault
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.button import ButtonDefault
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common.confirm import confirm, require_confirm, require_hold_to_confirm
|
||||
|
@ -1,17 +1,23 @@
|
||||
from trezor import wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.confirm import CONFIRMED, INFO, Confirm, HoldToConfirm, InfoConfirm
|
||||
from trezor.ui.components.tt.confirm import (
|
||||
CONFIRMED,
|
||||
INFO,
|
||||
Confirm,
|
||||
HoldToConfirm,
|
||||
InfoConfirm,
|
||||
)
|
||||
|
||||
from . import button_request
|
||||
|
||||
if __debug__:
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
|
||||
|
||||
if False:
|
||||
from typing import Any, Callable, Optional
|
||||
from trezor import ui
|
||||
from trezor.ui.confirm import ButtonContent, ButtonStyleType
|
||||
from trezor.ui.components.tt.confirm import ButtonContent, ButtonStyleType
|
||||
from trezor.ui.loader import LoaderStyleType
|
||||
from trezor.messages.ButtonRequest import EnumTypeButtonRequestType
|
||||
|
||||
|
@ -3,11 +3,11 @@ from ubinascii import hexlify
|
||||
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.button import ButtonDefault
|
||||
from trezor.ui.components.tt.button import ButtonDefault
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
from trezor.ui.components.tt.text import TEXT_MAX_LINES, Span, Text
|
||||
from trezor.ui.container import Container
|
||||
from trezor.ui.qr import Qr
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import TEXT_MAX_LINES, Span, Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common import HARDENED
|
||||
|
@ -2,7 +2,7 @@ import storage.device
|
||||
from trezor import ui, utils, workflow
|
||||
from trezor.crypto import bip39, slip39
|
||||
from trezor.messages import BackupType
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
if False:
|
||||
from typing import Optional, Tuple
|
||||
|
@ -6,8 +6,8 @@ from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.PassphraseAck import PassphraseAck
|
||||
from trezor.messages.PassphraseRequest import PassphraseRequest
|
||||
from trezor.ui import ICON_CONFIG, draw_simple
|
||||
from trezor.ui.passphrase import CANCELLED, PassphraseKeyboard
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.passphrase import CANCELLED, PassphraseKeyboard
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from . import button_request
|
||||
from .confirm import require_confirm
|
||||
|
@ -2,7 +2,7 @@ from micropython import const
|
||||
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from . import HARDENED
|
||||
from .confirm import require_confirm
|
||||
|
@ -4,9 +4,9 @@ import storage.sd_salt
|
||||
from trezor import config, ui, wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.pin import pin_to_int
|
||||
from trezor.ui.pin import CANCELLED, PinDialog
|
||||
from trezor.ui.components.tt.pin import CANCELLED, PinDialog
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.ui.popup import Popup
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from . import button_request
|
||||
from .sdcard import SdCardUnavailable, request_sd_salt
|
||||
|
@ -1,7 +1,7 @@
|
||||
import storage.sd_salt
|
||||
from storage.sd_salt import SD_CARD_HOT_SWAPPABLE
|
||||
from trezor import fatfs, sdcard, ui, wire
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import confirm, hold_to_confirm
|
||||
|
||||
|
@ -2,7 +2,7 @@ from ubinascii import hexlify
|
||||
|
||||
from trezor import ui, utils, wire
|
||||
from trezor.crypto.hashlib import blake256, sha256
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.layout import paginate_text, split_address
|
||||
|
@ -53,7 +53,7 @@ if __debug__:
|
||||
layout_change_chan.publish(current_content)
|
||||
|
||||
async def debuglink_decision_dispatcher() -> None:
|
||||
from trezor.ui import confirm, swipe
|
||||
from trezor.ui.components.tt import confirm, swipe
|
||||
|
||||
while True:
|
||||
msg = await debuglink_decision_chan.take()
|
||||
|
@ -5,7 +5,7 @@ from trezor.crypto import bip39, slip39
|
||||
from trezor.messages import BackupType
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.pin import pin_to_int
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.management import backup_types
|
||||
|
@ -3,7 +3,7 @@ from trezor import ui, wire
|
||||
from trezor.messages.DebugLinkShowText import DebugLinkShowText
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.ui import style, text
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import confirm
|
||||
|
||||
|
@ -3,8 +3,8 @@ from ubinascii import hexlify
|
||||
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from .. import helpers
|
||||
|
@ -1,6 +1,6 @@
|
||||
from trezor import ui, wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
|
||||
|
@ -3,7 +3,7 @@ from ubinascii import hexlify
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
|
@ -1,7 +1,7 @@
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
|
@ -3,7 +3,7 @@ from trezor import ui, wire, workflow
|
||||
from trezor.messages import ButtonRequestType, SafetyCheckLevel
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.strings import format_duration_ms
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.base import lock_device
|
||||
from apps.common import safety_checks
|
||||
|
@ -2,7 +2,7 @@ from storage.device import is_initialized
|
||||
from trezor import config, ui, wire
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.pin import pin_to_int
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.layout import show_success
|
||||
|
@ -2,8 +2,8 @@ from storage.device import is_initialized
|
||||
from trezor import config, ui, wire
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.pin import pin_to_int
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.ui.popup import Popup
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.layout import show_success
|
||||
|
@ -3,7 +3,7 @@ from trezor import ui, wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.GetNextU2FCounter import GetNextU2FCounter
|
||||
from trezor.messages.NextU2FCounter import NextU2FCounter
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
|
||||
|
@ -5,7 +5,7 @@ from trezor import config, ui, wire, workflow
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.pin import pin_to_int
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.request_pin import (
|
||||
|
@ -1,11 +1,16 @@
|
||||
from trezor import io, loop, res, ui, workflow
|
||||
from trezor.crypto import bip39
|
||||
from trezor.ui import display
|
||||
from trezor.ui.button import Button, ButtonClear, ButtonMono, ButtonMonoConfirm
|
||||
from trezor.ui.components.tt.button import (
|
||||
Button,
|
||||
ButtonClear,
|
||||
ButtonMono,
|
||||
ButtonMonoConfirm,
|
||||
)
|
||||
|
||||
if False:
|
||||
from typing import Optional, Tuple
|
||||
from trezor.ui.button import ButtonContent, ButtonStyleStateType
|
||||
from trezor.ui.components.tt.button import ButtonContent, ButtonStyleStateType
|
||||
|
||||
|
||||
def compute_mask(text: str) -> int:
|
||||
|
@ -1,11 +1,16 @@
|
||||
from trezor import io, loop, res, ui, workflow
|
||||
from trezor.crypto import slip39
|
||||
from trezor.ui import display
|
||||
from trezor.ui.button import Button, ButtonClear, ButtonMono, ButtonMonoConfirm
|
||||
from trezor.ui.components.tt.button import (
|
||||
Button,
|
||||
ButtonClear,
|
||||
ButtonMono,
|
||||
ButtonMonoConfirm,
|
||||
)
|
||||
|
||||
if False:
|
||||
from typing import Optional, Tuple
|
||||
from trezor.ui.button import ButtonContent, ButtonStyleStateType
|
||||
from trezor.ui.components.tt.button import ButtonContent, ButtonStyleStateType
|
||||
|
||||
|
||||
class KeyButton(Button):
|
||||
|
@ -2,9 +2,9 @@ import storage.recovery
|
||||
from trezor import strings, ui, wire
|
||||
from trezor.crypto.slip39 import MAX_SHARE_COUNT
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.word_select import WordSelector
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.ui.components.tt.word_select import WordSelector
|
||||
|
||||
from apps.common import button_request
|
||||
from apps.common.confirm import confirm, info_confirm, require_confirm
|
||||
|
@ -3,13 +3,13 @@ import ubinascii
|
||||
from trezor import ui, utils
|
||||
from trezor.crypto import random
|
||||
from trezor.messages import BackupType, ButtonRequestType
|
||||
from trezor.ui.button import Button, ButtonDefault
|
||||
from trezor.ui.checklist import Checklist
|
||||
from trezor.ui.info import InfoConfirm
|
||||
from trezor.ui.components.tt.button import Button, ButtonDefault
|
||||
from trezor.ui.components.tt.checklist import Checklist
|
||||
from trezor.ui.components.tt.info import InfoConfirm
|
||||
from trezor.ui.components.tt.num_input import NumInput
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.ui.loader import LoadingAnimation
|
||||
from trezor.ui.num_input import NumInput
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from apps.common.confirm import confirm, require_confirm, require_hold_to_confirm
|
||||
from apps.common.layout import show_success
|
||||
|
@ -5,7 +5,7 @@ from trezor.crypto import random
|
||||
from trezor.messages import SdProtectOperationType
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.pin import pin_to_int
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.layout import show_success
|
||||
|
@ -3,7 +3,7 @@ from trezor import ui, wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.SetU2FCounter import SetU2FCounter
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
|
||||
|
@ -2,9 +2,9 @@ import storage
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.ui.button import ButtonCancel
|
||||
from trezor.ui.components.tt.button import ButtonCancel
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.ui.loader import LoaderDanger
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from apps.common.confirm import require_hold_to_confirm
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from trezor import wire
|
||||
from trezor.crypto import aes, hmac
|
||||
from trezor.messages.CipheredKeyValue import CipheredKeyValue
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.keychain import get_keychain
|
||||
|
@ -3,7 +3,7 @@ from ustruct import pack, unpack
|
||||
from trezor import wire
|
||||
from trezor.crypto.hashlib import sha256
|
||||
from trezor.messages.ECDHSessionKey import ECDHSessionKey
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common import HARDENED
|
||||
|
@ -1,7 +1,7 @@
|
||||
from trezor.crypto import random
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.Entropy import Entropy
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
|
||||
|
@ -3,7 +3,7 @@ from ustruct import pack, unpack
|
||||
from trezor import ui, wire
|
||||
from trezor.crypto.hashlib import sha256
|
||||
from trezor.messages.SignedIdentity import SignedIdentity
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common import HARDENED, coininfo
|
||||
@ -16,7 +16,7 @@ if False:
|
||||
|
||||
from trezor.messages.IdentityType import IdentityType
|
||||
from trezor.messages.SignIdentity import SignIdentity
|
||||
from trezor.ui.text import TextContent
|
||||
from trezor.ui.components.common.text import TextContent
|
||||
|
||||
from apps.common.paths import Bip32Path
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from trezor import strings, ui, utils
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common import button_request
|
||||
|
||||
@ -8,7 +8,11 @@ from apps.common import button_request
|
||||
async def naive_pagination(
|
||||
ctx, lines, title, icon=ui.ICON_RESET, icon_color=ui.ORANGE, per_page=5
|
||||
):
|
||||
from trezor.ui.scroll import CANCELLED, CONFIRMED, PaginatedWithButtons
|
||||
from trezor.ui.components.tt.scroll import (
|
||||
CANCELLED,
|
||||
CONFIRMED,
|
||||
PaginatedWithButtons,
|
||||
)
|
||||
|
||||
pages = []
|
||||
page_lines = paginate_lines(lines, per_page)
|
||||
|
@ -2,8 +2,8 @@ from ubinascii import hexlify
|
||||
|
||||
from trezor import ui, wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.ui.popup import Popup
|
||||
from trezor.ui.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
@ -228,8 +228,8 @@ async def show_address(
|
||||
):
|
||||
from apps.common.confirm import confirm
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.button import ButtonDefault
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.components.tt.button import ButtonDefault
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
|
||||
pages = []
|
||||
for lines in common.paginate_lines(common.split_address(address), 5):
|
||||
|
@ -1,7 +1,7 @@
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
|
||||
|
@ -8,8 +8,8 @@ from trezor.messages import (
|
||||
NEMSupplyChangeType,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.layout import require_confirm, split_address
|
||||
|
||||
|
@ -7,7 +7,7 @@ from trezor.messages import (
|
||||
NEMSignTx,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.layout import split_address
|
||||
|
||||
|
@ -9,7 +9,7 @@ from trezor.messages import (
|
||||
NEMTransfer,
|
||||
)
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.layout import split_address
|
||||
|
@ -1,7 +1,7 @@
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
from apps.common.layout import split_address
|
||||
|
@ -1,6 +1,6 @@
|
||||
from trezor import strings, ui, utils
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
|
||||
|
@ -13,7 +13,7 @@ from trezor.messages.StellarManageOfferOp import StellarManageOfferOp
|
||||
from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp
|
||||
from trezor.messages.StellarPaymentOp import StellarPaymentOp
|
||||
from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.wire import ProcessError
|
||||
|
||||
from .. import consts, helpers
|
||||
|
@ -1,7 +1,7 @@
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.TezosPublicKey import TezosPublicKey
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common import paths, seed
|
||||
|
@ -1,8 +1,8 @@
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.scroll import Paginated
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
|
@ -2,7 +2,7 @@ import storage.device
|
||||
from trezor import ui, wire
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.messages.WebAuthnAddResidentCredential import WebAuthnAddResidentCredential
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from trezor import ui
|
||||
from trezor.ui.text import text_center_trim_left, text_center_trim_right
|
||||
from trezor.ui.components.tt.text import text_center_trim_left, text_center_trim_right
|
||||
|
||||
if False:
|
||||
from typing import Optional
|
||||
|
@ -8,9 +8,14 @@ import storage.resident_credentials
|
||||
from trezor import config, io, log, loop, ui, utils, workflow
|
||||
from trezor.crypto import aes, der, hashlib, hmac, random
|
||||
from trezor.crypto.curve import nist256p1
|
||||
from trezor.ui.confirm import CONFIRMED, Confirm, ConfirmPageable, Pageable
|
||||
from trezor.ui.components.tt.confirm import (
|
||||
CONFIRMED,
|
||||
Confirm,
|
||||
ConfirmPageable,
|
||||
Pageable,
|
||||
)
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.ui.popup import Popup
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from apps.base import set_homescreen
|
||||
from apps.common import cbor
|
||||
|
@ -4,7 +4,7 @@ from trezor.messages.WebAuthnCredentials import WebAuthnCredentials
|
||||
from trezor.messages.WebAuthnListResidentCredentials import (
|
||||
WebAuthnListResidentCredentials,
|
||||
)
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
|
||||
|
18
core/src/trezor/ui/components/common/__init__.py
Normal file
18
core/src/trezor/ui/components/common/__init__.py
Normal file
@ -0,0 +1,18 @@
|
||||
"""
|
||||
The components/common module contains code that is used by both components/tt
|
||||
and components/t1.
|
||||
"""
|
||||
|
||||
if False:
|
||||
from typing import List
|
||||
|
||||
|
||||
def break_path_to_lines(path_str: str, per_line: int) -> List[str]:
|
||||
lines = []
|
||||
while len(path_str) > per_line:
|
||||
i = path_str[:per_line].rfind("/")
|
||||
lines.append(path_str[:i])
|
||||
path_str = path_str[i:]
|
||||
lines.append(path_str)
|
||||
|
||||
return lines
|
45
core/src/trezor/ui/components/common/confirm.py
Normal file
45
core/src/trezor/ui/components/common/confirm.py
Normal file
@ -0,0 +1,45 @@
|
||||
from trezor import loop, ui
|
||||
|
||||
if __debug__:
|
||||
from apps.debug import confirm_signal
|
||||
|
||||
if False:
|
||||
from typing import List, Tuple, Optional
|
||||
|
||||
CONFIRMED = object()
|
||||
CANCELLED = object()
|
||||
INFO = object()
|
||||
|
||||
|
||||
class ConfirmBase(ui.Layout):
|
||||
def __init__(
|
||||
self,
|
||||
content: ui.Component,
|
||||
confirm: Optional[ui.Component] = None,
|
||||
cancel: Optional[ui.Component] = None,
|
||||
) -> None:
|
||||
self.content = content
|
||||
self.confirm = confirm
|
||||
self.cancel = cancel
|
||||
|
||||
def dispatch(self, event: int, x: int, y: int) -> None:
|
||||
super().dispatch(event, x, y)
|
||||
self.content.dispatch(event, x, y)
|
||||
if self.confirm is not None:
|
||||
self.confirm.dispatch(event, x, y)
|
||||
if self.cancel is not None:
|
||||
self.cancel.dispatch(event, x, y)
|
||||
|
||||
def on_confirm(self) -> None:
|
||||
raise ui.Result(CONFIRMED)
|
||||
|
||||
def on_cancel(self) -> None:
|
||||
raise ui.Result(CANCELLED)
|
||||
|
||||
if __debug__:
|
||||
|
||||
def read_content(self) -> List[str]:
|
||||
return self.content.read_content()
|
||||
|
||||
def create_tasks(self) -> Tuple[loop.Task, ...]:
|
||||
return super().create_tasks() + (confirm_signal(),)
|
@ -2,14 +2,18 @@ from micropython import const
|
||||
|
||||
from trezor import ui
|
||||
|
||||
from ...constants import (
|
||||
TEXT_HEADER_HEIGHT,
|
||||
TEXT_LINE_HEIGHT,
|
||||
TEXT_LINE_HEIGHT_HALF,
|
||||
TEXT_MARGIN_LEFT,
|
||||
TEXT_MAX_LINES,
|
||||
)
|
||||
|
||||
if False:
|
||||
from typing import Any, List, Optional, Union
|
||||
|
||||
TEXT_HEADER_HEIGHT = const(48)
|
||||
TEXT_LINE_HEIGHT = const(26)
|
||||
TEXT_LINE_HEIGHT_HALF = const(13)
|
||||
TEXT_MARGIN_LEFT = const(14)
|
||||
TEXT_MAX_LINES = const(5)
|
||||
TextContent = Union[str, int]
|
||||
|
||||
# needs to be different from all colors and font ids
|
||||
BR = const(-256)
|
||||
@ -17,10 +21,6 @@ BR_HALF = const(-257)
|
||||
|
||||
_FONTS = (ui.NORMAL, ui.BOLD, ui.MONO)
|
||||
|
||||
if False:
|
||||
TextContent = Union[str, int]
|
||||
|
||||
|
||||
DASH_WIDTH = ui.display.text_width("-", ui.BOLD)
|
||||
|
||||
|
||||
@ -360,7 +360,7 @@ if __debug__:
|
||||
self.screen_contents.append(string[start : start + length])
|
||||
|
||||
|
||||
class Text(ui.Component):
|
||||
class TextBase(ui.Component):
|
||||
def __init__(
|
||||
self,
|
||||
header_text: str,
|
||||
@ -406,25 +406,7 @@ class Text(ui.Component):
|
||||
self.content.append(BR_HALF)
|
||||
|
||||
def on_render(self) -> None:
|
||||
if self.repaint:
|
||||
ui.header(
|
||||
self.header_text,
|
||||
self.header_icon,
|
||||
ui.TITLE_GREY,
|
||||
ui.BG,
|
||||
self.icon_color,
|
||||
)
|
||||
render_text(
|
||||
self.content,
|
||||
self.new_lines,
|
||||
self.max_lines,
|
||||
item_offset=self.content_offset,
|
||||
char_offset=self.char_offset,
|
||||
break_words=self.break_words,
|
||||
line_width=self.line_width,
|
||||
render_page_overflow=self.render_page_overflow,
|
||||
)
|
||||
self.repaint = False
|
||||
pass
|
||||
|
||||
if __debug__:
|
||||
|
||||
@ -437,7 +419,7 @@ class Text(ui.Component):
|
||||
self.on_render()
|
||||
finally:
|
||||
self.repaint = should_repaint
|
||||
return display_mock.screen_contents
|
||||
return [self.header_text] + display_mock.screen_contents
|
||||
|
||||
|
||||
LABEL_LEFT = const(0)
|
@ -1,7 +1,8 @@
|
||||
from micropython import const
|
||||
|
||||
from trezor import res, ui
|
||||
from trezor.ui.text import TEXT_HEADER_HEIGHT, TEXT_LINE_HEIGHT
|
||||
|
||||
from ...constants import TEXT_HEADER_HEIGHT, TEXT_LINE_HEIGHT
|
||||
|
||||
if False:
|
||||
from typing import Iterable, List, Union
|
@ -1,29 +1,21 @@
|
||||
from micropython import const
|
||||
|
||||
from trezor import loop, res, ui, utils
|
||||
from trezor.ui.button import (
|
||||
Button,
|
||||
ButtonAbort,
|
||||
ButtonCancel,
|
||||
ButtonConfirm,
|
||||
ButtonDefault,
|
||||
)
|
||||
from trezor.ui.loader import Loader, LoaderDefault
|
||||
|
||||
from ..common.confirm import CANCELLED, CONFIRMED, INFO, ConfirmBase
|
||||
from .button import Button, ButtonAbort, ButtonCancel, ButtonConfirm, ButtonDefault
|
||||
|
||||
if __debug__:
|
||||
from apps.debug import swipe_signal, confirm_signal
|
||||
|
||||
if False:
|
||||
from typing import Any, Optional, List, Tuple
|
||||
from trezor.ui.button import ButtonContent, ButtonStyleType
|
||||
from typing import Any, List, Tuple, Optional
|
||||
from .button import ButtonContent, ButtonStyleType
|
||||
from trezor.ui.loader import LoaderStyleType
|
||||
|
||||
CONFIRMED = object()
|
||||
CANCELLED = object()
|
||||
INFO = object()
|
||||
|
||||
|
||||
class Confirm(ui.Layout):
|
||||
class Confirm(ConfirmBase):
|
||||
DEFAULT_CONFIRM = res.load(ui.ICON_CONFIRM)
|
||||
DEFAULT_CONFIRM_STYLE = ButtonConfirm
|
||||
DEFAULT_CANCEL = res.load(ui.ICON_CANCEL)
|
||||
@ -38,8 +30,9 @@ class Confirm(ui.Layout):
|
||||
cancel_style: ButtonStyleType = DEFAULT_CANCEL_STYLE,
|
||||
major_confirm: bool = False,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.content = content
|
||||
button_confirm: Optional[Button] = None
|
||||
button_cancel: Optional[Button] = None
|
||||
|
||||
if confirm is not None:
|
||||
if cancel is None:
|
||||
@ -48,10 +41,8 @@ class Confirm(ui.Layout):
|
||||
area = ui.grid(13, cells_x=2)
|
||||
else:
|
||||
area = ui.grid(9, n_x=2)
|
||||
self.confirm: Optional[Button] = Button(area, confirm, confirm_style)
|
||||
self.confirm.on_click = self.on_confirm # type: ignore
|
||||
else:
|
||||
self.confirm = None
|
||||
button_confirm = Button(area, confirm, confirm_style)
|
||||
button_confirm.on_click = self.on_confirm # type: ignore
|
||||
|
||||
if cancel is not None:
|
||||
if confirm is None:
|
||||
@ -60,32 +51,10 @@ class Confirm(ui.Layout):
|
||||
area = ui.grid(12, cells_x=1)
|
||||
else:
|
||||
area = ui.grid(8, n_x=2)
|
||||
self.cancel: Optional[Button] = Button(area, cancel, cancel_style)
|
||||
self.cancel.on_click = self.on_cancel # type: ignore
|
||||
else:
|
||||
self.cancel = None
|
||||
button_cancel = Button(area, cancel, cancel_style)
|
||||
button_cancel.on_click = self.on_cancel # type: ignore
|
||||
|
||||
def dispatch(self, event: int, x: int, y: int) -> None:
|
||||
super().dispatch(event, x, y)
|
||||
self.content.dispatch(event, x, y)
|
||||
if self.confirm is not None:
|
||||
self.confirm.dispatch(event, x, y)
|
||||
if self.cancel is not None:
|
||||
self.cancel.dispatch(event, x, y)
|
||||
|
||||
def on_confirm(self) -> None:
|
||||
raise ui.Result(CONFIRMED)
|
||||
|
||||
def on_cancel(self) -> None:
|
||||
raise ui.Result(CANCELLED)
|
||||
|
||||
if __debug__:
|
||||
|
||||
def read_content(self) -> List[str]:
|
||||
return self.content.read_content()
|
||||
|
||||
def create_tasks(self) -> Tuple[loop.Task, ...]:
|
||||
return super().create_tasks() + (confirm_signal(),)
|
||||
super().__init__(content, button_confirm, button_cancel)
|
||||
|
||||
|
||||
class Pageable:
|
||||
@ -117,7 +86,7 @@ class ConfirmPageable(Confirm):
|
||||
self.pageable = pageable
|
||||
|
||||
async def handle_paging(self) -> None:
|
||||
from trezor.ui.swipe import SWIPE_HORIZONTAL, SWIPE_LEFT, SWIPE_RIGHT, Swipe
|
||||
from .swipe import SWIPE_HORIZONTAL, SWIPE_LEFT, SWIPE_RIGHT, Swipe
|
||||
|
||||
if self.pageable.is_first():
|
||||
directions = SWIPE_LEFT
|
@ -1,11 +1,13 @@
|
||||
from trezor import res, ui
|
||||
from trezor.ui.button import Button, ButtonConfirm
|
||||
from trezor.ui.confirm import CONFIRMED
|
||||
from trezor.ui.text import TEXT_LINE_HEIGHT, TEXT_MARGIN_LEFT, render_text
|
||||
|
||||
from ...constants import TEXT_LINE_HEIGHT, TEXT_MARGIN_LEFT
|
||||
from .button import Button, ButtonConfirm
|
||||
from .confirm import CONFIRMED
|
||||
from .text import render_text
|
||||
|
||||
if False:
|
||||
from typing import Type
|
||||
from trezor.ui.button import ButtonContent
|
||||
from .button import ButtonContent
|
||||
|
||||
|
||||
class DefaultInfoConfirm:
|
@ -1,6 +1,7 @@
|
||||
from trezor import ui
|
||||
from trezor.ui.button import Button
|
||||
from trezor.ui.text import LABEL_CENTER, Label
|
||||
|
||||
from .button import Button
|
||||
from .text import LABEL_CENTER, Label
|
||||
|
||||
|
||||
class NumInput(ui.Component):
|
@ -2,12 +2,13 @@ from micropython import const
|
||||
|
||||
from trezor import io, loop, res, ui, workflow
|
||||
from trezor.ui import display
|
||||
from trezor.ui.button import Button, ButtonClear, ButtonConfirm
|
||||
from trezor.ui.swipe import SWIPE_HORIZONTAL, SWIPE_LEFT, Swipe
|
||||
|
||||
from .button import Button, ButtonClear, ButtonConfirm
|
||||
from .swipe import SWIPE_HORIZONTAL, SWIPE_LEFT, Swipe
|
||||
|
||||
if False:
|
||||
from typing import Iterable, List, Optional, Tuple
|
||||
from trezor.ui.button import ButtonContent, ButtonStyleStateType
|
||||
from .button import ButtonContent, ButtonStyleStateType
|
||||
|
||||
SPACE = res.load(ui.ICON_SPACE)
|
||||
|
@ -3,13 +3,8 @@ from micropython import const
|
||||
from trezor import config, res, ui
|
||||
from trezor.crypto import random
|
||||
from trezor.ui import display
|
||||
from trezor.ui.button import (
|
||||
Button,
|
||||
ButtonCancel,
|
||||
ButtonClear,
|
||||
ButtonConfirm,
|
||||
ButtonMono,
|
||||
)
|
||||
|
||||
from .button import Button, ButtonCancel, ButtonClear, ButtonConfirm, ButtonMono
|
||||
|
||||
if False:
|
||||
from trezor import loop
|
@ -1,9 +1,10 @@
|
||||
from micropython import const
|
||||
|
||||
from trezor import loop, res, ui, utils
|
||||
from trezor.ui.button import Button, ButtonCancel, ButtonConfirm, ButtonDefault
|
||||
from trezor.ui.confirm import CANCELLED, CONFIRMED
|
||||
from trezor.ui.swipe import SWIPE_DOWN, SWIPE_UP, SWIPE_VERTICAL, Swipe
|
||||
|
||||
from .button import Button, ButtonCancel, ButtonConfirm, ButtonDefault
|
||||
from .confirm import CANCELLED, CONFIRMED
|
||||
from .swipe import SWIPE_DOWN, SWIPE_UP, SWIPE_VERTICAL, Swipe
|
||||
|
||||
if __debug__:
|
||||
from apps.debug import confirm_signal, swipe_signal, notify_layout_change
|
139
core/src/trezor/ui/components/tt/text.py
Normal file
139
core/src/trezor/ui/components/tt/text.py
Normal file
@ -0,0 +1,139 @@
|
||||
from micropython import const
|
||||
|
||||
from trezor import res, ui
|
||||
from trezor.ui import display, style
|
||||
|
||||
from ..common.text import ( # noqa: F401
|
||||
BR,
|
||||
BR_HALF,
|
||||
TEXT_MAX_LINES,
|
||||
Span,
|
||||
TextBase,
|
||||
render_text,
|
||||
)
|
||||
|
||||
if False:
|
||||
from typing import List
|
||||
|
||||
|
||||
def header(
|
||||
title: str,
|
||||
icon: str = style.ICON_DEFAULT,
|
||||
fg: int = style.FG,
|
||||
bg: int = style.BG,
|
||||
ifg: int = style.GREEN,
|
||||
) -> None:
|
||||
if icon is not None:
|
||||
display.icon(14, 15, res.load(icon), ifg, bg)
|
||||
display.text(44, 35, title, ui.BOLD, fg, bg)
|
||||
|
||||
|
||||
class Text(TextBase):
|
||||
def on_render(self) -> None:
|
||||
if self.repaint:
|
||||
header(
|
||||
self.header_text,
|
||||
self.header_icon,
|
||||
ui.TITLE_GREY,
|
||||
ui.BG,
|
||||
self.icon_color,
|
||||
)
|
||||
render_text(
|
||||
self.content,
|
||||
self.new_lines,
|
||||
self.max_lines,
|
||||
item_offset=self.content_offset,
|
||||
char_offset=self.char_offset,
|
||||
break_words=self.break_words,
|
||||
line_width=self.line_width,
|
||||
render_page_overflow=self.render_page_overflow,
|
||||
)
|
||||
self.repaint = False
|
||||
|
||||
|
||||
LABEL_LEFT = const(0)
|
||||
LABEL_CENTER = const(1)
|
||||
LABEL_RIGHT = const(2)
|
||||
|
||||
|
||||
class Label(ui.Component):
|
||||
def __init__(
|
||||
self,
|
||||
area: ui.Area,
|
||||
content: str,
|
||||
align: int = LABEL_LEFT,
|
||||
style: int = ui.NORMAL,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.area = area
|
||||
self.content = content
|
||||
self.align = align
|
||||
self.style = style
|
||||
|
||||
def on_render(self) -> None:
|
||||
if self.repaint:
|
||||
align = self.align
|
||||
ax, ay, aw, ah = self.area
|
||||
ui.display.bar(ax, ay, aw, ah, ui.BG)
|
||||
tx = ax + aw // 2
|
||||
ty = ay + ah // 2 + 8
|
||||
if align is LABEL_LEFT:
|
||||
ui.display.text(tx, ty, self.content, self.style, ui.FG, ui.BG)
|
||||
elif align is LABEL_CENTER:
|
||||
ui.display.text_center(tx, ty, self.content, self.style, ui.FG, ui.BG)
|
||||
elif align is LABEL_RIGHT:
|
||||
ui.display.text_right(tx, ty, self.content, self.style, ui.FG, ui.BG)
|
||||
self.repaint = False
|
||||
|
||||
if __debug__:
|
||||
|
||||
def read_content(self) -> List[str]:
|
||||
return [self.content]
|
||||
|
||||
|
||||
def text_center_trim_left(
|
||||
x: int, y: int, text: str, font: int = ui.NORMAL, width: int = ui.WIDTH - 16
|
||||
) -> None:
|
||||
if ui.display.text_width(text, font) <= width:
|
||||
ui.display.text_center(x, y, text, font, ui.FG, ui.BG)
|
||||
return
|
||||
|
||||
ELLIPSIS_WIDTH = ui.display.text_width("...", ui.BOLD)
|
||||
if width < ELLIPSIS_WIDTH:
|
||||
return
|
||||
|
||||
text_length = 0
|
||||
for i in range(1, len(text)):
|
||||
if ui.display.text_width(text[-i:], font) + ELLIPSIS_WIDTH > width:
|
||||
text_length = i - 1
|
||||
break
|
||||
|
||||
text_width = ui.display.text_width(text[-text_length:], font)
|
||||
x -= (text_width + ELLIPSIS_WIDTH) // 2
|
||||
ui.display.text(x, y, "...", ui.BOLD, ui.GREY, ui.BG)
|
||||
x += ELLIPSIS_WIDTH
|
||||
ui.display.text(x, y, text[-text_length:], font, ui.FG, ui.BG)
|
||||
|
||||
|
||||
def text_center_trim_right(
|
||||
x: int, y: int, text: str, font: int = ui.NORMAL, width: int = ui.WIDTH - 16
|
||||
) -> None:
|
||||
if ui.display.text_width(text, font) <= width:
|
||||
ui.display.text_center(x, y, text, font, ui.FG, ui.BG)
|
||||
return
|
||||
|
||||
ELLIPSIS_WIDTH = ui.display.text_width("...", ui.BOLD)
|
||||
if width < ELLIPSIS_WIDTH:
|
||||
return
|
||||
|
||||
text_length = 0
|
||||
for i in range(1, len(text)):
|
||||
if ui.display.text_width(text[:i], font) + ELLIPSIS_WIDTH > width:
|
||||
text_length = i - 1
|
||||
break
|
||||
|
||||
text_width = ui.display.text_width(text[:text_length], font)
|
||||
x -= (text_width + ELLIPSIS_WIDTH) // 2
|
||||
ui.display.text(x, y, text[:text_length], font, ui.FG, ui.BG)
|
||||
x += text_width
|
||||
ui.display.text(x, y, "...", ui.BOLD, ui.GREY, ui.BG)
|
@ -1,5 +1,6 @@
|
||||
from trezor import ui
|
||||
from trezor.ui.button import Button
|
||||
|
||||
from .button import Button
|
||||
|
||||
if False:
|
||||
from trezor import loop
|
8
core/src/trezor/ui/constants/__init__.py
Normal file
8
core/src/trezor/ui/constants/__init__.py
Normal file
@ -0,0 +1,8 @@
|
||||
from trezor import utils
|
||||
|
||||
if utils.MODEL == "1":
|
||||
from .t1 import * # noqa: F401,F403
|
||||
elif utils.MODEL == "T":
|
||||
from .tt import * # noqa: F401,F403
|
||||
else:
|
||||
raise ValueError("Unknown Trezor model")
|
7
core/src/trezor/ui/constants/t1.py
Normal file
7
core/src/trezor/ui/constants/t1.py
Normal file
@ -0,0 +1,7 @@
|
||||
from micropython import const
|
||||
|
||||
TEXT_HEADER_HEIGHT = const(13)
|
||||
TEXT_LINE_HEIGHT = const(9)
|
||||
TEXT_LINE_HEIGHT_HALF = const(4)
|
||||
TEXT_MARGIN_LEFT = const(0)
|
||||
TEXT_MAX_LINES = const(4)
|
7
core/src/trezor/ui/constants/tt.py
Normal file
7
core/src/trezor/ui/constants/tt.py
Normal file
@ -0,0 +1,7 @@
|
||||
from micropython import const
|
||||
|
||||
TEXT_HEADER_HEIGHT = const(48)
|
||||
TEXT_LINE_HEIGHT = const(26)
|
||||
TEXT_LINE_HEIGHT_HALF = const(13)
|
||||
TEXT_MARGIN_LEFT = const(14)
|
||||
TEXT_MAX_LINES = const(5)
|
@ -2,7 +2,8 @@ import mock
|
||||
from common import *
|
||||
|
||||
from trezor import ui
|
||||
from trezor.ui import text, display
|
||||
from trezor.ui import display
|
||||
from trezor.ui.components.common import text
|
||||
|
||||
if False:
|
||||
from typing import List, Tuple
|
||||
|
Loading…
Reference in New Issue
Block a user