login page being implemented slowly
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// src/components/handlers/intro.rs
|
||||
// src/components/intro/intro.rs
|
||||
use ratatui::{
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
style::Style,
|
||||
@@ -33,7 +33,7 @@ impl IntroState {
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
Constraint::Percentage(35),
|
||||
Constraint::Length(5),
|
||||
Constraint::Length(7), // Increased to accommodate 3 buttons
|
||||
Constraint::Percentage(35),
|
||||
])
|
||||
.split(inner_area);
|
||||
@@ -48,10 +48,14 @@ impl IntroState {
|
||||
.alignment(Alignment::Center);
|
||||
f.render_widget(title_para, chunks[1]);
|
||||
|
||||
// Buttons
|
||||
// Buttons - now with 3 options
|
||||
let button_area = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||
.constraints([
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
])
|
||||
.split(chunks[1].inner(Margin {
|
||||
horizontal: 1,
|
||||
vertical: 1
|
||||
@@ -73,9 +77,9 @@ impl IntroState {
|
||||
);
|
||||
self.render_button(
|
||||
f,
|
||||
button_area[1],
|
||||
button_area[2],
|
||||
"Login",
|
||||
self.selected_option == 1,
|
||||
self.selected_option == 2,
|
||||
theme,
|
||||
);
|
||||
}
|
||||
@@ -107,11 +111,23 @@ impl IntroState {
|
||||
f.render_widget(button, area);
|
||||
}
|
||||
|
||||
pub fn next_option(&mut self) {
|
||||
self.selected_option = (self.selected_option + 1) % 2;
|
||||
pub fn next_option(&mut self) {
|
||||
self.selected_option = (self.selected_option + 1) % 3; // Now 3 options
|
||||
}
|
||||
|
||||
pub fn previous_option(&mut self) {
|
||||
self.selected_option = if self.selected_option == 0 { 1 } else { 0 };
|
||||
self.selected_option = if self.selected_option == 0 { 2 } else { self.selected_option - 1 };
|
||||
}
|
||||
|
||||
pub fn handle_selection(&self, app_state: &mut crate::state::state::AppState) {
|
||||
match self.selected_option {
|
||||
0 => { /* Continue logic */ }
|
||||
1 => { /* Admin logic */ }
|
||||
2 => {
|
||||
app_state.ui.show_intro = false;
|
||||
app_state.ui.show_login = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user