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

@@ -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);

View File

@@ -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);