Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b61ac643db | ||
|
|
c0cfdb8996 |
@@ -332,8 +332,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn missing_appearance_mode_falls_back_to_system() {
|
fn missing_appearance_mode_falls_back_to_dark() {
|
||||||
let settings = json_with("").unwrap();
|
let settings = json_with("").unwrap();
|
||||||
assert_eq!(settings.appearance_mode, AppearanceMode::System);
|
assert_eq!(settings.appearance_mode, AppearanceMode::Dark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,12 @@ use crate::{Theme, ThemeMode};
|
|||||||
/// it wherever their settings live; this crate never touches disk.
|
/// it wherever their settings live; this crate never touches disk.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||||
pub enum AppearanceMode {
|
pub enum AppearanceMode {
|
||||||
/// Follow the OS. The default — matches every other native app on the
|
/// Follow the OS — matches every other native app on the machine,
|
||||||
/// machine, including when the OS is set to switch at sunset.
|
/// including when the OS is set to switch at sunset.
|
||||||
#[default]
|
|
||||||
System,
|
System,
|
||||||
Light,
|
Light,
|
||||||
|
/// Paint dark regardless of the OS.
|
||||||
|
#[default]
|
||||||
Dark,
|
Dark,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ pub fn init(mode: AppearanceMode, cx: &mut App) {
|
|||||||
Theme::change(resolve(mode, system), None, cx);
|
Theme::change(resolve(mode, system), None, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The mode currently in effect (defaults to `System` before [`init`]).
|
/// The mode currently in effect (defaults to `Dark` before [`init`]).
|
||||||
pub fn mode(cx: &App) -> AppearanceMode {
|
pub fn mode(cx: &App) -> AppearanceMode {
|
||||||
cx.try_global::<AppearanceState>()
|
cx.try_global::<AppearanceState>()
|
||||||
.map(|state| state.mode)
|
.map(|state| state.mode)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ pub const TABBAR_HEIGHT: Pixels = px(36.0);
|
|||||||
pub const SIDEBAR_WIDTH: Pixels = px(240.);
|
pub const SIDEBAR_WIDTH: Pixels = px(240.);
|
||||||
|
|
||||||
pub fn init(cx: &mut App) {
|
pub fn init(cx: &mut App) {
|
||||||
appearance::init(AppearanceMode::System, cx);
|
appearance::init(AppearanceMode::default(), cx);
|
||||||
Theme::sync_scrollbar_appearance(cx);
|
Theme::sync_scrollbar_appearance(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[derive(Debug, Clone, Copy, Default, PartialEq, PartialOrd, Eq, Hash, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Copy, Default, PartialEq, PartialOrd, Eq, Hash, Deserialize, Serialize)]
|
||||||
pub enum ThemeMode {
|
pub enum ThemeMode {
|
||||||
#[default]
|
#[default]
|
||||||
Light,
|
|
||||||
Dark,
|
Dark,
|
||||||
|
Light,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ThemeMode {
|
impl ThemeMode {
|
||||||
|
|||||||
+13
-19
@@ -6,7 +6,7 @@ use gpui::{
|
|||||||
Pixels, RenderOnce, SharedString, StyleRefinement, Styled, Window, div, px, transparent_black,
|
Pixels, RenderOnce, SharedString, StyleRefinement, Styled, Window, div, px, transparent_black,
|
||||||
};
|
};
|
||||||
use gpui_base::{DialogBackdrop, DialogPopup, DialogTitle};
|
use gpui_base::{DialogBackdrop, DialogPopup, DialogTitle};
|
||||||
use theme::{ActiveTheme, SCRIM_ALPHA_DARK, hairline, scrim, surface_radius, surface_shadows};
|
use theme::{ActiveTheme, SCRIM_ALPHA_DARK, scrim, surface_radius, surface_shadows};
|
||||||
|
|
||||||
use crate::button::{Button, ButtonCustomVariant, ButtonVariant, ButtonVariants as _};
|
use crate::button::{Button, ButtonCustomVariant, ButtonVariant, ButtonVariants as _};
|
||||||
use crate::motion::DIALOG_IN;
|
use crate::motion::DIALOG_IN;
|
||||||
@@ -276,18 +276,16 @@ impl RenderOnce for Dialog {
|
|||||||
.when(self.overlay_visible, |this| {
|
.when(self.overlay_visible, |this| {
|
||||||
this.bg(scrim(SCRIM_ALPHA_DARK))
|
this.bg(scrim(SCRIM_ALPHA_DARK))
|
||||||
})
|
})
|
||||||
.with_animation(
|
.with_animation("fade-in", DIALOG_IN.animation(), move |this, delta| {
|
||||||
"fade-in",
|
this.opacity(delta)
|
||||||
DIALOG_IN.animation(),
|
});
|
||||||
move |this, delta| this.opacity(delta),
|
|
||||||
);
|
|
||||||
|
|
||||||
let card = DialogPopup::new()
|
let card = DialogPopup::new()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.bg(cx.theme().surface_dialog)
|
.bg(cx.theme().surface_dialog)
|
||||||
.border_1()
|
.border_1()
|
||||||
.border_color(hairline(0.4))
|
.border_color(cx.theme().border)
|
||||||
.rounded(px(surface_radius()))
|
.rounded(px(surface_radius()))
|
||||||
.when(cx.theme().shadow, |this| this.shadow(surface_shadows()))
|
.when(cx.theme().shadow, |this| this.shadow(surface_shadows()))
|
||||||
.min_h_24()
|
.min_h_24()
|
||||||
@@ -370,18 +368,14 @@ impl RenderOnce for Dialog {
|
|||||||
.children(footer(render_ok, render_cancel, window, cx)),
|
.children(footer(render_ok, render_cancel, window, cx)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.with_animation(
|
.with_animation("slide-down", DIALOG_IN.animation(), move |this, delta| {
|
||||||
"slide-down",
|
let y_offset = px(2.) * (delta - 1.);
|
||||||
DIALOG_IN.animation(),
|
let mut shadow = surface_shadows();
|
||||||
move |this, delta| {
|
for shadow in &mut shadow {
|
||||||
let y_offset = px(2.) * (delta - 1.);
|
shadow.color.a *= delta;
|
||||||
let mut shadow = surface_shadows();
|
}
|
||||||
for shadow in &mut shadow {
|
this.top(y_offset).shadow(shadow)
|
||||||
shadow.color.a *= delta;
|
});
|
||||||
}
|
|
||||||
this.top(y_offset).shadow(shadow)
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
gpui_base::Dialog::new(cx)
|
gpui_base::Dialog::new(cx)
|
||||||
.layer(layer_ix, is_topmost)
|
.layer(layer_ix, is_topmost)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ impl RenderOnce for Nav {
|
|||||||
cx.theme().text_muted
|
cx.theme().text_muted
|
||||||
};
|
};
|
||||||
|
|
||||||
v_flex().h_10().w_full().items_center().child(
|
v_flex().h_10().w_full().justify_center().child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.id(self.id)
|
.id(self.id)
|
||||||
.h_9()
|
.h_9()
|
||||||
|
|||||||
Reference in New Issue
Block a user