feat: Out-of-Box Experience (#12)

* refactor app view

* feat: onboarding

* add back buttons in onboarding
This commit is contained in:
reya
2025-03-25 12:34:39 +07:00
committed by GitHub
parent e15cbcc22c
commit 00cf7792e5
34 changed files with 1680 additions and 1920 deletions
+5 -6
View File
@@ -1,4 +1,4 @@
use chats::{registry::ChatRegistry, room::Room};
use chats::{room::Room, ChatRegistry};
use common::{profile::NostrProfile, utils::random_name};
use global::{constants::DEVICE_ANNOUNCEMENT_KIND, get_client};
use gpui::{
@@ -166,13 +166,12 @@ impl Compose {
if let Ok(event) = event.await {
_ = cx.update_window(window_handle, |_, window, cx| {
// Stop loading spinner
_ = this.update(cx, |this, cx| {
this.update(cx, |this, cx| {
this.set_submitting(false, cx);
});
})
.ok();
let Some(chats) = ChatRegistry::global(cx) else {
return;
};
let chats = ChatRegistry::global(cx);
let room = Room::new(&event, cx);
chats.update(cx, |state, cx| {
+60 -63
View File
@@ -1,4 +1,4 @@
use chats::{registry::ChatRegistry, room::Room};
use chats::{room::Room, ChatRegistry};
use compose::Compose;
use gpui::{
div, img, percentage, prelude::FluentBuilder, px, relative, uniform_list, AnyElement, App,
@@ -15,7 +15,7 @@ use ui::{
ContextModal, Disableable, Icon, IconName, Sizable, StyledExt,
};
use super::app::AddPanel;
use crate::chat_space::{AddPanel, PanelKind};
mod compose;
@@ -159,7 +159,7 @@ impl Sidebar {
fn open(&self, id: u64, window: &mut Window, cx: &mut Context<Self>) {
window.dispatch_action(
Box::new(AddPanel::new(
super::app::PanelKind::Room(id),
PanelKind::Room(id),
ui::dock_area::dock::DockPlacement::Center,
)),
cx,
@@ -278,69 +278,66 @@ impl Render for Sidebar {
})),
)
.when(!self.is_collapsed, |this| {
this.flex_1()
.w_full()
.when_some(ChatRegistry::global(cx), |this, state| {
let is_loading = state.read(cx).is_loading();
let len = state.read(cx).rooms().len();
this.flex_1().w_full().map(|this| {
let state = ChatRegistry::global(cx);
let is_loading = state.read(cx).is_loading();
let len = state.read(cx).rooms().len();
if is_loading {
this.children(self.render_skeleton(5))
} else if state.read(cx).rooms().is_empty() {
this.child(
div()
.px_1()
.w_full()
.h_20()
.flex()
.flex_col()
.items_center()
.justify_center()
.text_center()
.rounded(px(cx.theme().radius))
.bg(cx.theme().base.step(cx, ColorScaleStep::THREE))
.child(
div()
.text_xs()
.font_semibold()
.line_height(relative(1.2))
.child("No chats"),
)
.child(
div()
.text_xs()
.text_color(
cx.theme()
.base
.step(cx, ColorScaleStep::ELEVEN),
)
.child("Recent chats will appear here."),
),
)
} else {
this.child(
uniform_list(
entity,
"rooms",
len,
move |this, range, _, cx| {
let mut items = vec![];
for ix in range {
if let Some(room) =
state.read(cx).rooms().get(ix)
{
items.push(this.render_room(ix, room, cx));
}
}
items
},
if is_loading {
this.children(self.render_skeleton(5))
} else if state.read(cx).rooms().is_empty() {
this.child(
div()
.px_1()
.w_full()
.h_20()
.flex()
.flex_col()
.items_center()
.justify_center()
.text_center()
.rounded(px(cx.theme().radius))
.bg(cx.theme().base.step(cx, ColorScaleStep::THREE))
.child(
div()
.text_xs()
.font_semibold()
.line_height(relative(1.2))
.child("No chats"),
)
.size_full(),
.child(
div()
.text_xs()
.text_color(
cx.theme()
.base
.step(cx, ColorScaleStep::ELEVEN),
)
.child("Recent chats will appear here."),
),
)
} else {
this.child(
uniform_list(
entity,
"rooms",
len,
move |this, range, _, cx| {
let mut items = vec![];
for ix in range {
if let Some(room) = state.read(cx).rooms().get(ix) {
items.push(this.render_room(ix, room, cx));
}
}
items
},
)
}
})
.size_full(),
)
}
})
}),
)
}