trackWork 0.15.0

A terminal-based time tracking application for managing work sessions
use ratatui::{
    layout::Rect,
    style::{Color, Modifier, Style},
    text::{Line, Span},
    widgets::{Block, Borders, Paragraph},
    Frame,
};

use crate::app::App;

pub fn draw_top_bar(f: &mut Frame, app: &App, area: Rect) {
    let date_str = app.current_date.format(&app.config.date_format).to_string();

    // Per-day time math (day span, work hours, off-work) lives in the "At Work"
    // row now — keeps the totals next to the start/end span they're derived from.
    let mut spans = vec![
        Span::styled(
            format!("trackWork v{}", env!("CARGO_PKG_VERSION")),
            Style::default()
                .fg(Color::Cyan)
                .add_modifier(Modifier::BOLD),
        ),
        Span::raw("  |  "),
        Span::styled(date_str, Style::default().fg(Color::Yellow)),
    ];

    // Background update check (see `update_check.rs`) fills this slot when a
    // newer stable release is on crates.io. We only render when present.
    if let Ok(guard) = app.available_update.lock() {
        if let Some(latest) = guard.as_ref() {
            spans.push(Span::raw("  |  "));
            spans.push(Span::styled(
                format!("⬆ v{} available", latest),
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ));
        }
    }

    let header = Paragraph::new(Line::from(spans)).block(Block::default().borders(Borders::ALL));
    f.render_widget(header, area);
}