refactor: consolidate shared ui helpers and prune unused code
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
use gpui::App;
|
||||
use settings::{AppearanceMode, Settings};
|
||||
use settings::AppearanceMode;
|
||||
use ui::theme::{ThemeVariant, follow_system, set_mode_override};
|
||||
|
||||
/// Applies the persisted light/dark/system preference to the kit theme.
|
||||
pub fn apply_appearance(settings: &Settings, cx: &mut App) {
|
||||
apply_appearance_mode(settings.appearance, cx);
|
||||
}
|
||||
|
||||
/// Applies one appearance mode to the kit theme.
|
||||
pub fn apply_appearance_mode(mode: AppearanceMode, cx: &mut App) {
|
||||
match mode {
|
||||
|
||||
@@ -7,7 +7,7 @@ use gpui::{
|
||||
AppContext as _, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _,
|
||||
Render, Styled as _, Subscription, Window, div, px,
|
||||
};
|
||||
use helpers::apply_appearance;
|
||||
use helpers::apply_appearance_mode;
|
||||
use settings::SettingsStore;
|
||||
use signed_state::{Backend, BackendEvent};
|
||||
use ui::common::h_flex;
|
||||
@@ -82,7 +82,7 @@ impl AppRoot {
|
||||
|
||||
subscriptions.push(cx.observe(&settings, |_this, store, cx| {
|
||||
let settings = store.read(cx).settings().clone();
|
||||
apply_appearance(&settings, cx);
|
||||
apply_appearance_mode(settings.appearance, cx);
|
||||
}));
|
||||
|
||||
let app = cx.entity().downgrade();
|
||||
|
||||
@@ -45,15 +45,6 @@ impl Panel for SignedOutView {
|
||||
}
|
||||
}
|
||||
|
||||
/// One of the three banner photos, picked per process launch.
|
||||
fn pick_banner() -> SharedString {
|
||||
let nanos = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|now| now.subsec_nanos())
|
||||
.unwrap_or(0);
|
||||
format!("backgrounds/banner{}.jpg", nanos % 3 + 1).into()
|
||||
}
|
||||
|
||||
impl Render for SignedOutView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
@@ -110,3 +101,12 @@ impl Render for SignedOutView {
|
||||
.when_some(self.import.clone(), |el, view| el.child(view))
|
||||
}
|
||||
}
|
||||
|
||||
/// One of the three banner photos, picked per process launch.
|
||||
fn pick_banner() -> SharedString {
|
||||
let nanos = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|now| now.subsec_nanos())
|
||||
.unwrap_or(0);
|
||||
format!("backgrounds/banner{}.jpg", nanos % 3 + 1).into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user