Skip to content

Commit

Permalink
feat(theme): use OS dark/light theme preference for initial theme value
Browse files Browse the repository at this point in the history
  • Loading branch information
kpbaks committed Apr 14, 2024
1 parent aa7b59b commit 3d1e741
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 53 deletions.
113 changes: 104 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion crates/gbpplanner-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ egui_graphs = "0.19.0"
serde_yaml = "0.9.34"
colored = "2.1.0"
directories = "5.0.1"
chrono = "0.4.37"
chrono = "0.4.37"
# font-kit = { version = "0.13.0", features = ["freetype"] }

dark-light = "1.1.1"


# TODO: change to not wasm
[target.'cfg(linux)'.dependencies]
Expand Down
8 changes: 4 additions & 4 deletions crates/gbpplanner-rs/src/input/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use strum::IntoEnumIterator;
use strum_macros::EnumIter;
use tap::Tap;

use super::{super::theme::ThemeEvent, screenshot::TakeScreenshot};
use super::{super::theme::CycleTheme, screenshot::TakeScreenshot};
use crate::{
config::Config,
planner::{FactorGraph, NodeKind, PausePlayEvent, RobotId, RobotState},
Expand Down Expand Up @@ -219,7 +219,7 @@ fn export_factorgraphs_as_graphviz(
}

fn cycle_theme(
theme_event_writer: &mut EventWriter<ThemeEvent>,
theme_event_writer: &mut EventWriter<CycleTheme>,
catppuccin_theme: Res<CatppuccinTheme>,
) {
info!("toggling application theme");
Expand All @@ -231,7 +231,7 @@ fn cycle_theme(
catppuccin::Flavour::Mocha => catppuccin::Flavour::Latte,
};

theme_event_writer.send(ThemeEvent(next_theme));
theme_event_writer.send(CycleTheme(next_theme));
}

fn export_graph_on_event(
Expand Down Expand Up @@ -365,7 +365,7 @@ fn quit_application_system(
}

fn general_actions_system(
mut theme_event: EventWriter<ThemeEvent>,
mut theme_event: EventWriter<CycleTheme>,
query: Query<&ActionState<GeneralAction>, With<GeneralInputs>>,
query_graphs: Query<(Entity, &FactorGraph), With<RobotState>>,
config: Res<Config>,
Expand Down
Loading

0 comments on commit 3d1e741

Please sign in to comment.