use iced::{widget::Text, Element}; use crate::{gui::components::navigation, traits::Focusable}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum View { Balances, Buckets, Transactions, } impl View { pub const VIEW_1: View = View::Buckets; pub const VIEW_2: View = View::Balances; pub const VIEW_3: View = View::Transactions; pub fn views() -> Vec { vec![Self::VIEW_1, Self::VIEW_2, Self::VIEW_3] } pub const fn name(self) -> &'static str { match self { View::Balances => "balances", View::Buckets => "buckets", View::Transactions => "transactions", } } pub fn next(&self) -> View { match *self { Self::VIEW_1 => Self::VIEW_2, Self::VIEW_2 | Self::VIEW_3 => Self::VIEW_3, } } pub fn prev(&self) -> View { match *self { Self::VIEW_1 | Self::VIEW_2 => Self::VIEW_1, Self::VIEW_3 => Self::VIEW_2, } } } impl<'a> From<&'a View> for Element<'a, navigation::Message> { fn from(val: &'a View) -> Self { Text::new(val.name()).into() } } impl Focusable for View { fn focus(&mut self) {} fn unfocus(&mut self) {} }