use crate::model::ProjectIndex;
use ratatui::widgets::{ListState, TableState};
mod filter;
mod navigation;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum View {
#[default]
Dashboard,
RfcList,
AdrList,
WorkList,
RfcDetail(usize),
AdrDetail(usize),
WorkDetail(usize),
ClauseDetail(usize, usize),
}
pub struct App {
pub index: ProjectIndex,
pub view: View,
pub selected: usize,
pub table_state: TableState,
pub clause_list_state: ListState,
pub scroll: u16,
pub content_height: u16,
pub filter_query: String,
cached_indices: Vec<usize>,
indices_dirty: bool,
pub filter_mode: bool,
pub show_help: bool,
pub should_quit: bool,
}
impl App {
pub fn new(mut index: ProjectIndex) -> Self {
index.rfcs.sort_by(|a, b| a.rfc.rfc_id.cmp(&b.rfc.rfc_id));
index.adrs.sort_by(|a, b| a.meta().id.cmp(&b.meta().id));
index
.work_items
.sort_by(|a, b| a.meta().id.cmp(&b.meta().id));
Self {
index,
view: View::Dashboard,
selected: 0,
table_state: TableState::default().with_selected(Some(0)),
clause_list_state: ListState::default().with_selected(Some(0)),
scroll: 0,
content_height: 0,
filter_query: String::new(),
cached_indices: Vec::new(),
indices_dirty: true,
filter_mode: false,
show_help: false,
should_quit: false,
}
}
}