CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::ui::ToastView Class Reference

#include <ToastView.h>

Inheritance diagram for cdc::ui::ToastView:
cdc::ui::ViewBase cdc::ui::IView

Public Types

enum class  Icon : uint8_t {
  NONE = 0 , SUCCESS , ERROR , INFO ,
  TASK , ALERT
}

Public Member Functions

void init (const char *message, Icon icon=Icon::NONE, uint16_t durationMs=1500, bool dismissible=true)
 Initializes toast message content and timing behavior.
bool isExpired () const
void render (bool partial) override
 Renders the toast overlay.
InputResult onKey (char key) override
 Handles key input for optional toast dismissal.
void onTick (uint32_t nowMs) override
 Updates auto-dismiss timeout state.
const char * getName () const override
Public Member Functions inherited from cdc::ui::ViewBase
virtual ~ViewBase ()=default
void onEnter (void *context) override
void onExit () override
void onResume () override
void onPause () override
void setLifecycleHooks (void(*onHide)(void *), void(*onShow)(void *), void *userData) override
bool needsRender () const override
void markDirty () override
void clearDirty () override
void setFooterHint (const char *hint) override
const char * getFooterHint () const override
Public Member Functions inherited from cdc::ui::IView
virtual ~IView ()=default
virtual bool prefersLightRefresh () const
virtual InputResult onLongPress (char key)

Additional Inherited Members

Protected Member Functions inherited from cdc::ui::ViewBase
void setTitle (const char *title)
const char * getTitle () const
Protected Attributes inherited from cdc::ui::ViewBase
bool dirty_ = true
const char * title_ = nullptr
const char * customFooter_ = nullptr
void(* onHide_ )(void *) = nullptr
void(* onShow_ )(void *) = nullptr
void * lifecycleUserData_ = nullptr

Detailed Description

ToastView - Temporary overlay message

Shows a centered message box with optional icon. Auto-dismisses after timeout or on Y/N key press.

Icons: NONE = No icon SUCCESS = Checkmark ERROR = X mark INFO = (i) icon

Definition at line 20 of file ToastView.h.

Member Enumeration Documentation

◆ Icon

enum class cdc::ui::ToastView::Icon : uint8_t
strong
Enumerator
NONE 
SUCCESS 
ERROR 
INFO 
TASK 
ALERT 

Definition at line 22 of file ToastView.h.

Member Function Documentation

◆ getName()

const char * cdc::ui::ToastView::getName ( ) const
inlineoverridevirtual

Get view name for debugging

Implements cdc::ui::IView.

Definition at line 49 of file ToastView.h.

◆ init()

void cdc::ui::ToastView::init ( const char * message,
Icon icon = Icon::NONE,
uint16_t durationMs = 1500,
bool dismissible = true )

Initializes toast message content and timing behavior.

Initialize toast with message and settings

Parameters
messageText to display (copied internally)
iconIcon type
durationMsDisplay duration (0 = until dismissed)
messageToast message text.
iconIcon type to display.
durationMsAuto-dismiss duration in milliseconds.
dismissibleWhether key presses can dismiss the toast.
Returns
void

Definition at line 26 of file ToastView.cpp.

References cdc::ui::ViewBase::dirty_.

Referenced by host_ui_push_toast(), and cdc::plugin_manager::PluginManager::startPlugin().

◆ isExpired()

bool cdc::ui::ToastView::isExpired ( ) const
inline

Check if toast should be dismissed

Definition at line 43 of file ToastView.h.

◆ onKey()

InputResult cdc::ui::ToastView::onKey ( char key)
overridevirtual

Handles key input for optional toast dismissal.

Parameters
keyPressed key code.
Returns
Input handling result for the view stack.

Implements cdc::ui::IView.

Definition at line 64 of file ToastView.cpp.

References cdc::ui::CONSUMED, cdc::ui::ViewStack::hideModal(), cdc::ui::IGNORED, cdc::ui::ViewStack::instance(), cdc::ui::KEY_NO, and cdc::ui::KEY_YES.

◆ onTick()

void cdc::ui::ToastView::onTick ( uint32_t nowMs)
overridevirtual

Updates auto-dismiss timeout state.

Parameters
nowMsCurrent monotonic time in milliseconds.
Returns
void

Reimplemented from cdc::ui::IView.

Definition at line 47 of file ToastView.cpp.

References cdc::ui::ViewStack::hideModal(), and cdc::ui::ViewStack::instance().

◆ render()

void cdc::ui::ToastView::render ( bool partial)
overridevirtual

Renders the toast overlay.

Parameters
partialIndicates partial/full redraw mode.
Returns
void

Implements cdc::ui::IView.

Definition at line 79 of file ToastView.cpp.

References ALERT, cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::ui::render::drawDialogFrame(), ERROR, cdc::hal::getDisplayInstance(), INFO, NONE, cdc::ui::render::printTruncated(), SUCCESS, and TASK.


The documentation for this class was generated from the following files: