From 91cec81f8bfb05a2374bb82124633f5cd55b2c2c Mon Sep 17 00:00:00 2001 From: reya Date: Mon, 25 Nov 2024 13:44:32 +0700 Subject: [PATCH] feat: use system theme --- Cargo.toml | 6 +++--- crates/ui/src/main.rs | 9 +-------- crates/ui/src/views/app.rs | 9 ++++++++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b154767..7b15e19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,9 @@ resolver = "2" coop = { path = "crates/*" } # UI -gpui = { git = "https://github.com/huacnlee/zed.git", branch = "export-platform-window" } -components = { package = "ui", git = "https://github.com/longbridgeapp/gpui-component" } -reqwest_client = { git = "https://github.com/huacnlee/zed.git", branch = "export-platform-window" } +gpui = { git = "https://github.com/zed-industries/zed" } +reqwest_client = { git = "https://github.com/zed-industries/zed" } +components = { package = "ui", git = "https://github.com/lumehq/gpui-component" } # Nostr nostr-relay-builder = { git = "https://github.com/rust-nostr/nostr" } diff --git a/crates/ui/src/main.rs b/crates/ui/src/main.rs index 4cac3d0..579c7bb 100644 --- a/crates/ui/src/main.rs +++ b/crates/ui/src/main.rs @@ -1,6 +1,5 @@ use asset::Assets; use client::NostrClient; -use components::theme::{Theme, ThemeColor, ThemeMode}; use constants::{APP_NAME, KEYRING_SERVICE}; use gpui::*; use keyring::Entry; @@ -34,13 +33,7 @@ async fn main() { // Initialize components components::init(cx); - // Set custom theme - let mut theme = Theme::from(ThemeColor::dark()); - // Set dark mode by default - theme.mode = ThemeMode::Dark; - - // Set app state - cx.set_global(theme); + // Set global state cx.set_global(nostr); cx.set_global(app_state); diff --git a/crates/ui/src/views/app.rs b/crates/ui/src/views/app.rs index d8897bc..3caddea 100644 --- a/crates/ui/src/views/app.rs +++ b/crates/ui/src/views/app.rs @@ -1,4 +1,4 @@ -use components::theme::ActiveTheme; +use components::theme::{ActiveTheme, Theme}; use gpui::*; use super::{chat_space::ChatSpace, onboarding::Onboarding}; @@ -11,8 +11,15 @@ pub struct AppView { impl AppView { pub fn new(cx: &mut ViewContext<'_, Self>) -> AppView { + // Sync theme with system + cx.observe_window_appearance(|_, cx| { + Theme::sync_system_appearance(cx); + }) + .detach(); + // Onboarding let onboarding = cx.new_view(Onboarding::new); + // Chat Space let chat_space = cx.new_view(ChatSpace::new);