Skip to content

Commit 2916970

Browse files
committed
Add inline accent color picker
1 parent 3d56fc6 commit 2916970

4 files changed

Lines changed: 900 additions & 129 deletions

File tree

Cargo.lock

Lines changed: 60 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/plumeimpactor/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ plume_core = { path = "../../crates/plume_core", features = ["tweaks"] }
2222
plume_utils = { path = "../../crates/plume_utils" }
2323
plume_store = { path = "../../crates/plume_store" }
2424

25-
iced = { version = "0.14.0", features = ["image-without-codecs", "advanced"] }
25+
iced = { version = "0.14.0", features = ["image-without-codecs", "advanced", "canvas"] }
2626
wgpu = "27.0.1" # Power references
2727
tray-icon = { version = "0.21.2", default-features = false } # System tray icon
2828
rfd = "0.16.0" # File dialogs
2929
open = "5.3.3" # Opening links (I know, useless)
3030
notify-rust = "4.11.7" # Notifications
3131
single-instance = "0.3.3" # Ensuring single instance of the app on Linux and Windows
3232
auto-launcher = "0.6.1" # Auto-launching on startup
33-
tinyfiledialogs = { version = "3.9.1", default-features = false } # Cross-platform color picker dialog
3433

3534
[target.'cfg(target_os = "macos")'.dependencies]
3635
plume_gestalt = { path = "../../crates/plume_gestalt" }

apps/plumeimpactor/src/screen/mod.rs

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ pub struct Impactor {
8888
main_window: Option<window::Id>,
8989
account_store: Option<AccountStore>,
9090
accent_color: appearance::AccentColor,
91-
accent_picker_open: bool,
9291
login_windows: std::collections::HashMap<window::Id, login_window::LoginWindow>,
9392
pending_installation: bool,
9493
}
@@ -136,7 +135,6 @@ impl Impactor {
136135
main_window,
137136
account_store: Some(store),
138137
accent_color,
139-
accent_picker_open: false,
140138
login_windows: std::collections::HashMap::new(),
141139
pending_installation: false,
142140
},
@@ -465,59 +463,10 @@ impl Impactor {
465463
}
466464
Task::none()
467465
}
468-
settings::Message::RequestAccentColorPicker => {
469-
if self.accent_picker_open {
470-
return Task::none();
471-
}
472-
473-
self.accent_picker_open = true;
474-
475-
Task::perform(async {}, |_| {
476-
Message::SettingsScreen(settings::Message::OpenAccentColorPicker)
477-
})
478-
}
479-
settings::Message::OpenAccentColorPicker => {
480-
let current_accent = self.accent_color;
481-
482-
Task::perform(
483-
async move {
484-
let (tx, rx) = std::sync::mpsc::channel();
485-
486-
std::thread::spawn(move || {
487-
let default_rgb = [
488-
current_accent.red(),
489-
current_accent.green(),
490-
current_accent.blue(),
491-
];
492-
493-
let picked = tinyfiledialogs::color_chooser_dialog(
494-
"Choose Accent Color",
495-
tinyfiledialogs::DefaultColorValue::RGB(&default_rgb),
496-
)
497-
.map(|(_, rgb)| {
498-
appearance::AccentColor::new(rgb[0], rgb[1], rgb[2])
499-
});
500-
501-
let _ = tx.send(picked);
502-
});
503-
504-
rx.recv().ok().flatten()
505-
},
506-
|accent| {
507-
Message::SettingsScreen(settings::Message::AccentColorPicked(
508-
accent,
509-
))
510-
},
511-
)
512-
}
513-
settings::Message::AccentColorPicked(accent) => {
514-
self.accent_picker_open = false;
515-
516-
if let Some(accent_color) = accent {
517-
self.accent_color = accent_color;
518-
if let Err(err) = defaults::save_accent_color(self.accent_color) {
519-
log::error!("Failed to save accent color: {err}");
520-
}
466+
settings::Message::AccentColorPicked(accent_color) => {
467+
self.accent_color = accent_color;
468+
if let Err(err) = defaults::save_accent_color(self.accent_color) {
469+
log::error!("Failed to save accent color: {err}");
521470
}
522471

523472
Task::none()
@@ -840,11 +789,7 @@ impl Impactor {
840789
ImpactorScreen::Main(screen) => screen.view().map(Message::MainScreen),
841790
ImpactorScreen::Utilities(screen) => screen.view().map(Message::UtilitiesScreen),
842791
ImpactorScreen::Settings(screen) => screen
843-
.view(
844-
&self.account_store,
845-
self.accent_color,
846-
self.accent_picker_open,
847-
)
792+
.view(&self.account_store, self.accent_color)
848793
.map(Message::SettingsScreen),
849794
ImpactorScreen::Installer(screen) => {
850795
screen.view(has_device).map(Message::InstallerScreen)

0 commit comments

Comments
 (0)