示例#1
0
async def hold_to_confirm(
    ctx: wire.Context,
    content: ui.Layout,
    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)

    if __debug__:
        return await ctx.wait(dialog, confirm_signal()) is CONFIRMED
    else:
        return await ctx.wait(dialog) is CONFIRMED
示例#2
0
async def hold_to_confirm(
    ctx,
    content,
    code=ButtonRequestType.Other,
    confirm=HoldToConfirm.DEFAULT_CONFIRM,
    confirm_style=HoldToConfirm.DEFAULT_CONFIRM_STYLE,
    loader_style=HoldToConfirm.DEFAULT_LOADER_STYLE,
):
    await ctx.call(ButtonRequest(code=code), MessageType.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
示例#3
0
async def hold_to_confirm(
    ctx: wire.Context,
    content: ui.Control,
    code: int = ButtonRequestType.Other,
    confirm: ButtonContent = Confirm.DEFAULT_CONFIRM,
    confirm_style: ButtonStyleType = Confirm.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