feat: add support for dark / light mode switching (#178)

* feat: add support for dark / light mode switching and simultaneouscustom light / dark mode themes

* refactor(color-picker): optional initial color and fallback color

* refactor: used FixedPortion for layout of the settings item

This makes sure that the control always has at least the specified portion of the available space

* refactor: make all members of the ThemeBuilder public

* refactor: add and update palette colors

* fix(theme): typo and derive PartialEq for ThemeBuilder

* fix: update color picker usage

* feat: add more variables to the theme

* fix: radius on headerbar

* fix: Theme CosmicConfigEntry impl

* chore: specify rev of taffy

* fix: theme CosmicConfigEntry missing variables

* fix: apply theme type when theme mode changes

* wip: add plus icon to empty color picker button

* chore: fix rev and imports

* refactor(color-picker): allow custom size for the icon

* refactor(color_picker): make color_button public

* update iced
This commit is contained in:
Ashley Wulber 2023-10-16 16:19:04 -04:00 committed by GitHub
parent a91deacff5
commit 7cc791a3f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 542 additions and 164 deletions

View file

@ -1,6 +1,9 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use cosmic_config::CosmicConfigEntry;
use cosmic_theme::ThemeMode;
use crate::Theme;
/// Status of the nav bar and its panels.
@ -49,6 +52,9 @@ pub struct Core {
/// Last known system theme
pub(super) system_theme: Theme,
/// Theme mode
pub(super) system_theme_mode: ThemeMode,
pub(super) title: String,
pub window: Window,
@ -70,6 +76,16 @@ impl Default for Core {
scale_factor: 1.0,
title: String::new(),
system_theme: crate::theme::active(),
system_theme_mode: ThemeMode::config()
.map(|c| {
ThemeMode::get_entry(&c).unwrap_or_else(|(errors, mode)| {
for e in errors {
tracing::error!("{e}");
}
mode
})
})
.unwrap_or_default(),
window: Window {
context_title: String::new(),
header_title: String::new(),
@ -169,4 +185,15 @@ impl Core {
self.window.width = new_width;
self.is_condensed_update();
}
/// Get the current system theme
pub fn system_theme(&self) -> &Theme {
&self.system_theme
}
#[must_use]
/// Get the current system theme mode
pub fn system_theme_mode(&self) -> ThemeMode {
self.system_theme_mode
}
}