Implemented Scan card menu
This commit was merged in pull request #29.
This commit is contained in:
+16
-10
@@ -9,12 +9,12 @@ use crate::views::card_view::CardView;
|
||||
use crate::views::journal_view::JournalView;
|
||||
use crate::views::{menu_item, settings_menu::SettingsMenu, view::View};
|
||||
|
||||
use crate::navigation::navigation::{Action, Navigable};
|
||||
use crate::navigation::navigation::{Action, Navigable, NewState};
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
use embedded_graphics::prelude::RgbColor;
|
||||
use embedded_graphics_core::draw_target::DrawTarget;
|
||||
|
||||
pub const MAX_SELECTED: i32 = 3;
|
||||
pub const MAX_SELECTED: i32 = 4;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MainMenu {
|
||||
@@ -28,14 +28,15 @@ impl Navigable for MainMenu {
|
||||
) -> impl core::future::Future<Output = ()> + Send {
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
menu_item::show(display, "Last card", 0, self.selected);
|
||||
menu_item::show(display, "Journal", 1, self.selected);
|
||||
menu_item::show(display, "Settings", 2, self.selected);
|
||||
menu_item::show(display, "Scan card", 0, self.selected);
|
||||
menu_item::show(display, "Last card", 1, self.selected);
|
||||
menu_item::show(display, "Journal", 2, self.selected);
|
||||
menu_item::show(display, "Settings", 3, self.selected);
|
||||
|
||||
core::future::ready(())
|
||||
}
|
||||
|
||||
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = View> + Send {
|
||||
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = NewState> + Send {
|
||||
let card_mock1 = Card::try_from(split_nfc_hex(&MOCK_PAYLOAD3).unwrap()).unwrap();
|
||||
let card_mock2 = Card::try_from(split_nfc_hex(&MOCK_PAYLOAD2).unwrap()).unwrap();
|
||||
|
||||
@@ -57,17 +58,22 @@ impl Navigable for MainMenu {
|
||||
})
|
||||
}
|
||||
Action::Ok => match self.selected {
|
||||
0 => View::Card(CardView { card: card_mock1 }),
|
||||
1 => View::Journal(JournalView {
|
||||
0 => View::Scan(crate::views::scan_menu::ScanMenu { progress: 0 }),
|
||||
1 => View::Card(CardView { card: card_mock1 }),
|
||||
2 => View::Journal(JournalView {
|
||||
cards: vec![card_mock1, card_mock2],
|
||||
selected_card: 0,
|
||||
}),
|
||||
2 => View::Settings(SettingsMenu { selected: 0 }),
|
||||
3 => View::Settings(SettingsMenu { selected: 0 }),
|
||||
_ => View::Main(self.clone()),
|
||||
},
|
||||
_ => View::Main(self.clone()),
|
||||
};
|
||||
|
||||
future::ready(new_menu)
|
||||
future::ready(NewState {
|
||||
replace_view: matches!(new_menu, View::Main(_)),
|
||||
view: new_menu,
|
||||
redraw: !matches!(input, Action::Timer),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user