extract workspace crates and switch to gpui-native-kit
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "signed_app"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
assets = { path = "../assets" }
|
||||
metadata = { path = "../metadata" }
|
||||
paths = { path = "../paths" }
|
||||
settings = { path = "../settings" }
|
||||
signed_core = { path = "../signed_core" }
|
||||
signed_git = { path = "../signed_git" }
|
||||
signed_nostr = { path = "../signed_nostr" }
|
||||
signed_state = { path = "../signed_state" }
|
||||
utils = { path = "../utils" }
|
||||
|
||||
gpui.workspace = true
|
||||
gpui-native-kit.workspace = true
|
||||
anyhow.workspace = true
|
||||
futures.workspace = true
|
||||
log.workspace = true
|
||||
@@ -0,0 +1,55 @@
|
||||
use gpui::{
|
||||
App, AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render, Styled as _,
|
||||
Window, div,
|
||||
};
|
||||
use gpui_native_kit::empty_state::EmptyState;
|
||||
use gpui_native_kit::layout::dock::DockState;
|
||||
use gpui_native_kit::layout::shell::{LayoutState, Shell};
|
||||
use gpui_native_kit::theme::{ActiveTheme as _, ThemeVariant, follow_system, set_mode_override};
|
||||
use settings::{AppearanceMode, Settings};
|
||||
|
||||
use crate::dialogs::DialogHost;
|
||||
|
||||
pub struct AppRoot {
|
||||
layout: Entity<LayoutState>,
|
||||
dock: Entity<DockState>,
|
||||
dialogs: Entity<DialogHost>,
|
||||
}
|
||||
|
||||
impl AppRoot {
|
||||
pub fn new(_window: &mut Window, cx: &mut App) -> Self {
|
||||
let layout = LayoutState::new(cx);
|
||||
let dock = DockState::new(cx);
|
||||
let dialogs = cx.new(DialogHost::new);
|
||||
DialogHost::set_global(dialogs.clone(), cx);
|
||||
|
||||
Self {
|
||||
layout,
|
||||
dock,
|
||||
dialogs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for AppRoot {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
div()
|
||||
.size_full()
|
||||
.font_family(".SystemUIFont")
|
||||
.text_color(theme.colors.foreground)
|
||||
.child(
|
||||
Shell::new("signed-shell", self.layout.clone())
|
||||
.center(EmptyState::new("Signed").hint("UI migration in progress")),
|
||||
)
|
||||
.child(self.dialogs.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply_appearance(settings: &Settings, cx: &mut App) {
|
||||
match settings.appearance {
|
||||
AppearanceMode::System => follow_system(cx),
|
||||
AppearanceMode::Light => set_mode_override(Some(ThemeVariant::Light), cx),
|
||||
AppearanceMode::Dark => set_mode_override(Some(ThemeVariant::Dark), cx),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyView, App, Context, Entity, Global, IntoElement, ParentElement as _, Render, Styled as _,
|
||||
Window, div,
|
||||
};
|
||||
|
||||
struct GlobalDialogHost(Entity<DialogHost>);
|
||||
|
||||
impl Global for GlobalDialogHost {}
|
||||
|
||||
/// Owns the modal currently mounted at the window root.
|
||||
pub struct DialogHost {
|
||||
open: Option<AnyView>,
|
||||
}
|
||||
|
||||
impl DialogHost {
|
||||
pub fn new(_cx: &mut Context<Self>) -> Self {
|
||||
Self { open: None }
|
||||
}
|
||||
|
||||
pub fn set_global(entity: Entity<Self>, cx: &mut App) {
|
||||
cx.set_global(GlobalDialogHost(entity));
|
||||
}
|
||||
|
||||
pub fn global(cx: &App) -> Entity<Self> {
|
||||
cx.global::<GlobalDialogHost>().0.clone()
|
||||
}
|
||||
|
||||
pub fn open(&mut self, view: AnyView, cx: &mut Context<Self>) {
|
||||
self.open = Some(view);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn close(&mut self, cx: &mut Context<Self>) {
|
||||
self.open = None;
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for DialogHost {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
div()
|
||||
.absolute()
|
||||
.inset_0()
|
||||
.when_some(self.open.clone(), |host, view| host.child(view))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
mod app;
|
||||
mod dialogs;
|
||||
mod panels;
|
||||
mod views;
|
||||
|
||||
pub use app::{AppRoot, apply_appearance};
|
||||
|
||||
use gpui::{App, AppContext as _, Entity, Window};
|
||||
|
||||
pub fn root(window: &mut Window, cx: &mut App) -> Entity<AppRoot> {
|
||||
cx.new(|cx| AppRoot::new(window, cx))
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user