ThemeSelector · light, dark and system through the built-in catalogs, not English only
This commit is contained in:
2 files changed
+13
-5
No files matched your search
@@ -100,6 +100,9 @@ const EN: &[(&str, &str)] = &[
|
||||
("git.stash.pop", "Pop"),
|
||||
("git.stash.drop", "Drop"),
|
||||
("git.stash.on", "{message} · on {branch}"),
|
||||
("theme.light", "Light"),
|
||||
("theme.dark", "Dark"),
|
||||
("theme.system", "System"),
|
||||
];
|
||||
|
||||
const ZH_CN: &[(&str, &str)] = &[
|
||||
@@ -198,6 +201,9 @@ const ZH_CN: &[(&str, &str)] = &[
|
||||
("git.stash.pop", "弹出"),
|
||||
("git.stash.drop", "删除"),
|
||||
("git.stash.on", "{message} · 在 {branch}"),
|
||||
("theme.light", "浅色"),
|
||||
("theme.dark", "深色"),
|
||||
("theme.system", "跟随系统"),
|
||||
];
|
||||
|
||||
/// Ely's message for `key`; English if unshipped, fails if unknown.
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::{
|
||||
buttons::{IconButton, SegmentedControl},
|
||||
canvas::color_well,
|
||||
forms::{ColorPalette, Slider},
|
||||
i18n,
|
||||
primitives::IconName,
|
||||
theme::{ActiveTheme, Density, Mode, TextSize},
|
||||
};
|
||||
@@ -22,10 +23,11 @@ pub enum Appearance {
|
||||
}
|
||||
|
||||
impl Appearance {
|
||||
/// Each with its value, catalog key and icon.
|
||||
const ALL: [(Appearance, &'static str, IconName); 3] = [
|
||||
(Appearance::Light, "Light", IconName::Sun),
|
||||
(Appearance::Dark, "Dark", IconName::Moon),
|
||||
(Appearance::System, "System", IconName::Monitor),
|
||||
(Appearance::Light, "theme.light", IconName::Sun),
|
||||
(Appearance::Dark, "theme.dark", IconName::Moon),
|
||||
(Appearance::System, "theme.system", IconName::Monitor),
|
||||
];
|
||||
|
||||
/// The mode it shows when the system is in `system`.
|
||||
@@ -63,7 +65,7 @@ impl ThemeSelector {
|
||||
}
|
||||
|
||||
impl RenderOnce for ThemeSelector {
|
||||
fn render(self, _: &mut Window, _: &mut App) -> impl IntoElement {
|
||||
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let on_change = self.on_change;
|
||||
let (_, words, _) = Appearance::ALL
|
||||
.iter()
|
||||
@@ -73,7 +75,7 @@ impl RenderOnce for ThemeSelector {
|
||||
.iter()
|
||||
.fold(
|
||||
SegmentedControl::new(self.id, *words),
|
||||
|control, (_, words, icon)| control.segment(*words, *words, Some(*icon)),
|
||||
|control, (_, words, icon)| control.segment(*words, i18n::text(cx, words, &[]), Some(*icon)),
|
||||
)
|
||||
.on_change(move |value, window, cx| {
|
||||
let (chosen, _, _) = Appearance::ALL
|
||||
|
||||
Reference in new issue
Block a user