From 047c8e08c02d78601f63cc9ca02cd1d25a44ce1a Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Mon, 28 Jul 2025 11:53:15 -0600 Subject: [PATCH] Random tabs --- thecockpit/src/app/mod.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/thecockpit/src/app/mod.rs b/thecockpit/src/app/mod.rs index 1310725..7590cac 100644 --- a/thecockpit/src/app/mod.rs +++ b/thecockpit/src/app/mod.rs @@ -1,3 +1,4 @@ +use rand::{rngs::OsRng, seq::IndexedRandom, TryRngCore}; #[cfg(target_arch = "wasm32")] use ratzilla::ratatui; @@ -15,6 +16,7 @@ use crate::app::password_locker::PasswordLocker; mod password_locker; pub struct App { + tabs: [&'static str; 3], transition_instant: Instant, selected_tab: usize, password_locker: PasswordLocker, @@ -48,11 +50,23 @@ YJJJJJJJJJ????????????77777777777!!!!!!!!!!!~~~~~~ YJJJJJJJJJJJ???????????77777777777!!!!!!!!!!!~~~~~ "#; -const TABS: [&'static str; 3] = ["Whatzahoozits", "Thingamajigs", "Doohickeys"]; +const TABS: [&'static str; 10] = [ + "Doohickies", + "Gadgets", + "Gizmos", + "Inators", + "Thingamabobs", + "Thingamajigs", + "Doodads", + "Dingies", + "Trinkets", + "Goobers", +]; impl App { pub fn new() -> Self { Self { + tabs: TABS.choose_multiple_array(&mut OsRng.unwrap_err()).unwrap(), transition_instant: Instant::now(), selected_tab: 0, password_locker: PasswordLocker::default(), @@ -90,7 +104,7 @@ impl App { ) .split(frame.area()); frame.render_widget( - Tabs::new(TABS) + Tabs::new(self.tabs) .select(self.selected_tab) .fg(Color::Rgb(226, 190, 89)) .bg(Color::Black) @@ -114,7 +128,7 @@ impl App { pub fn next_tab(&mut self) { self.transition_instant = Instant::now(); - if self.selected_tab == TABS.len() - 1 { + if self.selected_tab == self.tabs.len() - 1 { self.selected_tab = 0; } else { self.selected_tab += 1; @@ -124,7 +138,7 @@ impl App { pub fn prev_tab(&mut self) { self.transition_instant = Instant::now(); if self.selected_tab == 0 { - self.selected_tab = TABS.len() - 1; + self.selected_tab = self.tabs.len() - 1; } else { self.selected_tab -= 1; }