parent
56ee7d33a9
commit
cb7152542d
@ -1,49 +0,0 @@
|
||||
import trezor.messages.DebugLinkShowTextStyle as S
|
||||
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.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import confirm
|
||||
|
||||
STYLES = {
|
||||
S.NORMAL: ui.NORMAL,
|
||||
S.BOLD: ui.BOLD,
|
||||
S.MONO: ui.MONO,
|
||||
S.BR: text.BR,
|
||||
S.BR_HALF: text.BR_HALF,
|
||||
}
|
||||
|
||||
|
||||
async def show_text(ctx: wire.Context, msg: DebugLinkShowText) -> Success:
|
||||
if msg.header_icon is not None:
|
||||
icon_name = "ICON_" + msg.header_icon
|
||||
icon = getattr(style, icon_name)
|
||||
if not isinstance(icon, str):
|
||||
raise wire.DataError("Invalid icon name: {}".format(msg.header_icon))
|
||||
else:
|
||||
icon = style.ICON_DEFAULT
|
||||
|
||||
if msg.icon_color is not None:
|
||||
color = getattr(style, msg.icon_color)
|
||||
if not isinstance(color, int):
|
||||
raise wire.DataError("Invalid color name: {}".format(msg.icon_color))
|
||||
else:
|
||||
color = style.ORANGE_ICON
|
||||
|
||||
dlg = Text(msg.header_text, icon, color, new_lines=False)
|
||||
for item in msg.body_text:
|
||||
if item.style in STYLES:
|
||||
dlg.content.append(STYLES[item.style])
|
||||
elif item.style == S.SET_COLOR:
|
||||
color = getattr(style, item.content)
|
||||
if not isinstance(color, int):
|
||||
raise wire.DataError("Invalid color name: {}".format(item.content))
|
||||
dlg.content.append(color)
|
||||
|
||||
elif item.content is not None:
|
||||
dlg.content.append(item.content)
|
||||
|
||||
await confirm(ctx, dlg)
|
||||
return Success("text shown")
|
@ -1,38 +0,0 @@
|
||||
# Automatically generated by pb2py
|
||||
# fmt: off
|
||||
import protobuf as p
|
||||
|
||||
from .DebugLinkShowTextItem import DebugLinkShowTextItem
|
||||
|
||||
if __debug__:
|
||||
try:
|
||||
from typing import Dict, List # noqa: F401
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
class DebugLinkShowText(p.MessageType):
|
||||
MESSAGE_WIRE_TYPE = 9004
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
body_text: List[DebugLinkShowTextItem] = None,
|
||||
header_text: str = None,
|
||||
header_icon: str = None,
|
||||
icon_color: str = None,
|
||||
) -> None:
|
||||
self.body_text = body_text if body_text is not None else []
|
||||
self.header_text = header_text
|
||||
self.header_icon = header_icon
|
||||
self.icon_color = icon_color
|
||||
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict:
|
||||
return {
|
||||
1: ('header_text', p.UnicodeType, None),
|
||||
2: ('body_text', DebugLinkShowTextItem, p.FLAG_REPEATED),
|
||||
3: ('header_icon', p.UnicodeType, None),
|
||||
4: ('icon_color', p.UnicodeType, None),
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
# Automatically generated by pb2py
|
||||
# fmt: off
|
||||
import protobuf as p
|
||||
|
||||
if __debug__:
|
||||
try:
|
||||
from typing import Dict, List # noqa: F401
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
EnumTypeDebugLinkShowTextStyle = Literal[0, 1, 2, 4, 5, 6]
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
class DebugLinkShowTextItem(p.MessageType):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
style: EnumTypeDebugLinkShowTextStyle = None,
|
||||
content: str = None,
|
||||
) -> None:
|
||||
self.style = style
|
||||
self.content = content
|
||||
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict:
|
||||
return {
|
||||
1: ('style', p.EnumType("DebugLinkShowTextStyle", (0, 1, 2, 4, 5, 6)), None),
|
||||
2: ('content', p.UnicodeType, None),
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Automatically generated by pb2py
|
||||
# fmt: off
|
||||
if __debug__:
|
||||
try:
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
NORMAL: Literal[0] = 0
|
||||
BOLD: Literal[1] = 1
|
||||
MONO: Literal[2] = 2
|
||||
BR: Literal[4] = 4
|
||||
BR_HALF: Literal[5] = 5
|
||||
SET_COLOR: Literal[6] = 6
|
@ -1,38 +0,0 @@
|
||||
# Automatically generated by pb2py
|
||||
# fmt: off
|
||||
from .. import protobuf as p
|
||||
|
||||
from .DebugLinkShowTextItem import DebugLinkShowTextItem
|
||||
|
||||
if __debug__:
|
||||
try:
|
||||
from typing import Dict, List # noqa: F401
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
class DebugLinkShowText(p.MessageType):
|
||||
MESSAGE_WIRE_TYPE = 9004
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
body_text: List[DebugLinkShowTextItem] = None,
|
||||
header_text: str = None,
|
||||
header_icon: str = None,
|
||||
icon_color: str = None,
|
||||
) -> None:
|
||||
self.body_text = body_text if body_text is not None else []
|
||||
self.header_text = header_text
|
||||
self.header_icon = header_icon
|
||||
self.icon_color = icon_color
|
||||
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict:
|
||||
return {
|
||||
1: ('header_text', p.UnicodeType, None),
|
||||
2: ('body_text', DebugLinkShowTextItem, p.FLAG_REPEATED),
|
||||
3: ('header_icon', p.UnicodeType, None),
|
||||
4: ('icon_color', p.UnicodeType, None),
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
# Automatically generated by pb2py
|
||||
# fmt: off
|
||||
from .. import protobuf as p
|
||||
|
||||
if __debug__:
|
||||
try:
|
||||
from typing import Dict, List # noqa: F401
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
EnumTypeDebugLinkShowTextStyle = Literal[0, 1, 2, 4, 5, 6]
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
class DebugLinkShowTextItem(p.MessageType):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
style: EnumTypeDebugLinkShowTextStyle = None,
|
||||
content: str = None,
|
||||
) -> None:
|
||||
self.style = style
|
||||
self.content = content
|
||||
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict:
|
||||
return {
|
||||
1: ('style', p.EnumType("DebugLinkShowTextStyle", (0, 1, 2, 4, 5, 6)), None),
|
||||
2: ('content', p.UnicodeType, None),
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Automatically generated by pb2py
|
||||
# fmt: off
|
||||
if __debug__:
|
||||
try:
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
NORMAL: Literal[0] = 0
|
||||
BOLD: Literal[1] = 1
|
||||
MONO: Literal[2] = 2
|
||||
BR: Literal[4] = 4
|
||||
BR_HALF: Literal[5] = 5
|
||||
SET_COLOR: Literal[6] = 6
|
Loading…
Reference in new issue