intro page working properly well
This commit is contained in:
@@ -5,6 +5,7 @@ pub mod status_line;
|
|||||||
pub mod canvas;
|
pub mod canvas;
|
||||||
pub mod sidebar;
|
pub mod sidebar;
|
||||||
pub mod background;
|
pub mod background;
|
||||||
|
pub mod intro;
|
||||||
|
|
||||||
pub use command_line::render_command_line;
|
pub use command_line::render_command_line;
|
||||||
pub use form::*;
|
pub use form::*;
|
||||||
@@ -12,3 +13,4 @@ pub use status_line::render_status_line;
|
|||||||
pub use canvas::*;
|
pub use canvas::*;
|
||||||
pub use sidebar::*;
|
pub use sidebar::*;
|
||||||
pub use background::*;
|
pub use background::*;
|
||||||
|
pub use intro::*;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use ratatui::{
|
|||||||
style::Style,
|
style::Style,
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{Block, BorderType, Borders, Paragraph},
|
widgets::{Block, BorderType, Borders, Paragraph},
|
||||||
|
prelude::Margin,
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::Theme;
|
||||||
@@ -51,7 +52,10 @@ impl IntroState {
|
|||||||
let button_area = Layout::default()
|
let button_area = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||||
.split(chunks[1].inner(chunks[1]));
|
.split(chunks[1].inner(Margin {
|
||||||
|
horizontal: 1,
|
||||||
|
vertical: 1
|
||||||
|
}));
|
||||||
|
|
||||||
self.render_button(
|
self.render_button(
|
||||||
f,
|
f,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
//
|
// src/modes/handlers/event.rs
|
||||||
|
use crossterm::event::{Event, KeyCode};
|
||||||
use crossterm::event::Event;
|
|
||||||
use crossterm::cursor::SetCursorStyle;
|
use crossterm::cursor::SetCursorStyle;
|
||||||
use crate::tui::terminal::{
|
use crate::tui::terminal::{
|
||||||
core::TerminalCore,
|
core::TerminalCore,
|
||||||
@@ -48,7 +47,27 @@ impl EventHandler {
|
|||||||
app_state: &mut crate::state::state::AppState,
|
app_state: &mut crate::state::state::AppState,
|
||||||
total_count: u64,
|
total_count: u64,
|
||||||
current_position: &mut u64,
|
current_position: &mut u64,
|
||||||
|
intro_state: &mut crate::components::handlers::intro::IntroState,
|
||||||
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||||
|
if app_state.ui.show_intro {
|
||||||
|
if let Event::Key(key) = event {
|
||||||
|
match key.code {
|
||||||
|
KeyCode::Left => intro_state.previous_option(),
|
||||||
|
KeyCode::Right => intro_state.next_option(),
|
||||||
|
KeyCode::Enter => {
|
||||||
|
if intro_state.selected_option == 0 {
|
||||||
|
app_state.ui.show_intro = false;
|
||||||
|
} else {
|
||||||
|
self.command_message = "Admin panel coming soon".to_string();
|
||||||
|
}
|
||||||
|
return Ok((false, String::new()));
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Ok((false, String::new()));
|
||||||
|
}
|
||||||
|
|
||||||
if let Event::Key(key) = event {
|
if let Event::Key(key) = event {
|
||||||
let key_code = key.code;
|
let key_code = key.code;
|
||||||
let modifiers = key.modifiers;
|
let modifiers = key.modifiers;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
|||||||
pub struct UiState {
|
pub struct UiState {
|
||||||
pub show_sidebar: bool,
|
pub show_sidebar: bool,
|
||||||
pub is_saved: bool,
|
pub is_saved: bool,
|
||||||
// pub show_intro: bool,
|
pub show_intro: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
@@ -49,6 +49,7 @@ impl Default for UiState {
|
|||||||
Self {
|
Self {
|
||||||
show_sidebar: true,
|
show_sidebar: true,
|
||||||
is_saved: false,
|
is_saved: false,
|
||||||
|
show_intro: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::components::{
|
|||||||
render_background,
|
render_background,
|
||||||
render_command_line,
|
render_command_line,
|
||||||
render_status_line,
|
render_status_line,
|
||||||
handlers::sidebar::{self, calculate_sidebar_layout}
|
handlers::{sidebar::{self, calculate_sidebar_layout}, intro},
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::Theme;
|
||||||
use ratatui::layout::{Constraint, Direction, Layout};
|
use ratatui::layout::{Constraint, Direction, Layout};
|
||||||
@@ -23,9 +23,15 @@ pub fn render_ui(
|
|||||||
command_mode: bool,
|
command_mode: bool,
|
||||||
command_message: &str,
|
command_message: &str,
|
||||||
app_state: &AppState,
|
app_state: &AppState,
|
||||||
|
intro_state: &intro::IntroState,
|
||||||
) {
|
) {
|
||||||
render_background(f, f.area(), theme);
|
render_background(f, f.area(), theme);
|
||||||
|
|
||||||
|
if app_state.ui.show_intro {
|
||||||
|
intro_state.render(f, f.area(), theme);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let root = Layout::default()
|
let root = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints([
|
.constraints([
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::config::config::Config;
|
|||||||
use crate::ui::handlers::{form::FormState, render::render_ui};
|
use crate::ui::handlers::{form::FormState, render::render_ui};
|
||||||
use crate::modes::handlers::event::EventHandler;
|
use crate::modes::handlers::event::EventHandler;
|
||||||
use crate::state::state::AppState;
|
use crate::state::state::AppState;
|
||||||
|
use crate::components::handlers::intro::IntroState;
|
||||||
|
|
||||||
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let config = Config::load()?;
|
let config = Config::load()?;
|
||||||
@@ -17,6 +17,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let mut grpc_client = GrpcClient::new().await?;
|
let mut grpc_client = GrpcClient::new().await?;
|
||||||
let mut command_handler = CommandHandler::new();
|
let mut command_handler = CommandHandler::new();
|
||||||
let theme = Theme::from_str(&config.colors.theme);
|
let theme = Theme::from_str(&config.colors.theme);
|
||||||
|
let mut intro_state = IntroState::new();
|
||||||
|
|
||||||
// Fetch table structure at startup (one-time)
|
// Fetch table structure at startup (one-time)
|
||||||
// TODO: Later, consider implementing a live update for table structure changes.
|
// TODO: Later, consider implementing a live update for table structure changes.
|
||||||
@@ -63,6 +64,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
event_handler.command_mode,
|
event_handler.command_mode,
|
||||||
&event_handler.command_message,
|
&event_handler.command_message,
|
||||||
&app_state,
|
&app_state,
|
||||||
|
&intro_state,
|
||||||
);
|
);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -80,6 +82,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
&mut app_state,
|
&mut app_state,
|
||||||
total_count,
|
total_count,
|
||||||
&mut current_position,
|
&mut current_position,
|
||||||
|
&mut intro_state,
|
||||||
).await?;
|
).await?;
|
||||||
|
|
||||||
app_state.current_position = current_position;
|
app_state.current_position = current_position;
|
||||||
|
|||||||
Reference in New Issue
Block a user