feat: use system theme

This commit is contained in:
2024-11-25 13:44:32 +07:00
parent e619fa365b
commit 91cec81f8b
3 changed files with 12 additions and 12 deletions

View File

@@ -7,9 +7,9 @@ resolver = "2"
coop = { path = "crates/*" } coop = { path = "crates/*" }
# UI # UI
gpui = { git = "https://github.com/huacnlee/zed.git", branch = "export-platform-window" } gpui = { git = "https://github.com/zed-industries/zed" }
components = { package = "ui", git = "https://github.com/longbridgeapp/gpui-component" } reqwest_client = { git = "https://github.com/zed-industries/zed" }
reqwest_client = { git = "https://github.com/huacnlee/zed.git", branch = "export-platform-window" } components = { package = "ui", git = "https://github.com/lumehq/gpui-component" }
# Nostr # Nostr
nostr-relay-builder = { git = "https://github.com/rust-nostr/nostr" } nostr-relay-builder = { git = "https://github.com/rust-nostr/nostr" }

View File

@@ -1,6 +1,5 @@
use asset::Assets; use asset::Assets;
use client::NostrClient; use client::NostrClient;
use components::theme::{Theme, ThemeColor, ThemeMode};
use constants::{APP_NAME, KEYRING_SERVICE}; use constants::{APP_NAME, KEYRING_SERVICE};
use gpui::*; use gpui::*;
use keyring::Entry; use keyring::Entry;
@@ -34,13 +33,7 @@ async fn main() {
// Initialize components // Initialize components
components::init(cx); components::init(cx);
// Set custom theme // Set global state
let mut theme = Theme::from(ThemeColor::dark());
// Set dark mode by default
theme.mode = ThemeMode::Dark;
// Set app state
cx.set_global(theme);
cx.set_global(nostr); cx.set_global(nostr);
cx.set_global(app_state); cx.set_global(app_state);

View File

@@ -1,4 +1,4 @@
use components::theme::ActiveTheme; use components::theme::{ActiveTheme, Theme};
use gpui::*; use gpui::*;
use super::{chat_space::ChatSpace, onboarding::Onboarding}; use super::{chat_space::ChatSpace, onboarding::Onboarding};
@@ -11,8 +11,15 @@ pub struct AppView {
impl AppView { impl AppView {
pub fn new(cx: &mut ViewContext<'_, Self>) -> 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 // Onboarding
let onboarding = cx.new_view(Onboarding::new); let onboarding = cx.new_view(Onboarding::new);
// Chat Space // Chat Space
let chat_space = cx.new_view(ChatSpace::new); let chat_space = cx.new_view(ChatSpace::new);