コード例 #1
0
async def confirm(
    ctx: wire.GenericContext,
    content: ui.Component,
    code: EnumTypeButtonRequestType = ButtonRequestType.Other,
    confirm: ButtonContent | None = Confirm.DEFAULT_CONFIRM,
    confirm_style: ButtonStyleType = Confirm.DEFAULT_CONFIRM_STYLE,
    cancel: ButtonContent | None = Confirm.DEFAULT_CANCEL,
    cancel_style: ButtonStyleType = Confirm.DEFAULT_CANCEL_STYLE,
    major_confirm: bool = False,
) -> bool:
    await button_request(ctx, code=code)

    if content.__class__.__name__ == "Paginated":
        # The following works because asserts are omitted in non-debug builds.
        # IOW if the assert runs, that means __debug__ is True and Paginated is imported
        assert isinstance(content, Paginated)

        content.pages[-1] = Confirm(
            content.pages[-1],
            confirm,
            confirm_style,
            cancel,
            cancel_style,
            major_confirm,
        )
        dialog: ui.Layout = content
    else:
        dialog = Confirm(content, confirm, confirm_style, cancel, cancel_style,
                         major_confirm)

    return await ctx.wait(dialog) is CONFIRMED
コード例 #2
0
ファイル: confirm.py プロジェクト: tomtau/trezor-firmware
async def confirm(
    ctx: wire.Context,
    content: ui.Component,
    code: int = ButtonRequestType.Other,
    confirm: ButtonContent = Confirm.DEFAULT_CONFIRM,
    confirm_style: ButtonStyleType = Confirm.DEFAULT_CONFIRM_STYLE,
    cancel: ButtonContent = Confirm.DEFAULT_CANCEL,
    cancel_style: ButtonStyleType = Confirm.DEFAULT_CANCEL_STYLE,
    major_confirm: bool = False,
) -> bool:
    await ctx.call(ButtonRequest(code=code), ButtonAck)

    if content.__class__.__name__ == "Paginated":
        content.pages[-1] = Confirm(
            content.pages[-1],
            confirm,
            confirm_style,
            cancel,
            cancel_style,
            major_confirm,
        )
        dialog = content
    else:
        dialog = Confirm(content, confirm, confirm_style, cancel, cancel_style,
                         major_confirm)

    if __debug__:
        return await ctx.wait(dialog, confirm_signal()) is CONFIRMED
    else:
        return await ctx.wait(dialog) is CONFIRMED
コード例 #3
0
ファイル: confirm.py プロジェクト: tomtau/trezor-firmware
async def hold_to_confirm(
    ctx: wire.Context,
    content: ui.Component,
    code: int = ButtonRequestType.Other,
    confirm: ButtonContent = HoldToConfirm.DEFAULT_CONFIRM,
    confirm_style: ButtonStyleType = HoldToConfirm.DEFAULT_CONFIRM_STYLE,
    loader_style: LoaderStyleType = HoldToConfirm.DEFAULT_LOADER_STYLE,
) -> bool:
    await ctx.call(ButtonRequest(code=code), ButtonAck)

    if content.__class__.__name__ == "Paginated":
        content.pages[-1] = HoldToConfirm(content.pages[-1], confirm,
                                          confirm_style, loader_style)
        dialog = content
    else:
        dialog = HoldToConfirm(content, confirm, confirm_style, loader_style)

    if __debug__:
        return await ctx.wait(dialog, confirm_signal()) is CONFIRMED
    else:
        return await ctx.wait(dialog) is CONFIRMED
コード例 #4
0
async def hold_to_confirm(
    ctx: wire.GenericContext,
    content: ui.Component,
    code: EnumTypeButtonRequestType = ButtonRequestType.Other,
    confirm: str = HoldToConfirm.DEFAULT_CONFIRM,
    confirm_style: ButtonStyleType = HoldToConfirm.DEFAULT_CONFIRM_STYLE,
    loader_style: LoaderStyleType = HoldToConfirm.DEFAULT_LOADER_STYLE,
) -> bool:
    await ctx.call(ButtonRequest(code=code), ButtonAck)

    if content.__class__.__name__ == "Paginated":
        # The following works because asserts are omitted in non-debug builds.
        # IOW if the assert runs, that means __debug__ is True and Paginated is imported
        assert isinstance(content, Paginated)

        content.pages[-1] = HoldToConfirm(
            content.pages[-1], confirm, confirm_style, loader_style
        )
        dialog = content  # type: ui.Layout
    else:
        dialog = HoldToConfirm(content, confirm, confirm_style, loader_style)

    return await ctx.wait(dialog) is CONFIRMED