Split into multi-menu

This commit is contained in:
2026-08-14 23:31:36 +02:00
parent 6c683e415f
commit 0fb87f2913
4 changed files with 105 additions and 57 deletions
+37 -17
View File
@@ -1,23 +1,49 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScreenMode {
CardDetail,
DexGrid,
use crate::navigation::{main_menu::MainMenu, navigation::Navigable, scan_menu::ScanMenu};
#[derive(Debug, Clone)]
pub enum Menu {
Main(MainMenu),
Scan(ScanMenu),
Settings,
}
#[derive(Debug, Clone, Copy)]
impl Navigable for Menu {
fn display(
&self,
display: &mut crate::display::primary_lcd::PrimaryLcdDisplay<'static>,
) -> impl core::future::Future<Output = ()> + Send {
async move {
match self {
Menu::Main(main_menu) => main_menu.display(display).await,
Menu::Scan(scan_menu) => scan_menu.display(display).await,
Menu::Settings => {}
}
}
}
fn handle_input(
&self,
input: crate::navigation::navigation::Action,
) -> impl core::future::Future<Output = Self> + Send {
async move {
match self {
Menu::Main(main_menu) => main_menu.handle_input(input).await,
Menu::Scan(scan_menu) => scan_menu.handle_input(input).await,
Menu::Settings => Self::Settings,
}
}
}
}
#[derive(Debug, Clone)]
pub struct NavigationState {
pub current_screen: ScreenMode,
pub card_index: usize,
pub use_first_payload: bool,
pub current_screen: Menu,
}
impl Default for NavigationState {
fn default() -> Self {
Self {
current_screen: ScreenMode::CardDetail,
card_index: 0,
use_first_payload: true,
current_screen: Menu::Main(MainMenu { selected: 0 }),
}
}
}
@@ -26,10 +52,4 @@ impl NavigationState {
pub fn new() -> Self {
Self::default()
}
pub fn toggle_payload(&mut self) -> bool {
let current = self.use_first_payload;
self.use_first_payload = !self.use_first_payload;
current
}
}