11use makepad_widgets:: * ;
22use matrix_sdk:: ruma:: OwnedRoomId ;
33
4- use crate :: home:: rooms_list:: RoomListAction ;
4+ use crate :: {
5+ home:: rooms_list:: RoomListAction ,
6+ verification:: VerificationAction ,
7+ verification_modal:: { VerificationModalAction , VerificationModalWidgetRefExt } ,
8+ } ;
59
610live_design ! {
711 import makepad_widgets:: base:: * ;
812 import makepad_widgets:: theme_desktop_dark:: * ;
913 import makepad_draw:: shader:: std:: * ;
1014
1115 import crate :: shared:: styles:: * ;
12- import crate :: shared:: clickable_view:: ClickableView
13- import crate :: home:: home_screen:: HomeScreen
14- import crate :: home:: room_screen:: RoomScreen
15- import crate :: profile:: my_profile_screen:: MyProfileScreen
16+ import crate :: shared:: clickable_view:: ClickableView ;
17+ import crate :: home:: home_screen:: HomeScreen ;
18+ import crate :: home:: room_screen:: RoomScreen ;
19+ import crate :: profile:: my_profile_screen:: MyProfileScreen ;
20+ import crate :: verification_modal:: VerificationModal ;
1621
1722 ICON_CHAT = dep( "crate://self/resources/icons/chat.svg" )
1823 ICON_CONTACTS = dep( "crate://self/resources/icons/contacts.svg" )
@@ -103,7 +108,19 @@ live_design! {
103108 pass: { clear_color: #2 A }
104109
105110 body = {
106- home_screen = <HomeScreen > { }
111+ // A wrapper view for showing top-level app modals/dialogs/popups
112+ <View > {
113+ width: Fill , height: Fill ,
114+ flow: Overlay ,
115+
116+ home_screen = <HomeScreen > { }
117+
118+ verification_modal = <Modal > {
119+ content: {
120+ verification_modal_inner = <VerificationModal > { }
121+ }
122+ }
123+ }
107124 } // end of body
108125 }
109126 }
@@ -128,6 +145,7 @@ impl LiveRegister for App {
128145 // then other modules widgets.
129146 makepad_widgets:: live_design ( cx) ;
130147 crate :: shared:: live_design ( cx) ;
148+ crate :: verification_modal:: live_design ( cx) ;
131149 crate :: home:: live_design ( cx) ;
132150 crate :: profile:: live_design ( cx) ;
133151 }
@@ -168,7 +186,23 @@ impl MatchEvent for App {
168186 ) ;
169187 self . ui . redraw ( cx) ;
170188 }
171- _ => ( ) ,
189+ RoomListAction :: None => { }
190+ }
191+
192+ // `VerificationAction`s come from a background thread, so they are NOT widget actions.
193+ // Therefore, we cannot use `as_widget_action().cast()` to match them.
194+ match action. downcast_ref ( ) {
195+ Some ( VerificationAction :: RequestReceived ( state) ) => {
196+ self . ui . verification_modal ( id ! ( verification_modal_inner) )
197+ . initialize_with_data ( state. clone ( ) ) ;
198+ self . ui . modal ( id ! ( verification_modal) ) . open ( cx) ;
199+ }
200+ // other verification actions are handled by the verification modal itself.
201+ _ => { }
202+ }
203+
204+ if let VerificationModalAction :: Close = action. as_widget_action ( ) . cast ( ) {
205+ self . ui . modal ( id ! ( verification_modal) ) . close ( cx) ;
172206 }
173207 }
174208 }
@@ -222,3 +256,4 @@ pub struct SelectedRoom {
222256 pub id : OwnedRoomId ,
223257 pub name : Option < String > ,
224258}
259+
0 commit comments