53 lines
1.3 KiB
Rust
53 lines
1.3 KiB
Rust
use crate::drivers::primary_lcd::PrimaryDisplayError;
|
|
use crate::peripherals::Peripherals;
|
|
use alloc::boxed::Box;
|
|
use core::error;
|
|
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},
|
|
outputs::Outputs,
|
|
},
|
|
views::view::View,
|
|
};
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct JournalView {
|
|
pub cards: Vec<Card>,
|
|
pub selected_card: usize,
|
|
}
|
|
|
|
impl Navigable for JournalView {
|
|
fn display(
|
|
&self,
|
|
outputs: &mut Outputs,
|
|
_: &Peripherals,
|
|
) -> impl core::future::Future<Output = Result<(), Box<dyn error::Error>>> + Send {
|
|
async move {
|
|
outputs
|
|
.primary_display
|
|
.clear(Rgb565::BLACK)
|
|
.map_err(PrimaryDisplayError::from)?;
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|