pub mod browse;
pub mod doc_meta;
pub mod editor;
pub mod onboarding;
pub mod overlay_host;
pub mod panel_set;
pub mod preferences;
pub mod start;
use async_trait::async_trait;
use ratatui::Frame;
use kimun_core::nfs::VaultPath;
use crate::components::event_state::EventState;
use crate::components::events::{AppEvent, AppTx, InputEvent};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScreenKind {
Start,
Browse,
Editor,
Onboarding,
Preferences,
}
#[async_trait(?Send)]
pub trait AppScreen {
async fn on_enter(&mut self, _tx: &AppTx) {}
fn handle_input(&mut self, event: &InputEvent, tx: &AppTx) -> EventState;
fn render(&mut self, f: &mut Frame);
async fn handle_app_message(&mut self, _msg: AppEvent, _tx: &AppTx) {}
async fn try_open_path(
&mut self,
path: VaultPath,
_emphasis: Option<Vec<String>>,
_tx: &AppTx,
) -> Option<VaultPath> {
Some(path)
}
fn get_kind(&self) -> ScreenKind;
async fn on_exit(&mut self, _tx: &AppTx) {}
}
#[cfg(test)]
mod tests {
use tokio::sync::mpsc::unbounded_channel;
use std::sync::{Arc, RwLock};
use super::*;
use crate::app_screen::preferences::PreferencesScreen;
use crate::settings::AppSettings;
fn shared_defaults() -> crate::settings::SharedSettings {
Arc::new(RwLock::new(AppSettings::default()))
}
#[tokio::test]
async fn on_exit_default_is_noop() {
let (tx, _rx) = unbounded_channel::<AppEvent>();
let mut screen = PreferencesScreen::new(shared_defaults());
screen.on_exit(&tx).await; }
}