From 17e7766401fadf89f92ffcf5d6b0fcd45f950150 Mon Sep 17 00:00:00 2001 From: reya Date: Sat, 23 Nov 2024 14:43:16 +0700 Subject: [PATCH] wip: sidebar --- .DS_Store | Bin 6148 -> 6148 bytes assets/.DS_Store | Bin 0 -> 6148 bytes assets/icons/explore.svg | 3 + assets/icons/messages.svg | 4 + assets/icons/notifications.svg | 3 + assets/icons/search.svg | 3 + crates/ui/Cargo.toml | 1 + crates/ui/src/main.rs | 2 + crates/ui/src/views/chat_space/mod.rs | 14 +--- crates/ui/src/views/chat_space/navigation.rs | 83 +++++++++++++++++++ 10 files changed, 103 insertions(+), 10 deletions(-) create mode 100644 assets/.DS_Store create mode 100644 assets/icons/explore.svg create mode 100644 assets/icons/messages.svg create mode 100644 assets/icons/notifications.svg create mode 100644 assets/icons/search.svg create mode 100644 crates/ui/src/views/chat_space/navigation.rs diff --git a/.DS_Store b/.DS_Store index ca558bffc85d42e6d77ae5c79ab567e5519b2c55..4de7a025d2c46811ea31e708fcb7a7790949c6f2 100644 GIT binary patch delta 420 zcmZ8dI}gE77(Mq^>Jf=b#AfgVG*+WvkYHdjdd8sAXuDf%7LDCvBr)_C_)P{eaoR?r z_ddS+_|Ez6xo2PB*N^ zCmKyo^Ak1Tlo!uk4lUvxtYE{0#W=@0EcwT}|FgJHay)W2u#y~6Q8+s5I(*5au1IoR ze;3LU2L+r)4_ylDV1N-iO6j+P&SFSp6K(XlniR80GUQ5O=#&wEx`@@( dLj>teAw%zZcxk6XsbSE1jwr}*4aTLL_5~!cY$gBz delta 92 zcmZoMXfc=|#>B`mu~2NHo}wTV0|Nsi1A_nqLkUB1Qh9N~#Dvw84MbQbTeE!FEW#no ova#VS<7Rdaeh#3X&4L`?nJ4p$SOS%UwSjblw6koE5Lv?v0PAfNo&W#< diff --git a/assets/.DS_Store b/assets/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7d1d964ec7c44cd0b1a870e466265619cce828bf GIT binary patch literal 6148 zcmeHKTT22#6rNGb5ea-K=y9M|A&s)6m(A><$J!|9g1N5b(z+wAW+1{o^i;p4*XS4Y z6Z$)K=3;1ed65V?2hMzF&YUxsZ-~LI?wu7)wF%g~)cP6B09?Bp_9N zg!{gzIlgcvV$tzG8IXH7M?6v^f&^rA|Kum}2phZerbJDDB+}`HEwj_lPRsYgPA>OK zWAVh?e3B(unqAlp(X%_%PB$!7+h?+NB!uq_?W%L^)q9o9;;slfRWGQwRf6Z%A>{nT z3tZ7FiEiMAD%aKxEX7il%yPfKRxD(BzK|Pad4H?8p5=v&&A}kWmR44`4=dMxGZ6Qh zathz3k_Cf9cmQK$MgCRZu8C%A*gW3a6y>s6FH0WWoj%>Z?0k-Je~D-{ej4G%ZU?>y zuAtZ9j7O$|CNh8wAOllmz??EHJ;gq;D`Wr}m<ga$%Jplj{;8p^* z{Be{y+@NJJ(g-aeRHp*!RBE0WRHuWVn>fp0q*136Y91fdj7-f7g{sk^f3Cs_wKQUh z3?KvJ48(OcBk%vc@8AF9NmxS$kb#+EfF{azxdclxck9IB + + diff --git a/assets/icons/messages.svg b/assets/icons/messages.svg new file mode 100644 index 0000000..fe6207c --- /dev/null +++ b/assets/icons/messages.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/icons/notifications.svg b/assets/icons/notifications.svg new file mode 100644 index 0000000..8e48c04 --- /dev/null +++ b/assets/icons/notifications.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/search.svg b/assets/icons/search.svg new file mode 100644 index 0000000..2ad28af --- /dev/null +++ b/assets/icons/search.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index 7418574..7f8d2aa 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -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" diff --git a/crates/ui/src/main.rs b/crates/ui/src/main.rs index 32d13b6..297fb22 100644 --- a/crates/ui/src/main.rs +++ b/crates/ui/src/main.rs @@ -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 diff --git a/crates/ui/src/views/chat_space/mod.rs b/crates/ui/src/views/chat_space/mod.rs index 2592517..3d36288 100644 --- a/crates/ui/src/views/chat_space/mod.rs +++ b/crates/ui/src/views/chat_space/mod.rs @@ -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, @@ -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() }), diff --git a/crates/ui/src/views/chat_space/navigation.rs b/crates/ui/src/views/chat_space/navigation.rs new file mode 100644 index 0000000..9ad2abd --- /dev/null +++ b/crates/ui/src/views/chat_space/navigation.rs @@ -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) -> 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), + )), + ), + ) + } +}