|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <ToastView.h>
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 |
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.
|
strong |
| Enumerator | |
|---|---|
| NONE | |
| SUCCESS | |
| ERROR | |
| INFO | |
| TASK | |
| ALERT | |
Definition at line 22 of file ToastView.h.
|
inlineoverridevirtual |
| 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
| message | Text to display (copied internally) |
| icon | Icon type |
| durationMs | Display duration (0 = until dismissed) |
| message | Toast message text. |
| icon | Icon type to display. |
| durationMs | Auto-dismiss duration in milliseconds. |
| dismissible | Whether key presses can dismiss the toast. |
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().
|
inline |
Check if toast should be dismissed
Definition at line 43 of file ToastView.h.
|
overridevirtual |
Handles key input for optional toast dismissal.
| key | Pressed key code. |
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.
|
overridevirtual |
Updates auto-dismiss timeout state.
| nowMs | Current monotonic time in milliseconds. |
Reimplemented from cdc::ui::IView.
Definition at line 47 of file ToastView.cpp.
References cdc::ui::ViewStack::hideModal(), and cdc::ui::ViewStack::instance().
|
overridevirtual |
Renders the toast overlay.
| partial | Indicates partial/full redraw mode. |
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.