1use crate::app::App; 2use crate::app::tabs::Tab; 3use crate::paths; 4use crate::ui::theme::{self, pal}; 5use crate::ui::widgets::{Kind, btn, btn_tx, lbl, mono}; 6use crate::workspace; 7use rune::{El, col, row, text}; 8 9fn count(n: usize, noun: &str) -> String { 10 match n { 11 0 => format!("no {noun} yet"), 12 1 => format!("1 {noun}"), 13 n => format!("{n} {noun}s"), 14 } 15} 16 17pub fn view(s: &App) -> El { 18 let p = pal(); 19 let recents = s.cfg.recents.iter().enumerate().map(|(i, dir)| { 20 let (prompts, workflows) = workspace::summary(dir); 21 let d = dir.clone(); 22 row() 23 .key(format!("recent-{i}")) 24 .px(12.0) 25 .py(4.0) 26 .gap(12.0) 27 .center_y() 28 .radius(4.0) 29 .role("button") 30 .label(paths::tilde(dir)) 31 .focusable(true) 32 .cursor(rune::Cursor::Pointer) 33 .hover(p.hover) 34 .on_press(move |s: &mut App| s.open_dir(&d)) 35 .child( 36 text(paths::tilde(dir)) 37 .font(theme::MONO) 38 .color(p.fg) 39 .truncate_middle() 40 .grow(1.0) 41 .min_w(0.0), 42 ) 43 .child(mono( 44 format!( 45 "{} · {}", 46 count(prompts, "prompt"), 47 count(workflows, "workflow") 48 ), 49 p.muted, 50 )) 51 }); 52 let mut recent = col().w(640.0).gap(4.0); 53 if !s.cfg.recents.is_empty() { 54 recent = recent 55 .child(lbl("Recent directories").px(12.0)) 56 .child(col().children(recents)); 57 } 58 col() 59 .w_full() 60 .h_full() 61 .center() 62 .gap(24.0) 63 .child( 64 col() 65 .items_center() 66 .gap(4.0) 67 .child(text("▲ cast").font(theme::DISPLAY).color(p.accent)) 68 .child(lbl("prompt → workflow → execution")), 69 ) 70 .child( 71 row() 72 .gap(8.0) 73 .child(btn_tx( 74 "Open directory… ⌃O", 75 Kind::Primary, 76 |s: &mut App, tx| s.pick_dir(tx), 77 )) 78 .child(btn( 79 "Settings", 80 Kind::Normal, 81 Some(|s: &mut App| s.open(Tab::Settings)), 82 )), 83 ) 84 .child(recent) 85}