Improve the `ThemePreference` selection UI slightly
This commit is contained in:
parent
40c69cd1ba
commit
378e22e6ec
|
|
@ -89,9 +89,32 @@ impl ThemePreference {
|
|||
/// Show radio-buttons to switch between light mode, dark mode and following the system theme.
|
||||
pub fn radio_buttons(&mut self, ui: &mut crate::Ui) {
|
||||
ui.horizontal(|ui| {
|
||||
ui.selectable_value(self, Self::Light, "☀ Light");
|
||||
ui.selectable_value(self, Self::Dark, "🌙 Dark");
|
||||
ui.selectable_value(self, Self::System, "💻 System");
|
||||
let system_theme = ui.ctx().input(|i| i.raw.system_theme);
|
||||
|
||||
ui.selectable_value(self, Self::System, "💻 System")
|
||||
.on_hover_ui(|ui| {
|
||||
ui.label("Follow the system theme preference.");
|
||||
|
||||
ui.add_space(4.0);
|
||||
|
||||
if let Some(system_theme) = system_theme {
|
||||
ui.label(format!(
|
||||
"The current system theme is: {}",
|
||||
match system_theme {
|
||||
Theme::Dark => "dark",
|
||||
Theme::Light => "light",
|
||||
}
|
||||
));
|
||||
} else {
|
||||
ui.label("The system theme is unknown.");
|
||||
}
|
||||
});
|
||||
|
||||
ui.selectable_value(self, Self::Dark, "🌙 Dark")
|
||||
.on_hover_text("Use the dark mode theme");
|
||||
|
||||
ui.selectable_value(self, Self::Light, "☀ Light")
|
||||
.on_hover_text("Use the light mode theme");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue