diff --git a/crates/notedeck_columns/src/route.rs b/crates/notedeck_columns/src/route.rs index ca0c782e..41d20714 100644 --- a/crates/notedeck_columns/src/route.rs +++ b/crates/notedeck_columns/src/route.rs @@ -361,3 +361,40 @@ impl fmt::Display for Route { } } } + +#[derive(Clone, Debug)] +pub struct SingletonRouter { + route: Option, + pub returning: bool, + pub navigating: bool, +} + +impl SingletonRouter { + pub fn route_to(&mut self, route: R) { + self.navigating = true; + self.route = Some(route); + } + + pub fn go_back(&mut self) { + self.returning = true; + } + + pub fn clear(&mut self) { + self.route = None; + self.returning = false; + } + + pub fn route(&self) -> &Option { + &self.route + } +} + +impl Default for SingletonRouter { + fn default() -> Self { + Self { + route: None, + returning: false, + navigating: false, + } + } +}