Files
creaturedex/src/views/journal_view.rs
T

42 lines
1.0 KiB
Rust

use core::future;
use alloc::vec::Vec;
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::RgbColor;
use embedded_graphics_core::draw_target::DrawTarget;
use crate::{
card::model::Card,
navigation::navigation::{Action, Navigable, NewState},
views::view::View,
};
#[derive(Debug, Clone)]
pub struct JournalView {
pub cards: Vec<Card>,
pub selected_card: usize,
}
impl Navigable for JournalView {
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
where
D: DrawTarget<Color = Rgb565>,
D::Error: core::fmt::Debug,
{
display.clear(Rgb565::BLACK).unwrap();
core::future::ready(())
}
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = NewState> + Send {
let new_state = NewState {
view: View::Journal(self.clone()),
replace_view: true,
redraw: !matches!(input, Action::Timer),
};
future::ready(new_state)
}
}