Skip to content

Commit 1cb43bb

Browse files
authored
Merge pull request #173 from kevinaboos/device_verification_via_emoji
Implement device verification
2 parents df4f372 + 129cc4f commit 1cb43bb

18 files changed

Lines changed: 930 additions & 191 deletions

Cargo.lock

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ version = "0.0.1-pre-alpha"
1616
metadata.makepad-auto-version = "zqpv-Yj-K7WNVK2I8h5Okhho46Q="
1717

1818
[dependencies]
19-
makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik" }
19+
# makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik" }
20+
makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "modal_sends_dismissed_action_to_inner_modal_content" }
21+
2022
## Including this crate automatically configures all `robius-*` crates to work with Makepad.
2123
robius-use-makepad = "0.1.0"
2224
robius-open = "0.1.0"

resources/icons/checkmark.svg

Lines changed: 9 additions & 0 deletions
Loading

src/app.rs

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
use makepad_widgets::*;
22
use 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

610
live_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: #2A}
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+

src/home/room_preview.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ live_design! {
5050
latest_message = <HtmlOrPlaintext> {
5151
padding: {top: 3.0}
5252
html_view = { html = {
53-
font_size: 9.3, line_spacing: 1.,
54-
draw_normal: { text_style: { font_size: 9.3, line_spacing: 1. } },
55-
draw_italic: { text_style: { font_size: 9.3, line_spacing: 1. } },
56-
draw_bold: { text_style: { font_size: 9.3, line_spacing: 1. } },
57-
draw_bold_italic: { text_style: { font_size: 9.3, line_spacing: 1. } },
58-
draw_fixed: { text_style: { font_size: 9.3, line_spacing: 1. } },
53+
font_size: 9.3,
54+
draw_normal: { text_style: { font_size: 9.3 } },
55+
draw_italic: { text_style: { font_size: 9.3 } },
56+
draw_bold: { text_style: { font_size: 9.3 } },
57+
draw_bold_italic: { text_style: { font_size: 9.3 } },
58+
draw_fixed: { text_style: { font_size: 9.3 } },
5959
} }
6060
plaintext_view = { pt_label = {
6161
draw_text: {
62-
text_style: { font_size: 9.5, line_spacing: 1. },
62+
text_style: { font_size: 9.5 },
6363
}
6464
text: "[Loading latest message]"
6565
} }

0 commit comments

Comments
 (0)