chore: small fixes
This commit is contained in:
@@ -39,7 +39,6 @@ pub enum DeviceState {
|
||||
|
||||
impl DeviceState {
|
||||
pub fn subscribe(&self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
log::info!("Device State: {:?}", self);
|
||||
match self {
|
||||
Self::Master => {
|
||||
let client = get_client();
|
||||
@@ -156,25 +155,7 @@ pub fn init(window: &mut Window, cx: &App) {
|
||||
|
||||
cx.update(|cx| {
|
||||
let state = cx.new(|_| DeviceState::None);
|
||||
|
||||
window_handle
|
||||
.update(cx, |_, window, cx| {
|
||||
// Open the onboarding view
|
||||
Root::update(window, cx, |this, window, cx| {
|
||||
this.replace_view(onboarding::init(window, cx).into());
|
||||
cx.notify();
|
||||
});
|
||||
|
||||
window
|
||||
.observe(&state, cx, |this, window, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
this.subscribe(window, cx);
|
||||
});
|
||||
})
|
||||
.detach();
|
||||
})
|
||||
.ok();
|
||||
|
||||
let weak_state = state.downgrade();
|
||||
let requesters = cx.new(|_| HashSet::new());
|
||||
let entity = cx.new(|_| Device {
|
||||
profile: None,
|
||||
@@ -192,6 +173,18 @@ pub fn init(window: &mut Window, cx: &App) {
|
||||
cx.notify();
|
||||
});
|
||||
|
||||
// Observe the DeviceState changes
|
||||
if let Some(state) = weak_state.upgrade() {
|
||||
window
|
||||
.observe(&state, cx, |this, window, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
this.subscribe(window, cx);
|
||||
});
|
||||
})
|
||||
.detach();
|
||||
};
|
||||
|
||||
// Observe the Device changes
|
||||
window
|
||||
.observe(&entity, cx, |this, window, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
|
||||
@@ -24,12 +24,12 @@ use nostr_sdk::{
|
||||
};
|
||||
use smol::Timer;
|
||||
use std::{collections::HashSet, mem, sync::Arc, time::Duration};
|
||||
use ui::Root;
|
||||
use ui::{theme::Theme, Root};
|
||||
use views::startup;
|
||||
|
||||
mod asset;
|
||||
mod device;
|
||||
mod views;
|
||||
pub(crate) mod asset;
|
||||
pub(crate) mod device;
|
||||
pub(crate) mod views;
|
||||
|
||||
actions!(coop, [Quit]);
|
||||
|
||||
@@ -245,6 +245,13 @@ fn main() {
|
||||
|
||||
// Open a window with default options
|
||||
cx.open_window(opts, |window, cx| {
|
||||
// Automatically sync theme with system appearance
|
||||
window
|
||||
.observe_window_appearance(|window, cx| {
|
||||
Theme::sync_system_appearance(Some(window), cx);
|
||||
})
|
||||
.detach();
|
||||
|
||||
// Initialize components
|
||||
ui::init(cx);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ impl Relays {
|
||||
if let Ok(relays) = task.await {
|
||||
_ = cx.update(|cx| {
|
||||
_ = this.update(cx, |this: &mut Vec<RelayUrl>, cx| {
|
||||
this.extend(relays);
|
||||
*this = relays;
|
||||
cx.notify();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
pub const APP_NAME: &str = "Coop";
|
||||
pub const APP_ID: &str = "su.reya.coop";
|
||||
|
||||
pub const KEYRING: &str = "Coop Safe Storage";
|
||||
pub const CLIENT_KEYRING: &str = "Coop Client Keys";
|
||||
pub const MASTER_KEYRING: &str = "Coop Master Keys";
|
||||
|
||||
|
||||
@@ -634,7 +634,18 @@ impl ButtonVariant {
|
||||
_ => cx.theme().base.step(cx, ColorScaleStep::THREE),
|
||||
};
|
||||
|
||||
let fg = cx.theme().base.step(cx, ColorScaleStep::ELEVEN);
|
||||
let fg = match self {
|
||||
ButtonVariant::Primary => match cx.theme().accent.name().to_string().as_str() {
|
||||
"Sky" => cx.theme().base.darken(cx),
|
||||
"Mint" => cx.theme().base.darken(cx),
|
||||
"Lime" => cx.theme().base.darken(cx),
|
||||
"Amber" => cx.theme().base.darken(cx),
|
||||
"Yellow" => cx.theme().base.darken(cx),
|
||||
_ => cx.theme().accent.step(cx, ColorScaleStep::ONE),
|
||||
},
|
||||
_ => cx.theme().base.step(cx, ColorScaleStep::ELEVEN),
|
||||
};
|
||||
|
||||
let border = bg;
|
||||
let underline = self.underline(window, cx);
|
||||
let shadow = false;
|
||||
|
||||
@@ -293,7 +293,10 @@ impl ColorScaleSet {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn darken(&self, _cx: &App) -> Hsla {
|
||||
self.light.step_12()
|
||||
pub fn darken(&self, cx: &App) -> Hsla {
|
||||
match cx.theme().appearance {
|
||||
Appearance::Light => self.light.step_12(),
|
||||
Appearance::Dark => self.dark.step_1(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use gpui::{
|
||||
use std::rc::Rc;
|
||||
|
||||
const HEIGHT: Pixels = px(34.);
|
||||
const TITLE_BAR_HEIGHT: Pixels = px(35.);
|
||||
const TITLE_BAR_HEIGHT: Pixels = px(34.);
|
||||
#[cfg(target_os = "macos")]
|
||||
const TITLE_BAR_LEFT_PADDING: Pixels = px(80.);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
|
||||
Reference in New Issue
Block a user