Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8da29376ab | ||
|
|
8ad5fedcea | ||
|
|
16a7fa0bcc | ||
|
|
5f6858251c | ||
|
|
73567ae5cf |
@@ -8,7 +8,7 @@ use ratatui::{
|
|||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
|
|
||||||
pub struct AdminPanelState {
|
pub struct AdminPanelState {
|
||||||
pub list_state: ListState,
|
pub list_state: ListState,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use ratatui::{
|
|||||||
style::Style,
|
style::Style,
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
|
|
||||||
pub fn render_background(f: &mut Frame, area: Rect, theme: &Theme) {
|
pub fn render_background(f: &mut Frame, area: Rect, theme: &Theme) {
|
||||||
let background = Block::default()
|
let background = Block::default()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use ratatui::{
|
|||||||
layout::Rect,
|
layout::Rect,
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
|
|
||||||
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool, theme: &Theme, message: &str) {
|
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool, theme: &Theme, message: &str) {
|
||||||
let prompt = if active {
|
let prompt = if active {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use ratatui::{
|
|||||||
Frame,
|
Frame,
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn render_status_line(
|
pub fn render_status_line(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use ratatui::{
|
|||||||
Frame,
|
Frame,
|
||||||
prelude::Alignment,
|
prelude::Alignment,
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use crate::ui::form::FormState;
|
use crate::ui::form::FormState;
|
||||||
|
|
||||||
pub fn render_canvas(
|
pub fn render_canvas(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use ratatui::{
|
|||||||
style::Style,
|
style::Style,
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use crate::ui::form::FormState;
|
use crate::ui::form::FormState;
|
||||||
use super::canvas::render_canvas; // Changed to canvas
|
use super::canvas::render_canvas; // Changed to canvas
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use ratatui::{
|
|||||||
style::Style,
|
style::Style,
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use common::proto::multieko2::table_definition::{ProfileTreeResponse};
|
use common::proto::multieko2::table_definition::{ProfileTreeResponse};
|
||||||
use ratatui::text::{Span, Line};
|
use ratatui::text::{Span, Line};
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use ratatui::{
|
|||||||
prelude::Margin,
|
prelude::Margin,
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
|
|
||||||
pub struct IntroState {
|
pub struct IntroState {
|
||||||
pub selected_option: usize,
|
pub selected_option: usize,
|
||||||
|
|||||||
7
client/src/config/binds.rs
Normal file
7
client/src/config/binds.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// src/config/binds.rs
|
||||||
|
|
||||||
|
pub mod config;
|
||||||
|
pub mod key_sequences;
|
||||||
|
|
||||||
|
pub use config::*;
|
||||||
|
pub use key_sequences::*;
|
||||||
@@ -355,13 +355,13 @@ impl Config {
|
|||||||
|
|
||||||
// Get string representations of the sequence
|
// Get string representations of the sequence
|
||||||
let sequence_str = sequence.iter()
|
let sequence_str = sequence.iter()
|
||||||
.map(|k| crate::config::key_sequences::key_to_string(k))
|
.map(|k| crate::config::binds::key_sequences::key_to_string(k))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("");
|
.join("");
|
||||||
|
|
||||||
// Add the missing sequence_plus definition
|
// Add the missing sequence_plus definition
|
||||||
let sequence_plus = sequence.iter()
|
let sequence_plus = sequence.iter()
|
||||||
.map(|k| crate::config::key_sequences::key_to_string(k))
|
.map(|k| crate::config::binds::key_sequences::key_to_string(k))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("+");
|
.join("+");
|
||||||
|
|
||||||
@@ -414,7 +414,7 @@ impl Config {
|
|||||||
// Special case for + format in bindings
|
// Special case for + format in bindings
|
||||||
if binding.contains('+') {
|
if binding.contains('+') {
|
||||||
let normalized_sequence = sequence.iter()
|
let normalized_sequence = sequence.iter()
|
||||||
.map(|k| crate::config::key_sequences::key_to_string(k))
|
.map(|k| crate::config::binds::key_sequences::key_to_string(k))
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
let binding_parts: Vec<&str> = binding.split('+').collect();
|
let binding_parts: Vec<&str> = binding.split('+').collect();
|
||||||
@@ -442,7 +442,7 @@ impl Config {
|
|||||||
|
|
||||||
// Get string representation of the sequence
|
// Get string representation of the sequence
|
||||||
let sequence_str = sequence.iter()
|
let sequence_str = sequence.iter()
|
||||||
.map(|k| crate::config::key_sequences::key_to_string(k))
|
.map(|k| crate::config::binds::key_sequences::key_to_string(k))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("");
|
.join("");
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ impl Config {
|
|||||||
if binding.contains('+') {
|
if binding.contains('+') {
|
||||||
let binding_parts: Vec<&str> = binding.split('+').collect();
|
let binding_parts: Vec<&str> = binding.split('+').collect();
|
||||||
let sequence_parts = sequence.iter()
|
let sequence_parts = sequence.iter()
|
||||||
.map(|k| crate::config::key_sequences::key_to_string(k))
|
.map(|k| crate::config::binds::key_sequences::key_to_string(k))
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
if binding_parts.len() > sequence_parts.len() {
|
if binding_parts.len() > sequence_parts.len() {
|
||||||
@@ -1,68 +1,4 @@
|
|||||||
// src/client/colors.rs
|
// src/config/colors.rs
|
||||||
use ratatui::style::Color;
|
pub mod themes;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
pub use themes::*;
|
||||||
pub struct Theme {
|
|
||||||
pub bg: Color,
|
|
||||||
pub fg: Color,
|
|
||||||
pub accent: Color,
|
|
||||||
pub secondary: Color,
|
|
||||||
pub highlight: Color,
|
|
||||||
pub warning: Color,
|
|
||||||
pub border: Color,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Theme {
|
|
||||||
pub fn from_str(theme_name: &str) -> Self {
|
|
||||||
match theme_name.to_lowercase().as_str() {
|
|
||||||
"dark" => Self::dark(),
|
|
||||||
"high_contrast" => Self::high_contrast(),
|
|
||||||
_ => Self::light(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default light theme
|
|
||||||
pub fn light() -> Self {
|
|
||||||
Self {
|
|
||||||
bg: Color::Rgb(245, 245, 245), // Light gray
|
|
||||||
fg: Color::Rgb(64, 64, 64), // Dark gray
|
|
||||||
accent: Color::Rgb(173, 216, 230), // Pastel blue
|
|
||||||
secondary: Color::Rgb(255, 165, 0), // Orange for secondary
|
|
||||||
highlight: Color::Rgb(152, 251, 152), // Pastel green
|
|
||||||
warning: Color::Rgb(255, 182, 193), // Pastel pink
|
|
||||||
border: Color::Rgb(220, 220, 220), // Light gray border
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// High-contrast dark theme
|
|
||||||
pub fn dark() -> Self {
|
|
||||||
Self {
|
|
||||||
bg: Color::Rgb(30, 30, 30), // Dark background
|
|
||||||
fg: Color::Rgb(255, 255, 255), // White text
|
|
||||||
accent: Color::Rgb(0, 191, 255), // Bright blue
|
|
||||||
secondary: Color::Rgb(255, 215, 0), // Gold for secondary
|
|
||||||
highlight: Color::Rgb(50, 205, 50), // Bright green
|
|
||||||
warning: Color::Rgb(255, 99, 71), // Bright red
|
|
||||||
border: Color::Rgb(100, 100, 100), // Medium gray border
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// High-contrast light theme
|
|
||||||
pub fn high_contrast() -> Self {
|
|
||||||
Self {
|
|
||||||
bg: Color::Rgb(255, 255, 255), // White background
|
|
||||||
fg: Color::Rgb(0, 0, 0), // Black text
|
|
||||||
accent: Color::Rgb(0, 0, 255), // Blue
|
|
||||||
secondary: Color::Rgb(255, 140, 0), // Dark orange for secondary
|
|
||||||
highlight: Color::Rgb(0, 128, 0), // Green
|
|
||||||
warning: Color::Rgb(255, 0, 0), // Red
|
|
||||||
border: Color::Rgb(0, 0, 0), // Black border
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Theme {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::light() // Default to light theme
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
68
client/src/config/colors/themes.rs
Normal file
68
client/src/config/colors/themes.rs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
// src/client/themes/colors.rs
|
||||||
|
use ratatui::style::Color;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct Theme {
|
||||||
|
pub bg: Color,
|
||||||
|
pub fg: Color,
|
||||||
|
pub accent: Color,
|
||||||
|
pub secondary: Color,
|
||||||
|
pub highlight: Color,
|
||||||
|
pub warning: Color,
|
||||||
|
pub border: Color,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Theme {
|
||||||
|
pub fn from_str(theme_name: &str) -> Self {
|
||||||
|
match theme_name.to_lowercase().as_str() {
|
||||||
|
"dark" => Self::dark(),
|
||||||
|
"high_contrast" => Self::high_contrast(),
|
||||||
|
_ => Self::light(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default light theme
|
||||||
|
pub fn light() -> Self {
|
||||||
|
Self {
|
||||||
|
bg: Color::Rgb(245, 245, 245), // Light gray
|
||||||
|
fg: Color::Rgb(64, 64, 64), // Dark gray
|
||||||
|
accent: Color::Rgb(173, 216, 230), // Pastel blue
|
||||||
|
secondary: Color::Rgb(255, 165, 0), // Orange for secondary
|
||||||
|
highlight: Color::Rgb(152, 251, 152), // Pastel green
|
||||||
|
warning: Color::Rgb(255, 182, 193), // Pastel pink
|
||||||
|
border: Color::Rgb(220, 220, 220), // Light gray border
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// High-contrast dark theme
|
||||||
|
pub fn dark() -> Self {
|
||||||
|
Self {
|
||||||
|
bg: Color::Rgb(30, 30, 30), // Dark background
|
||||||
|
fg: Color::Rgb(255, 255, 255), // White text
|
||||||
|
accent: Color::Rgb(0, 191, 255), // Bright blue
|
||||||
|
secondary: Color::Rgb(255, 215, 0), // Gold for secondary
|
||||||
|
highlight: Color::Rgb(50, 205, 50), // Bright green
|
||||||
|
warning: Color::Rgb(255, 99, 71), // Bright red
|
||||||
|
border: Color::Rgb(100, 100, 100), // Medium gray border
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// High-contrast light theme
|
||||||
|
pub fn high_contrast() -> Self {
|
||||||
|
Self {
|
||||||
|
bg: Color::Rgb(255, 255, 255), // White background
|
||||||
|
fg: Color::Rgb(0, 0, 0), // Black text
|
||||||
|
accent: Color::Rgb(0, 0, 255), // Blue
|
||||||
|
secondary: Color::Rgb(255, 140, 0), // Dark orange for secondary
|
||||||
|
highlight: Color::Rgb(0, 128, 0), // Green
|
||||||
|
warning: Color::Rgb(255, 0, 0), // Red
|
||||||
|
border: Color::Rgb(0, 0, 0), // Black border
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Theme {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::light() // Default to light theme
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/config/mod.rs
|
// src/config/mod.rs
|
||||||
|
|
||||||
|
pub mod binds;
|
||||||
pub mod colors;
|
pub mod colors;
|
||||||
pub mod config;
|
|
||||||
pub mod key_sequences;
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
||||||
use crate::tui::terminal::grpc_client::GrpcClient;
|
use crate::tui::terminal::grpc_client::GrpcClient;
|
||||||
use crate::config::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::ui::handlers::form::FormState;
|
use crate::ui::handlers::form::FormState;
|
||||||
use super::common;
|
use super::common;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crossterm::event::{KeyEvent, KeyCode, KeyModifiers};
|
|||||||
use crate::tui::terminal::{
|
use crate::tui::terminal::{
|
||||||
grpc_client::GrpcClient,
|
grpc_client::GrpcClient,
|
||||||
};
|
};
|
||||||
use crate::config::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::ui::handlers::form::FormState;
|
use crate::ui::handlers::form::FormState;
|
||||||
use super::common;
|
use super::common;
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ use crate::tui::terminal::{
|
|||||||
grpc_client::GrpcClient,
|
grpc_client::GrpcClient,
|
||||||
commands::CommandHandler,
|
commands::CommandHandler,
|
||||||
};
|
};
|
||||||
use crate::config::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::ui::handlers::form::FormState;
|
use crate::ui::handlers::form::FormState;
|
||||||
use crate::ui::handlers::rat_state::UiStateHandler;
|
use crate::ui::handlers::rat_state::UiStateHandler;
|
||||||
use crate::modes::handlers::{edit, command_mode, read_only};
|
use crate::modes::handlers::{edit, command_mode, read_only};
|
||||||
use crate::config::key_sequences::KeySequenceTracker;
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||||
use super::common;
|
use super::common;
|
||||||
|
|
||||||
pub struct EventHandler {
|
pub struct EventHandler {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// src/modes/handlers/read_only.rs
|
// src/modes/handlers/read_only.rs
|
||||||
|
|
||||||
use crossterm::event::{KeyEvent};
|
use crossterm::event::{KeyEvent};
|
||||||
use crate::config::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::ui::handlers::form::FormState;
|
use crate::ui::handlers::form::FormState;
|
||||||
use crate::config::key_sequences::KeySequenceTracker;
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||||
use crate::tui::terminal::grpc_client::GrpcClient;
|
use crate::tui::terminal::grpc_client::GrpcClient;
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// src/client/ui/handlers/form.rs
|
// src/client/ui/handlers/form.rs
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use ratatui::Frame;
|
use ratatui::Frame;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// src/ui/handlers/rat_state.rs
|
// src/ui/handlers/rat_state.rs
|
||||||
use crossterm::event::{KeyCode, KeyModifiers};
|
use crossterm::event::{KeyCode, KeyModifiers};
|
||||||
use crate::config::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::state::state::UiState;
|
use crate::state::state::UiState;
|
||||||
|
|
||||||
pub struct UiStateHandler;
|
pub struct UiStateHandler;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::components::{
|
|||||||
intro::{intro},
|
intro::{intro},
|
||||||
admin::{admin_panel::AdminPanelState},
|
admin::{admin_panel::AdminPanelState},
|
||||||
};
|
};
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use ratatui::layout::{Constraint, Direction, Layout};
|
use ratatui::layout::{Constraint, Direction, Layout};
|
||||||
use ratatui::Frame;
|
use ratatui::Frame;
|
||||||
use super::form::FormState;
|
use super::form::FormState;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use crate::tui::terminal::TerminalCore;
|
|||||||
use crate::tui::terminal::GrpcClient;
|
use crate::tui::terminal::GrpcClient;
|
||||||
use crate::tui::terminal::CommandHandler;
|
use crate::tui::terminal::CommandHandler;
|
||||||
use crate::tui::terminal::EventReader;
|
use crate::tui::terminal::EventReader;
|
||||||
use crate::config::colors::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use crate::config::config::Config;
|
use crate::config::binds::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;
|
||||||
|
|||||||
Reference in New Issue
Block a user