Skip to content

Commit

Permalink
Merge pull request #181 from joulei/introduce-dock-for-desktop-ui
Browse files Browse the repository at this point in the history
Multi-pane rooms: Introduce Dock for desktop UI
  • Loading branch information
kevinaboos authored Oct 11, 2024
2 parents 0fee755 + 46c99a6 commit 9bfcb89
Show file tree
Hide file tree
Showing 10 changed files with 685 additions and 98 deletions.
17 changes: 14 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use makepad_widgets::*;
use matrix_sdk::ruma::OwnedRoomId;

use crate::{
home::rooms_list::RoomListAction,
home::{main_desktop_ui::RoomsPanelAction, rooms_list::RoomListAction},
verification::VerificationAction,
verification_modal::{VerificationModalAction, VerificationModalWidgetRefExt},
};
Expand All @@ -13,9 +13,7 @@ live_design! {
import makepad_draw::shader::std::*;

import crate::shared::styles::*;
import crate::shared::clickable_view::ClickableView;
import crate::home::home_screen::HomeScreen;
import crate::home::room_screen::RoomScreen;
import crate::profile::my_profile_screen::MyProfileScreen;
import crate::verification_modal::VerificationModal;

Expand Down Expand Up @@ -189,6 +187,19 @@ impl MatchEvent for App {
RoomListAction::None => { }
}

match action.as_widget_action().cast() {
RoomsPanelAction::RoomFocused(room_id) => {
self.app_state.rooms_panel.selected_room = Some(SelectedRoom {
id: room_id.clone(),
name: None
});
}
RoomsPanelAction::FocusNone => {
self.app_state.rooms_panel.selected_room = None;
}
_ => { }
}

// `VerificationAction`s come from a background thread, so they are NOT widget actions.
// Therefore, we cannot use `as_widget_action().cast()` to match them.
match action.downcast_ref() {
Expand Down
26 changes: 17 additions & 9 deletions src/home/home_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ live_design! {
import makepad_widgets::theme_desktop_dark::*;
import makepad_draw::shader::std::*;

import crate::home::main_content::MainContent;
import crate::home::main_mobile_ui::MainMobileUI;
import crate::home::rooms_sidebar::RoomsSideBar;
import crate::home::spaces_dock::SpacesDock;
import crate::shared::styles::*;
import crate::shared::adaptive_view::AdaptiveView;
import crate::shared::search_bar::SearchBar;
import crate::home::main_desktop_ui::MainDesktopUI;

NavigationWrapper = {{NavigationWrapper}} {
view_stack = <StackNavigation> {}
Expand All @@ -24,10 +26,15 @@ live_design! {
width: Fill, height: Fill
padding: 0, margin: 0, align: {x: 0.0, y: 0.0}
flow: Right

spaces = <SpacesDock> {}
rooms_sidebar = <RoomsSideBar> {}
main_content = <MainContent> {}

<View> {
flow: Down
width: Fill, height: Fill
<SearchBar> {}
<MainDesktopUI> {}
}
}

Mobile = {
Expand All @@ -47,11 +54,11 @@ live_design! {
sidebar = <RoomsSideBar> {}
spaces = <SpacesDock> {}
}

main_content_view = <StackNavigationView> {
width: Fill, height: Fill
body = {
main_content = <MainContent> {}
main_content = <MainMobileUI> {}
}
}
}
Expand All @@ -63,7 +70,7 @@ live_design! {
#[derive(Live, LiveHook, Widget)]
pub struct NavigationWrapper {
#[deref]
view: View
view: View,
}

impl Widget for NavigationWrapper {
Expand All @@ -77,7 +84,8 @@ impl Widget for NavigationWrapper {
}

impl MatchEvent for NavigationWrapper {
fn handle_actions(&mut self, cx: &mut Cx, actions:&Actions) {
self.stack_navigation(id!(view_stack)).handle_stack_view_actions(cx, actions);
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions) {
self.stack_navigation(id!(view_stack))
.handle_stack_view_actions(cx, actions);
}
}
Loading

0 comments on commit 9bfcb89

Please sign in to comment.