fix: panel is not focus
This commit is contained in:
@@ -20,7 +20,7 @@ use state::{get_client, initialize_client};
|
||||
use std::{borrow::Cow, collections::HashSet, ops::Deref, str::FromStr, sync::Arc, time::Duration};
|
||||
use tokio::sync::mpsc;
|
||||
use ui::{theme::Theme, Root};
|
||||
use views::{app::AppView, onboarding, startup::Startup};
|
||||
use views::{app, onboarding, startup::Startup};
|
||||
|
||||
mod asset;
|
||||
mod views;
|
||||
@@ -311,8 +311,7 @@ fn main() {
|
||||
if let Some(root) = this.root() {
|
||||
cx.update_entity(&root, |this: &mut Root, cx| {
|
||||
this.set_view(
|
||||
cx.new(|cx| AppView::new(profile, window, cx))
|
||||
.into(),
|
||||
app::init(profile, window, cx).into(),
|
||||
cx,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ use app_state::registry::AppRegistry;
|
||||
use chat_state::registry::ChatRegistry;
|
||||
use common::profile::NostrProfile;
|
||||
use gpui::{
|
||||
actions, div, img, impl_internal_actions, px, AppContext, Axis, BorrowAppContext, Context,
|
||||
actions, div, img, impl_internal_actions, px, App, AppContext, Axis, BorrowAppContext, Context,
|
||||
Entity, InteractiveElement, IntoElement, ObjectFit, ParentElement, Render, Styled, StyledImage,
|
||||
Window,
|
||||
};
|
||||
@@ -44,24 +44,18 @@ impl_internal_actions!(dock, [AddPanel]);
|
||||
// Account actions
|
||||
actions!(account, [OpenProfile, OpenContacts, OpenSettings, Logout]);
|
||||
|
||||
pub struct DockAreaTab {
|
||||
id: &'static str,
|
||||
version: usize,
|
||||
pub fn init(account: NostrProfile, window: &mut Window, cx: &mut App) -> Entity<AppView> {
|
||||
AppView::new(account, window, cx)
|
||||
}
|
||||
|
||||
pub const DOCK_AREA: DockAreaTab = DockAreaTab {
|
||||
id: "dock",
|
||||
version: 1,
|
||||
};
|
||||
|
||||
pub struct AppView {
|
||||
account: NostrProfile,
|
||||
dock: Entity<DockArea>,
|
||||
}
|
||||
|
||||
impl AppView {
|
||||
pub fn new(account: NostrProfile, window: &mut Window, cx: &mut Context<'_, Self>) -> AppView {
|
||||
let dock = cx.new(|cx| DockArea::new(DOCK_AREA.id, Some(DOCK_AREA.version), window, cx));
|
||||
pub fn new(account: NostrProfile, window: &mut Window, cx: &mut App) -> Entity<Self> {
|
||||
let dock = cx.new(|cx| DockArea::new(window, cx));
|
||||
let weak_dock = dock.downgrade();
|
||||
let left_panel = DockItem::panel(Arc::new(sidebar::init(window, cx)));
|
||||
let center_panel = DockItem::split_with_sizes(
|
||||
@@ -79,13 +73,13 @@ impl AppView {
|
||||
cx,
|
||||
);
|
||||
|
||||
// Set default dock layout
|
||||
_ = weak_dock.update(cx, |view, cx| {
|
||||
view.set_version(DOCK_AREA.version, window, cx);
|
||||
view.set_left_dock(left_panel, Some(px(240.)), true, window, cx);
|
||||
view.set_center(center_panel, window, cx);
|
||||
});
|
||||
|
||||
AppView { account, dock }
|
||||
cx.new(|_| Self { account, dock })
|
||||
}
|
||||
|
||||
fn render_account(&self) -> impl IntoElement {
|
||||
|
||||
@@ -16,7 +16,7 @@ use ui::{
|
||||
ContextModal, Root, Size, StyledExt,
|
||||
};
|
||||
|
||||
use super::app::AppView;
|
||||
use super::app;
|
||||
|
||||
const ALPHA_MESSAGE: &str = "Coop is in the alpha stage; it does not store any credentials. You will need to log in again when you reopen the app.";
|
||||
const JOIN_URL: &str = "https://start.njump.me/";
|
||||
@@ -61,10 +61,12 @@ impl Onboarding {
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
fn use_connect(&mut self, _window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.use_connect = true;
|
||||
cx.notify();
|
||||
}
|
||||
*/
|
||||
|
||||
fn use_privkey(&mut self, _window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.use_privkey = true;
|
||||
@@ -127,10 +129,7 @@ impl Onboarding {
|
||||
|
||||
if let Some(root) = this.root() {
|
||||
cx.update_entity(&root, |this: &mut Root, cx| {
|
||||
this.set_view(
|
||||
cx.new(|cx| AppView::new(profile, window, cx)).into(),
|
||||
cx,
|
||||
);
|
||||
this.set_view(app::init(profile, window, cx).into(), cx);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user