1- use makepad_widgets:: * ;
1+ //! The RoomsSideBar is the widget that contains the RoomsList and other items.
2+ //!
3+ //! It differs in what content it includes based on the adaptive view:
4+ //! * On a narrow mobile view, it acts as the root_view of StackNavigation
5+ //! * It includes a title label, a search bar, and the RoomsList.
6+ //! * On a wide desktop view, it acts as a permanent tab that is on the left side of the dock.
7+ //! * It only includes a title label and the RoomsList, because the SearcBar
8+ //! is at the top of the HomeScreen in Desktop view.
29
3- use crate :: shared :: search_bar :: SearchBarAction ;
10+ use makepad_widgets :: * ;
411
512live_design ! {
613 use link:: theme:: * ;
@@ -9,94 +16,62 @@ live_design! {
916
1017 use crate :: shared:: styles:: * ;
1118 use crate :: shared:: helpers:: * ;
12- use crate :: shared:: search_bar :: SearchBar ;
19+ use crate :: shared:: room_filter_input_bar :: RoomFilterInputBar ;
1320
1421 use crate :: home:: rooms_list:: RoomsList ;
1522
16- RoomsView = { { RoomsView } } {
17- show_bg: true ,
18- draw_bg: {
19- instance bg_color: ( COLOR_PRIMARY )
20- instance border_color: #f2f2f2
21- instance border_size: 0.003
23+ pub RoomsSideBar = <AdaptiveView > {
24+ Desktop = <View > {
25+ padding: { top: 20 , left: 10 , right: 10 }
26+ flow: Down , spacing: 10
27+ width: Fill , height: Fill
28+
29+ show_bg: true ,
30+ draw_bg: {
31+ instance bg_color: ( COLOR_PRIMARY )
32+ instance border_color: #f2f2f2
33+ instance border_size: 0.003
2234
23- // Draws a right-side border
24- fn pixel( self ) -> vec4 {
25- if self . pos. x > 1.0 - self . border_size {
26- return self . border_color;
27- } else {
28- return self . bg_color;
35+ // Draws a right-side border
36+ fn pixel( self ) -> vec4 {
37+ if self . pos. x > 1.0 - self . border_size {
38+ return self . border_color;
39+ } else {
40+ return self . bg_color;
41+ }
2942 }
3043 }
31- }
32- <Label > {
33- text: "All Rooms"
34- draw_text: {
35- color: #x0
36- text_style: <TITLE_TEXT >{ }
44+
45+ sidebar_title = <Label > {
46+ text: "All Rooms"
47+ draw_text: {
48+ color: #x0
49+ text_style: <TITLE_TEXT >{ }
50+ }
3751 }
38- }
39- search_bar = <SearchBar > {
40- input = {
41- empty_message: "Filter rooms..."
52+ <CachedWidget > {
53+ rooms_list = <RoomsList > { }
4254 }
43- }
44- <CachedWidget > {
45- rooms_list = <RoomsList > { }
46- }
47- }
48-
49- pub RoomsSideBar = <AdaptiveView > {
50- Desktop = <RoomsView > {
51- padding: { top: 20. , left: 10. , right: 10. }
52- flow: Down , spacing: 10
53- width: Fill , height: Fill
5455 } ,
55- Mobile = <RoomsView > {
56- padding: { top: 17. , left: 17. , right: 17. }
56+
57+ Mobile = <View > {
58+ padding: { top: 17 , left: 17 , right: 17 }
5759 flow: Down , spacing: 7
5860 width: Fill , height: Fill
59- }
60- }
61- }
62-
63- #[ derive( Clone , Debug , DefaultNone ) ]
64- pub enum RoomsViewAction {
65- /// Search for rooms
66- Search ( String ) ,
67- None ,
68- }
69-
70- #[ derive( Widget , Live , LiveHook ) ]
71- pub struct RoomsView {
72- #[ deref]
73- view : View ,
74- }
7561
76- impl Widget for RoomsView {
77- fn handle_event ( & mut self , cx : & mut Cx , event : & Event , scope : & mut Scope ) {
78- self . view . handle_event ( cx, event, scope) ;
79- self . widget_match_event ( cx, event, scope) ;
80- }
81-
82- fn draw_walk ( & mut self , cx : & mut Cx2d , scope : & mut Scope , walk : Walk ) -> DrawStep {
83- self . view . draw_walk ( cx, scope, walk)
84- }
85- }
86-
87- impl WidgetMatchEvent for RoomsView {
88- fn handle_actions ( & mut self , cx : & mut Cx , actions : & Actions , scope : & mut Scope ) {
89- let widget_uid = self . widget_uid ( ) ;
90- for action in actions {
91- match action. as_widget_action ( ) . cast ( ) {
92- SearchBarAction :: Search ( keywords) => {
93- cx. widget_action ( widget_uid, & scope. path , RoomsViewAction :: Search ( keywords. clone ( ) ) ) ;
62+ sidebar_title = <Label > {
63+ text: "All Rooms"
64+ draw_text: {
65+ color: #x0
66+ text_style: <TITLE_TEXT >{ }
9467 }
95- SearchBarAction :: ResetSearch => {
96- cx. widget_action ( widget_uid, & scope. path , RoomsViewAction :: Search ( "" . to_string ( ) ) ) ;
97- }
98- _ => { }
68+ }
69+ <CachedWidget > {
70+ <RoomFilterInputBar > { }
71+ }
72+ <CachedWidget > {
73+ rooms_list = <RoomsList > { }
9974 }
10075 }
10176 }
102- }
77+ }
0 commit comments