theme is now in the config file
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
.
|
|
||||||
├── ./colors.rs
|
|
||||||
└── components1/
|
|
||||||
├── ./components1/mod.rs
|
|
||||||
├── ./components1/models.rs
|
|
||||||
├── ./components1/handlers.rs
|
|
||||||
└── handlers/
|
|
||||||
├── ./components1/handlers/command_line.rs
|
|
||||||
├── ./components1/handlers/form.rs
|
|
||||||
├── ./components1/handlers/mod.rs
|
|
||||||
├── ./components1/handlers/preview_card.rs
|
|
||||||
└── ./components1/handlers/status_line.rs
|
|
||||||
├── ./config.rs
|
|
||||||
├── ./mod.rs
|
|
||||||
├── ./terminal.rs
|
|
||||||
├── ./ui.rs
|
|
||||||
└── ./ui
|
|
||||||
├── ./ui/mod.rs
|
|
||||||
├── ./ui/models.rs
|
|
||||||
├── ./ui/handlers.rs
|
|
||||||
└── handlers/
|
|
||||||
├── ./ui/handlers/x.rs
|
|
||||||
├── ./ui/handlers/x2.rs
|
|
||||||
└── ./ui/handlers/x3.rs
|
|
||||||
@@ -13,3 +13,7 @@ move_left = ["h"]
|
|||||||
move_right = ["l"]
|
move_right = ["l"]
|
||||||
move_up = ["k", "Up"]
|
move_up = ["k", "Up"]
|
||||||
move_down = ["j", "Down"]
|
move_down = ["j", "Down"]
|
||||||
|
|
||||||
|
[colors]
|
||||||
|
theme = "dark"
|
||||||
|
# Options: "light", "dark", "high_contrast"
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ pub struct Theme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Theme {
|
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
|
// Default light theme
|
||||||
pub fn light() -> Self {
|
pub fn light() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -3,9 +3,21 @@ use serde::Deserialize;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crossterm::event::{KeyCode, KeyModifiers};
|
use crossterm::event::{KeyCode, KeyModifiers};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Default)]
|
||||||
|
pub struct ColorsConfig {
|
||||||
|
#[serde(default = "default_theme")]
|
||||||
|
pub theme: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_theme() -> String {
|
||||||
|
"light".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub keybindings: HashMap<String, Vec<String>>,
|
pub keybindings: HashMap<String, Vec<String>>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub colors: ColorsConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::client::ui::handlers::{event::EventHandler, form::FormState, state::A
|
|||||||
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()?;
|
||||||
let mut app_terminal = AppTerminal::new().await?;
|
let mut app_terminal = AppTerminal::new().await?;
|
||||||
let theme = Theme::dark();
|
let theme = Theme::from_str(&config.colors.theme);
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user