This commit is contained in:
parent
de193a6e47
commit
047c8e08c0
1 changed files with 18 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
use rand::{rngs::OsRng, seq::IndexedRandom, TryRngCore};
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use ratzilla::ratatui;
|
use ratzilla::ratatui;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ use crate::app::password_locker::PasswordLocker;
|
||||||
mod password_locker;
|
mod password_locker;
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
|
tabs: [&'static str; 3],
|
||||||
transition_instant: Instant,
|
transition_instant: Instant,
|
||||||
selected_tab: usize,
|
selected_tab: usize,
|
||||||
password_locker: PasswordLocker,
|
password_locker: PasswordLocker,
|
||||||
|
@ -48,11 +50,23 @@ YJJJJJJJJJ????????????77777777777!!!!!!!!!!!~~~~~~
|
||||||
YJJJJJJJJJJJ???????????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 {
|
impl App {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
tabs: TABS.choose_multiple_array(&mut OsRng.unwrap_err()).unwrap(),
|
||||||
transition_instant: Instant::now(),
|
transition_instant: Instant::now(),
|
||||||
selected_tab: 0,
|
selected_tab: 0,
|
||||||
password_locker: PasswordLocker::default(),
|
password_locker: PasswordLocker::default(),
|
||||||
|
@ -90,7 +104,7 @@ impl App {
|
||||||
)
|
)
|
||||||
.split(frame.area());
|
.split(frame.area());
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
Tabs::new(TABS)
|
Tabs::new(self.tabs)
|
||||||
.select(self.selected_tab)
|
.select(self.selected_tab)
|
||||||
.fg(Color::Rgb(226, 190, 89))
|
.fg(Color::Rgb(226, 190, 89))
|
||||||
.bg(Color::Black)
|
.bg(Color::Black)
|
||||||
|
@ -114,7 +128,7 @@ impl App {
|
||||||
|
|
||||||
pub fn next_tab(&mut self) {
|
pub fn next_tab(&mut self) {
|
||||||
self.transition_instant = Instant::now();
|
self.transition_instant = Instant::now();
|
||||||
if self.selected_tab == TABS.len() - 1 {
|
if self.selected_tab == self.tabs.len() - 1 {
|
||||||
self.selected_tab = 0;
|
self.selected_tab = 0;
|
||||||
} else {
|
} else {
|
||||||
self.selected_tab += 1;
|
self.selected_tab += 1;
|
||||||
|
@ -124,7 +138,7 @@ impl App {
|
||||||
pub fn prev_tab(&mut self) {
|
pub fn prev_tab(&mut self) {
|
||||||
self.transition_instant = Instant::now();
|
self.transition_instant = Instant::now();
|
||||||
if self.selected_tab == 0 {
|
if self.selected_tab == 0 {
|
||||||
self.selected_tab = TABS.len() - 1;
|
self.selected_tab = self.tabs.len() - 1;
|
||||||
} else {
|
} else {
|
||||||
self.selected_tab -= 1;
|
self.selected_tab -= 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue