mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-27 02:12:35 +00:00
refactor(core/ui): get rid of confirm_wipe
This commit is contained in:
parent
c0174ff217
commit
da72482c2f
@ -1,12 +1,27 @@
|
|||||||
import storage
|
import storage
|
||||||
|
from trezor import ui
|
||||||
|
from trezor.messages import ButtonRequestType
|
||||||
from trezor.messages.Success import Success
|
from trezor.messages.Success import Success
|
||||||
from trezor.ui.layouts import confirm_wipe
|
from trezor.ui.layouts import confirm_action
|
||||||
|
|
||||||
from .apply_settings import reload_settings_from_storage
|
from .apply_settings import reload_settings_from_storage
|
||||||
|
|
||||||
|
|
||||||
async def wipe_device(ctx, msg):
|
async def wipe_device(ctx, msg):
|
||||||
await confirm_wipe(ctx)
|
await confirm_action(
|
||||||
|
ctx,
|
||||||
|
"confirm_wipe",
|
||||||
|
title="Wipe device",
|
||||||
|
description="Do you really want to\nwipe the device?\n",
|
||||||
|
action="All data will be lost.",
|
||||||
|
reverse=True,
|
||||||
|
verb="Hold to confirm",
|
||||||
|
hold=True,
|
||||||
|
hold_danger=True,
|
||||||
|
icon=ui.ICON_WIPE,
|
||||||
|
icon_color=ui.RED,
|
||||||
|
br_code=ButtonRequestType.WipeDevice,
|
||||||
|
)
|
||||||
|
|
||||||
storage.wipe()
|
storage.wipe()
|
||||||
reload_settings_from_storage()
|
reload_settings_from_storage()
|
||||||
|
@ -43,7 +43,6 @@ if False:
|
|||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
"confirm_action",
|
"confirm_action",
|
||||||
"confirm_wipe",
|
|
||||||
"confirm_reset_device",
|
"confirm_reset_device",
|
||||||
"confirm_backup",
|
"confirm_backup",
|
||||||
"confirm_path_warning",
|
"confirm_path_warning",
|
||||||
@ -79,13 +78,13 @@ async def confirm_action(
|
|||||||
verb: Union[str, bytes, None] = Confirm.DEFAULT_CONFIRM,
|
verb: Union[str, bytes, None] = Confirm.DEFAULT_CONFIRM,
|
||||||
verb_cancel: Union[str, bytes, None] = Confirm.DEFAULT_CANCEL,
|
verb_cancel: Union[str, bytes, None] = Confirm.DEFAULT_CANCEL,
|
||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
|
hold_danger: bool = False,
|
||||||
icon: str = None, # TODO cleanup @ redesign
|
icon: str = None, # TODO cleanup @ redesign
|
||||||
icon_color: int = None, # TODO cleanup @ redesign
|
icon_color: int = None, # TODO cleanup @ redesign
|
||||||
reverse: bool = False, # TODO cleanup @ redesign
|
reverse: bool = False, # TODO cleanup @ redesign
|
||||||
larger_vspace: bool = False, # TODO cleanup @ redesign
|
larger_vspace: bool = False, # TODO cleanup @ redesign
|
||||||
exc: ExceptionType = wire.ActionCancelled,
|
exc: ExceptionType = wire.ActionCancelled,
|
||||||
br_code: EnumTypeButtonRequestType = ButtonRequestType.Other,
|
br_code: EnumTypeButtonRequestType = ButtonRequestType.Other,
|
||||||
**kwargs: Any,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
text = Text(
|
text = Text(
|
||||||
title,
|
title,
|
||||||
@ -118,10 +117,13 @@ async def confirm_action(
|
|||||||
)
|
)
|
||||||
|
|
||||||
cls = HoldToConfirm if hold else Confirm
|
cls = HoldToConfirm if hold else Confirm
|
||||||
|
kwargs = {}
|
||||||
|
if hold_danger:
|
||||||
|
kwargs = {"loader_style": LoaderDanger, "confirm_style": ButtonCancel}
|
||||||
await raise_if_cancelled(
|
await raise_if_cancelled(
|
||||||
interact(
|
interact(
|
||||||
ctx,
|
ctx,
|
||||||
cls(text, confirm=verb, cancel=verb_cancel),
|
cls(text, confirm=verb, cancel=verb_cancel, **kwargs),
|
||||||
br_type,
|
br_type,
|
||||||
br_code,
|
br_code,
|
||||||
),
|
),
|
||||||
@ -129,21 +131,6 @@ async def confirm_action(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# TODO cleanup @ redesign
|
|
||||||
async def confirm_wipe(ctx: wire.GenericContext) -> None:
|
|
||||||
text = Text("Wipe device", ui.ICON_WIPE, ui.RED)
|
|
||||||
text.normal("Do you really want to", "wipe the device?", "")
|
|
||||||
text.bold("All data will be lost.")
|
|
||||||
await raise_if_cancelled(
|
|
||||||
interact(
|
|
||||||
ctx,
|
|
||||||
HoldToConfirm(text, confirm_style=ButtonCancel, loader_style=LoaderDanger),
|
|
||||||
"wipe_device",
|
|
||||||
ButtonRequestType.WipeDevice,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def confirm_reset_device(ctx: wire.GenericContext, prompt: str) -> None:
|
async def confirm_reset_device(ctx: wire.GenericContext, prompt: str) -> None:
|
||||||
text = Text("Create new wallet", ui.ICON_RESET, new_lines=False)
|
text = Text("Create new wallet", ui.ICON_RESET, new_lines=False)
|
||||||
text.bold(prompt)
|
text.bold(prompt)
|
||||||
|
Loading…
Reference in New Issue
Block a user