wip: sidebar
This commit is contained in:
@@ -22,3 +22,4 @@ reqwest_client.workspace = true
|
||||
|
||||
client = { version = "0.1.0", path = "../client" }
|
||||
rust-embed = "8.5.0"
|
||||
env_logger = "0.11.5"
|
||||
|
||||
@@ -15,6 +15,8 @@ actions!(main_menu, [Quit]);
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
// Initialize nostr client
|
||||
let nostr = NostrClient::init().await;
|
||||
// Initializ app state
|
||||
|
||||
@@ -4,8 +4,10 @@ use components::{
|
||||
theme::ActiveTheme,
|
||||
};
|
||||
use gpui::*;
|
||||
use navigation::Navigation;
|
||||
|
||||
pub mod bottom_bar;
|
||||
pub mod navigation;
|
||||
|
||||
pub struct ChatSpace {
|
||||
layout: View<ResizablePanelGroup>,
|
||||
@@ -13,8 +15,8 @@ pub struct ChatSpace {
|
||||
|
||||
impl ChatSpace {
|
||||
pub fn new(cx: &mut ViewContext<'_, Self>) -> Self {
|
||||
let navigation = cx.new_view(Navigation::new);
|
||||
let bottom_bar = cx.new_view(BottomBar::new);
|
||||
// TODO: add chat list view
|
||||
|
||||
let layout = cx.new_view(|cx| {
|
||||
h_resizable(cx)
|
||||
@@ -25,15 +27,7 @@ impl ChatSpace {
|
||||
.bg(cx.theme().secondary)
|
||||
.flex()
|
||||
.flex_col()
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.w_full()
|
||||
.child("Chat List"),
|
||||
)
|
||||
.child(navigation.clone())
|
||||
.child(bottom_bar.clone())
|
||||
.into_any_element()
|
||||
}),
|
||||
|
||||
83
crates/ui/src/views/chat_space/navigation.rs
Normal file
83
crates/ui/src/views/chat_space/navigation.rs
Normal file
@@ -0,0 +1,83 @@
|
||||
use components::{theme::ActiveTheme, Icon, IconName};
|
||||
use gpui::*;
|
||||
|
||||
#[derive(IntoElement)]
|
||||
struct NavItem {
|
||||
text: SharedString,
|
||||
icon: Icon,
|
||||
}
|
||||
|
||||
impl NavItem {
|
||||
pub fn new(text: SharedString, icon: Icon) -> Self {
|
||||
Self { text, icon }
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderOnce for NavItem {
|
||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||
div()
|
||||
.hover(|this| this.bg(cx.theme().background))
|
||||
.rounded_md()
|
||||
.flex()
|
||||
.items_center()
|
||||
.h_7()
|
||||
.px_2()
|
||||
.gap_2()
|
||||
.child(self.icon)
|
||||
.child(div().pt(px(2.)).child(self.text))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Navigation {}
|
||||
|
||||
impl Navigation {
|
||||
pub fn new(cx: &mut ViewContext<'_, Self>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for Navigation {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||
div().flex_1().w_full().px_2().child(div().h_11()).child(
|
||||
div().flex().flex_col().gap_4().child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_1()
|
||||
.text_sm()
|
||||
.child(NavItem::new(
|
||||
"Find".into(),
|
||||
Icon::new(IconName::Search)
|
||||
.path("icons/search.svg")
|
||||
.size_4()
|
||||
.flex_shrink_0()
|
||||
.text_color(cx.theme().foreground),
|
||||
))
|
||||
.child(NavItem::new(
|
||||
"Messages".into(),
|
||||
Icon::new(IconName::Search)
|
||||
.path("icons/messages.svg")
|
||||
.size_4()
|
||||
.flex_shrink_0()
|
||||
.text_color(cx.theme().foreground),
|
||||
))
|
||||
.child(NavItem::new(
|
||||
"Notifications".into(),
|
||||
Icon::new(IconName::Search)
|
||||
.path("icons/notifications.svg")
|
||||
.size_4()
|
||||
.flex_shrink_0()
|
||||
.text_color(cx.theme().foreground),
|
||||
))
|
||||
.child(NavItem::new(
|
||||
"explore".into(),
|
||||
Icon::new(IconName::Search)
|
||||
.path("icons/explore.svg")
|
||||
.size_4()
|
||||
.flex_shrink_0()
|
||||
.text_color(cx.theme().foreground),
|
||||
)),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user