1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use dioxus::prelude::*;
use crate::components::modal::Modal;
/// Dialog for sharing a room link/permalink.
#[component]
pub fn ShareRoomDialog(
room_id: String,
room_name: String,
on_close: EventHandler<()>,
) -> Element {
let mut copied = use_signal(|| false);
// Generate matrix.to permalink
let permalink = format!("https://matrix.to/#/{room_id}");
rsx! {
Modal {
title: "Share Room".to_string(),
on_close: move |_| on_close.call(()),
div {
class: "share-room-dialog",
p {
class: "share-room-dialog__info",
"Share a link to \"{room_name}\" with others."
}
div {
class: "share-room-dialog__link-row",
input {
r#type: "text",
class: "share-room-dialog__link-input",
value: "{permalink}",
readonly: true,
}
button {
class: "btn btn--primary",
onclick: move |_| {
let link = permalink.clone();
copied.set(true);
spawn(async move {
let _ = dioxus::prelude::document::eval(
&format!("navigator.clipboard.writeText({})", serde_json::to_string(&link).unwrap_or_default()),
);
});
},
if *copied.read() { "Copied!" } else { "Copy Link" }
}
}
div {
class: "share-room-dialog__room-id",
label { "Room ID:" }
code { "{room_id}" }
}
}
}
}
}