use ratatui::{
layout::{Constraint, Direction, Layout},
Frame,
};
use crate::app::{App, InputMode};
use crate::passphrase;
use crate::settings;
use crate::tasks;
use crate::whats_new;
use super::top_bar::draw_top_bar;
use super::bottom_bar::draw_bottom_bar;
use super::drawers::{draw_timeline, draw_weekly_stats};
use super::main_element::{draw_entries, draw_suggestions_modal, draw_operations_menu, draw_hotkeys};
pub fn draw_dashboard(f: &mut Frame, app: &App) {
if matches!(app.input_mode, InputMode::PassphrasePrompt { .. }) {
passphrase::draw_passphrase_prompt(f, app);
return;
}
if matches!(app.input_mode, InputMode::PassphraseChange { .. }) {
passphrase::draw_passphrase_change(f, app);
return;
}
if matches!(app.input_mode, InputMode::Settings { .. }) {
settings::draw_settings(f, app);
return;
}
if matches!(app.input_mode, InputMode::Triggers { .. }) {
crate::triggers::draw_triggers(f, app);
return;
}
if matches!(app.input_mode, InputMode::WhatsNew) {
whats_new::draw_whats_new(f, app);
return;
}
if matches!(app.input_mode, InputMode::Tasks { .. }) {
tasks::draw_tasks(f, app);
return;
}
if matches!(app.input_mode, InputMode::WeekSummary { .. }) {
super::week_summary::draw_week_summary(f, app);
return;
}
let main_chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Length(3), Constraint::Min(10), Constraint::Length(3), ])
.split(f.area());
let content_chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints([
Constraint::Length(35), Constraint::Min(40), Constraint::Length(30), ])
.split(main_chunks[1]);
draw_top_bar(f, app, main_chunks[0]);
draw_timeline(f, app, content_chunks[0]);
draw_entries(f, app, content_chunks[1]);
draw_weekly_stats(f, app, content_chunks[2]);
draw_bottom_bar(f, app, main_chunks[2]);
if let InputMode::Creating { suggestions, .. } = &app.input_mode {
if !suggestions.is_empty() {
draw_suggestions_modal(f, app);
}
}
if matches!(app.input_mode, InputMode::OperationsMenu { .. }) {
draw_operations_menu(f, app);
}
if matches!(app.input_mode, InputMode::Hotkeys) {
draw_hotkeys(f, app);
}
}