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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
use dioxus::prelude::*;
/// A sticker entry for display.
#[derive(Clone, Debug, PartialEq)]
struct StickerEntry {
name: String,
emoji: String,
}
/// A server-side sticker pack.
#[derive(Clone, Debug, PartialEq)]
pub struct StickerPack {
/// Display name of the sticker pack
pub name: String,
/// Avatar/icon URL for the pack (mxc:// or https://)
pub avatar_url: Option<String>,
/// Stickers in this pack
pub stickers: Vec<ServerSticker>,
}
/// A single sticker from a server-side pack.
#[derive(Clone, Debug, PartialEq)]
pub struct ServerSticker {
/// Display name of the sticker
pub name: String,
/// Image URL for the sticker (mxc:// or https://)
pub image_url: String,
/// Optional description shown on hover
pub description: Option<String>,
}
/// Built-in sticker categories with emoji-based stickers.
static BUILTIN_PACKS: &[(&str, &[(&str, &str)])] = &[
("Smileys", &[
("grinning", "\u{1f600}"), ("joy", "\u{1f602}"), ("heart_eyes", "\u{1f60d}"), ("thinking", "\u{1f914}"),
("wink", "\u{1f609}"), ("sunglasses", "\u{1f60e}"), ("party", "\u{1f973}"), ("pleading", "\u{1f97a}"),
("rage", "\u{1f621}"), ("scream", "\u{1f631}"), ("skull", "\u{1f480}"), ("clown", "\u{1f921}"),
]),
("Gestures", &[
("thumbs_up", "\u{1f44d}"), ("thumbs_down", "\u{1f44e}"), ("clap", "\u{1f44f}"), ("wave", "\u{1f44b}"),
("pray", "\u{1f64f}"), ("muscle", "\u{1f4aa}"), ("ok_hand", "\u{1f44c}"), ("point_up", "\u{261d}"),
("fist", "\u{270a}"), ("raised_hands", "\u{1f64c}"), ("shrug", "\u{1f937}"), ("facepalm", "\u{1f926}"),
]),
("Objects", &[
("heart", "\u{2764}"), ("fire", "\u{1f525}"), ("star", "\u{2b50}"), ("sparkles", "\u{2728}"),
("rocket", "\u{1f680}"), ("trophy", "\u{1f3c6}"), ("gift", "\u{1f381}"), ("balloon", "\u{1f388}"),
("bulb", "\u{1f4a1}"), ("key", "\u{1f511}"), ("hammer", "\u{1f528}"), ("shield", "\u{1f6e1}"),
]),
("Animals", &[
("cat", "\u{1f431}"), ("dog", "\u{1f436}"), ("unicorn", "\u{1f984}"), ("butterfly", "\u{1f98b}"),
("penguin", "\u{1f427}"), ("owl", "\u{1f989}"), ("fox", "\u{1f98a}"), ("bear", "\u{1f43b}"),
("monkey", "\u{1f435}"), ("rabbit", "\u{1f430}"), ("dragon", "\u{1f409}"), ("whale", "\u{1f433}"),
]),
];
/// Example server-side sticker packs (stubbed data).
fn get_example_server_packs() -> Vec<StickerPack> {
vec![
StickerPack {
name: "Fluffy Bunnies".to_string(),
avatar_url: None,
stickers: vec![
ServerSticker {
name: "Happy Bunny".to_string(),
image_url: "mxc://example.com/happy_bunny".to_string(),
description: Some("A happy fluffy bunny".to_string()),
},
ServerSticker {
name: "Sleepy Bunny".to_string(),
image_url: "mxc://example.com/sleepy_bunny".to_string(),
description: Some("A sleepy bunny with a pillow".to_string()),
},
ServerSticker {
name: "Dancing Bunny".to_string(),
image_url: "mxc://example.com/dancing_bunny".to_string(),
description: Some("A bunny doing a happy dance".to_string()),
},
ServerSticker {
name: "Love Bunny".to_string(),
image_url: "mxc://example.com/love_bunny".to_string(),
description: Some("A bunny holding a heart".to_string()),
},
ServerSticker {
name: "Surprised Bunny".to_string(),
image_url: "mxc://example.com/surprised_bunny".to_string(),
description: Some("A bunny with wide eyes".to_string()),
},
ServerSticker {
name: "Cool Bunny".to_string(),
image_url: "mxc://example.com/cool_bunny".to_string(),
description: Some("A bunny wearing sunglasses".to_string()),
},
],
},
StickerPack {
name: "Office Life".to_string(),
avatar_url: None,
stickers: vec![
ServerSticker {
name: "Coffee Time".to_string(),
image_url: "mxc://example.com/coffee".to_string(),
description: Some("A steaming cup of coffee".to_string()),
},
ServerSticker {
name: "Meeting".to_string(),
image_url: "mxc://example.com/meeting".to_string(),
description: Some("This could have been an email".to_string()),
},
ServerSticker {
name: "Deadline".to_string(),
image_url: "mxc://example.com/deadline".to_string(),
description: Some("Running against the clock".to_string()),
},
ServerSticker {
name: "LGTM".to_string(),
image_url: "mxc://example.com/lgtm".to_string(),
description: Some("Looks good to me!".to_string()),
},
ServerSticker {
name: "Ship It".to_string(),
image_url: "mxc://example.com/ship_it".to_string(),
description: Some("Ship it!".to_string()),
},
ServerSticker {
name: "Bug Found".to_string(),
image_url: "mxc://example.com/bug".to_string(),
description: Some("It's not a bug, it's a feature".to_string()),
},
],
},
StickerPack {
name: "Pixel Cats".to_string(),
avatar_url: None,
stickers: vec![
ServerSticker {
name: "Pixel Cat Wave".to_string(),
image_url: "mxc://example.com/pixel_cat_wave".to_string(),
description: Some("A pixel art cat waving hello".to_string()),
},
ServerSticker {
name: "Pixel Cat Heart".to_string(),
image_url: "mxc://example.com/pixel_cat_heart".to_string(),
description: Some("A pixel art cat with hearts".to_string()),
},
ServerSticker {
name: "Pixel Cat Nap".to_string(),
image_url: "mxc://example.com/pixel_cat_nap".to_string(),
description: Some("A pixel art cat taking a nap".to_string()),
},
ServerSticker {
name: "Pixel Cat Party".to_string(),
image_url: "mxc://example.com/pixel_cat_party".to_string(),
description: Some("A pixel art cat celebrating".to_string()),
},
],
},
]
}
/// Which section of the sticker picker is active.
#[derive(Clone, Debug, PartialEq)]
enum StickerSection {
/// Built-in emoji stickers
Builtin(usize),
/// Server-side sticker pack (by index)
ServerPack(usize),
}
/// Sticker picker popup for selecting and sending stickers.
/// Supports both built-in emoji stickers and server-side sticker packs.
#[component]
pub fn StickerPicker(
on_select: EventHandler<String>,
on_close: EventHandler<()>,
) -> Element {
let mut active_section = use_signal(|| StickerSection::Builtin(0));
let server_packs = use_signal(|| get_example_server_packs());
let mut show_get_stickers = use_signal(|| false);
let current_section = active_section.read().clone();
let packs = server_packs.read().clone();
rsx! {
div {
class: "sticker-picker",
// Pack tabs - top row with built-in + server packs
div {
class: "sticker-picker__tabs",
// Built-in pack tabs
for (idx, (pack_name, _)) in BUILTIN_PACKS.iter().enumerate() {
{
let is_active = matches!(current_section, StickerSection::Builtin(i) if i == idx);
rsx! {
button {
class: if is_active { "sticker-picker__tab sticker-picker__tab--active" } else { "sticker-picker__tab" },
onclick: move |_| active_section.set(StickerSection::Builtin(idx)),
"{pack_name}"
}
}
}
}
// Server pack tabs (if any)
if !packs.is_empty() {
span { class: "sticker-picker__tab-separator" }
}
for (idx, pack) in packs.iter().enumerate() {
{
let is_active = matches!(current_section, StickerSection::ServerPack(i) if i == idx);
let pack_name = pack.name.clone();
rsx! {
button {
class: if is_active {
"sticker-picker__tab sticker-picker__tab--active sticker-picker__tab--server"
} else {
"sticker-picker__tab sticker-picker__tab--server"
},
title: "{pack_name}",
onclick: move |_| active_section.set(StickerSection::ServerPack(idx)),
"{pack_name}"
}
}
}
}
}
// Sticker grid
div {
class: "sticker-picker__grid",
match current_section {
StickerSection::Builtin(pack_idx) => {
let current_pack = BUILTIN_PACKS.get(pack_idx);
rsx! {
if let Some((_name, stickers)) = current_pack {
for (sticker_name, emoji) in stickers.iter() {
{
let emoji_str = emoji.to_string();
let name = sticker_name.to_string();
rsx! {
button {
class: "sticker-picker__sticker",
title: "{name}",
onclick: move |_| {
on_select.call(emoji_str.clone());
},
"{emoji}"
}
}
}
}
}
}
},
StickerSection::ServerPack(pack_idx) => {
match packs.get(pack_idx) {
Some(pack) => {
let stickers = pack.stickers.clone();
rsx! {
for sticker in stickers.iter() {
{
let name = sticker.name.clone();
let url = sticker.image_url.clone();
let desc = sticker.description.clone().unwrap_or_else(|| sticker.name.clone());
rsx! {
button {
class: "sticker-picker__sticker sticker-picker__sticker--server",
title: "{desc}",
onclick: move |_| {
// Send the sticker URL as the selection
on_select.call(url.clone());
},
div {
class: "sticker-picker__sticker-preview",
// In a real implementation, this would be an img tag
// loading from the mxc:// URL via the media proxy
div {
class: "sticker-picker__sticker-placeholder",
"{name}"
}
}
span {
class: "sticker-picker__sticker-name",
"{name}"
}
}
}
}
}
}
},
None => rsx! {},
}
},
}
}
// Footer with close and "Get Stickers" buttons
div {
class: "sticker-picker__footer",
button {
class: "btn btn--accent btn--sm sticker-picker__get-stickers-btn",
onclick: move |_| show_get_stickers.set(true),
"Get Stickers"
}
button {
class: "btn btn--secondary btn--sm",
onclick: move |_| on_close.call(()),
"Close"
}
}
// "Get Stickers" overlay panel
if *show_get_stickers.read() {
div {
class: "sticker-picker__get-overlay",
div {
class: "sticker-picker__get-header",
h4 { "Get Sticker Packs" }
button {
class: "sticker-picker__get-close",
onclick: move |_| show_get_stickers.set(false),
"Back"
}
}
div {
class: "sticker-picker__get-content",
p {
class: "sticker-picker__get-info",
"Browse and add sticker packs from the integration manager. "
"Sticker packs added here will appear as tabs in the sticker picker."
}
// Example available packs to browse
div {
class: "sticker-picker__available-packs",
div {
class: "sticker-picker__available-pack",
div {
class: "sticker-picker__pack-icon",
"P"
}
div {
class: "sticker-picker__pack-info",
strong { "Fluffy Bunnies" }
p { "6 cute bunny stickers" }
}
span { class: "sticker-picker__pack-status sticker-picker__pack-status--added", "Added" }
}
div {
class: "sticker-picker__available-pack",
div {
class: "sticker-picker__pack-icon",
"P"
}
div {
class: "sticker-picker__pack-info",
strong { "Office Life" }
p { "6 work-themed stickers" }
}
span { class: "sticker-picker__pack-status sticker-picker__pack-status--added", "Added" }
}
div {
class: "sticker-picker__available-pack",
div {
class: "sticker-picker__pack-icon",
"P"
}
div {
class: "sticker-picker__pack-info",
strong { "Pixel Cats" }
p { "4 pixel art cat stickers" }
}
span { class: "sticker-picker__pack-status sticker-picker__pack-status--added", "Added" }
}
div {
class: "sticker-picker__available-pack",
div {
class: "sticker-picker__pack-icon sticker-picker__pack-icon--placeholder",
"?"
}
div {
class: "sticker-picker__pack-info",
strong { "More Packs" }
p { "Browse the integration manager for more sticker packs" }
}
button {
class: "btn btn--primary btn--sm",
onclick: move |_| {
// In a real implementation, this would open the
// integration manager / sticker picker widget URL
tracing::info!("Opening integration manager for sticker packs");
},
"Browse"
}
}
}
}
}
}
}
}
}