euv_example/pages/window/
fn.rs1use super::*;
2
3pub(crate) fn mount_window_viewport_card(
15 state: &ShowcaseState,
16 dpr_sig: Signal<f32>,
17 tokens: ThemeTokens,
18) -> NodeId {
19 let p: ThemePalette = tokens.get_palette();
20 let ctx_win: Context = current_context();
21 let vp_sig: Signal<Size> = use_viewport_size();
22 let bp_sig: Signal<Breakpoint> = use_breakpoint();
23 let safe_area_sig: Signal<SafeAreaInsets> = use_safe_area();
24 let orient_sig: Signal<ScreenOrientation> = ctx_win.get_orientation();
25 let locale_sig: Signal<String> = ctx_win.get_locale();
26 let focus_sig: Signal<bool> = ctx_win.get_window_focused();
27 let fs_sig: Signal<bool> = state.get_fullscreen();
28 let clip_draft: Signal<String> = Signal::new(WINDOW_CLIPBOARD_DEFAULT.to_string());
29 let clip_status: Signal<String> = Signal::new(WINDOW_CLIPBOARD_READY.to_string());
30 let viewport_line = move || -> String {
31 let vp: Size = vp_sig.get();
32 format!(
33 "Live Viewport: {:.0}x{:.0} @ {:.2}x DPR | Breakpoint: {:?}",
34 vp.get_width(),
35 vp.get_height(),
36 dpr_sig.get(),
37 bp_sig.get()
38 )
39 };
40 let safe_area_line = move || -> String {
41 let sa: SafeAreaInsets = safe_area_sig.get();
42 format!(
43 "SafeArea: T{:.0} R{:.0} B{:.0} L{:.0} | Orientation: {:?}",
44 sa.get_top(),
45 sa.get_right(),
46 sa.get_bottom(),
47 sa.get_left(),
48 orient_sig.get()
49 )
50 };
51 let locale_line = move || -> String {
52 format!(
53 "Locale: {} | Window Focused: {}",
54 locale_sig.get(),
55 focus_sig.get()
56 )
57 };
58 let clip_status_text = move || -> String { clip_status.get() };
59 let ctx_for_copy: Context = ctx_win.clone();
60 let on_copy = move |_: &UiEvent| {
61 let payload: String = clip_draft.get_untracked();
62 let accepted: bool = ctx_for_copy.copy_to_clipboard(&payload);
63 let tag: &str = if accepted {
64 WINDOW_CLIPBOARD_COPIED
65 } else {
66 WINDOW_CLIPBOARD_SIMULATED
67 };
68 let _: bool = clip_status.set(format!("Clipboard ({tag}): {} bytes", payload.len()));
69 };
70 view! {
71 EuvCard {
72 title: WINDOW_VIEWPORT_CARD_TITLE.to_string()
73 tokens: tokens
74 subtitle: WINDOW_VIEWPORT_CARD_SUB
75 column {
76 style: {
77 width: Length::Percent(100.0)
78 gap: SPACE_SM
79 }
80 text {
81 style: {
82 width: Length::Percent(100.0)
83 font_size: 13.5
84 font_weight: FontWeight::SemiBold
85 color: p.get_primary()
86 }
87 { viewport_line }
88 }
89 text {
90 style: {
91 width: Length::Percent(100.0)
92 font_size: 12.5
93 font_family: FontFamily::Monospace
94 color: p.get_foreground()
95 }
96 { safe_area_line }
97 }
98 text {
99 style: {
100 width: Length::Percent(100.0)
101 font_size: 12.5
102 color: p.get_muted_foreground()
103 }
104 { locale_line }
105 }
106 EuvSwitch {
107 checked: fs_sig
108 label: SWITCH_FULLSCREEN.to_string()
109 tokens: tokens
110 }
111 EuvInput {
112 value: clip_draft
113 placeholder: WINDOW_CLIPBOARD_PLACEHOLDER.to_string()
114 tokens: tokens
115 }
116 EuvActionRow {
117 EuvButton {
118 label: WINDOW_BTN_COPY_CLIPBOARD.to_string()
119 tokens: tokens
120 sm()
121 on_click: on_copy
122 }
123 }
124 text {
125 style: {
126 width: Length::Percent(100.0)
127 font_size: 12.0
128 font_family: FontFamily::Monospace
129 color: p.get_card_foreground()
130 }
131 { clip_status_text }
132 }
133 }
134 }
135 }
136}
137
138pub(crate) fn mount_window_hardware_card(tokens: ThemeTokens) -> NodeId {
148 let p: ThemePalette = tokens.get_palette();
149 let (font_info, gpu_info): (SystemFontInfo, GpuAdapterInfo) = cached_window_hardware_probe();
150 let platform: PlatformKind = current_platform();
151 let caps: PlatformCapabilities = PlatformCapabilities::for_platform(platform);
152 let summary: String = format!(
153 "Platform: {:?} | Font: {} ({:?})",
154 platform,
155 font_info.get_family_name(),
156 font_info.get_backend()
157 );
158 let gpu_line: String = format!(
159 "GPU Adapter: {} | Shader Compiled: {} | Haptics: {} | A11y Bridge: {}",
160 gpu_info.get_device_name(),
161 gpu_info.get_shader_compiled(),
162 caps.get_haptics(),
163 caps.get_accessibility_bridge()
164 );
165 view! {
166 EuvCard {
167 title: WINDOW_HARDWARE_CARD_TITLE.to_string()
168 tokens: tokens
169 subtitle: WINDOW_HARDWARE_CARD_SUB
170 column {
171 style: {
172 width: Length::Percent(100.0)
173 gap: SPACE_SM
174 }
175 text {
176 style: {
177 width: Length::Percent(100.0)
178 font_size: 13.5
179 font_weight: FontWeight::SemiBold
180 color: p.get_foreground()
181 }
182 { summary }
183 }
184 text {
185 style: {
186 width: Length::Percent(100.0)
187 font_size: 12.5
188 font_family: FontFamily::Monospace
189 color: p.get_muted_foreground()
190 }
191 { gpu_line }
192 }
193 EuvCodeBlock {
194 code: CODE_WINDOW_SNIPPET.to_string()
195 tokens: tokens
196 }
197 }
198 }
199 }
200}
201
202pub(crate) fn mount_window_fps_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
213 let p: ThemePalette = tokens.get_palette();
214 let ctx_win: Context = current_context();
215 let fps_limit_sig: Signal<Option<u32>> = ctx_win.get_fps_limit();
216 let live_fps_sig: Signal<f32> = ctx_win.get_live_fps();
217 let native_hz_sig: Signal<f32> = ctx_win.get_display_refresh_rate();
218 let demo_fps_idx: Signal<usize> = state.get_demo_fps_cap_index();
219 let demo_fps_line = move || -> String {
220 let native_hz: f32 = native_hz_sig.get().max(24.0);
221 let (target_label, target_hz): (String, f32) = match demo_fps_idx.get() {
222 1 => (FPS_OPT_30.to_string(), 30.0),
223 2 => (FPS_OPT_60.to_string(), 60.0),
224 3 => (FPS_OPT_120.to_string(), 120.0),
225 4 => (FPS_OPT_144.to_string(), 144.0),
226 5 => (FPS_OPT_240.to_string(), 240.0),
227 6 => (FPS_OPT_360.to_string(), 360.0),
228 _ => (format!("{FPS_OPT_NATIVE} ({native_hz:.0} Hz)"), native_hz),
229 };
230 let budget_ms: f32 = 1_000.0 / target_hz;
231 format!("Demo Widget Pacing: {target_label} ({budget_ms:.2} ms/frame — Card-Scoped Only)")
232 };
233 let global_fps_line = move || -> String {
234 let native_hz: f32 = native_hz_sig.get();
235 let cap_txt: String = match fps_limit_sig.get() {
236 None => format!("{FPS_OPT_NATIVE} ({native_hz:.0} Hz)"),
237 Some(v) => format!("Capped at {v} FPS"),
238 };
239 let live_fps: f32 = live_fps_sig.get();
240 if !live_fps.is_finite() || live_fps <= 0.05 {
241 format!("Global App Policy (Read-Only): {cap_txt} | Status: {LABEL_FPS_IDLE} (0.0 FPS)")
242 } else {
243 format!("Global App Policy (Read-Only): {cap_txt} | Live Measured: {live_fps:.1} FPS")
244 }
245 };
246 view! {
247 EuvCard {
248 title: FPS_DEMO_CARD_TITLE.to_string()
249 tokens: tokens
250 subtitle: FPS_DEMO_CARD_SUB
251 column {
252 style: {
253 width: Length::Percent(100.0)
254 gap: SPACE_SM
255 }
256 EuvSegmented {
257 options: vec![
258 FPS_OPT_NATIVE.to_string(),
259 FPS_OPT_30.to_string(),
260 FPS_OPT_60.to_string(),
261 FPS_OPT_120.to_string(),
262 FPS_OPT_144.to_string(),
263 FPS_OPT_240.to_string(),
264 FPS_OPT_360.to_string(),
265 ]
266 selected: demo_fps_idx
267 tokens: tokens
268 }
269 text {
270 style: {
271 width: Length::Percent(100.0)
272 font_size: 13.0
273 font_weight: FontWeight::SemiBold
274 color: p.get_primary()
275 }
276 { demo_fps_line }
277 }
278 text {
279 style: {
280 width: Length::Percent(100.0)
281 font_size: 12.5
282 font_weight: FontWeight::Medium
283 color: p.get_muted_foreground()
284 }
285 { global_fps_line }
286 }
287 }
288 }
289 }
290}
291
292pub(crate) fn mount_window_services_card(
304 state: &ShowcaseState,
305 native_feedback: Signal<String>,
306 tokens: ThemeTokens,
307) -> (NodeId, NodeId) {
308 let p: ThemePalette = tokens.get_palette();
309 let platform: PlatformKind = current_platform();
310 let caps: PlatformCapabilities = PlatformCapabilities::for_platform(platform);
311 let hub: PlatformServiceHub = PlatformServiceHub::new(platform);
312 let cam_key: &'static str = SystemPermission::Camera.native_key(platform);
313 let island_active: Signal<bool> = state.get_island_active();
314 let island_progress: Signal<u8> = state.get_island_progress();
315 let cam_status: Signal<String> = state.get_camera_perm_status();
316 let proto_status: Signal<String> = state.get_protocol_status();
317 let a11y_count: Signal<u32> = state.get_a11y_announcements();
318 let haptic_count: Signal<u32> = state.get_haptic_pulses();
319 let feedback_text = move || -> String { native_feedback.get() };
320 let island_line = move || -> String {
321 format!(
322 "Dynamic Island: active={} ({}%) | Mode: {:?} | Biometrics: {:?}",
323 island_active.get(),
324 island_progress.get(),
325 PlatformServiceHub::default_island_mode(platform),
326 hub.biometric_kind()
327 )
328 };
329 let proto_cam_line = move || -> String {
330 format!(
331 "Protocol: {} | Camera: {} ({cam_key})",
332 proto_status.get(),
333 cam_status.get()
334 )
335 };
336 let a11y_haptic_line = move || -> String {
337 format!(
338 "A11y Bridge: {} (announcements={}) | Haptics: {} (pulses={})",
339 caps.get_accessibility_bridge(),
340 a11y_count.get(),
341 caps.get_haptics(),
342 haptic_count.get()
343 )
344 };
345 let on_toggle_island = move |_: &UiEvent| {
346 let next_active: bool = !island_active.get_untracked();
347 let _: bool = island_active.set_if_changed(next_active);
348 let next_pct: u8 = if next_active {
349 let cur: u8 = island_progress.get_untracked();
350 if cur >= 100 { 25 } else { (cur + 25).min(100) }
351 } else {
352 island_progress.get_untracked()
353 };
354 let _: bool = island_progress.set_if_changed(next_pct);
355 let mut svc: PlatformServiceHub = PlatformServiceHub::new(platform);
356 if next_active {
357 let mut content: LiveActivityContent = LiveActivityContent::new(
358 WINDOW_ISLAND_TITLE.to_string(),
359 format!("Active ({next_pct}%) on {platform:?}"),
360 );
361 content.set_progress_percent(Some(next_pct));
362 let _: LiveActivityHandle =
363 svc.start_live_activity(WINDOW_ISLAND_ID.to_string(), content);
364 let _: bool = native_feedback.set(format!(
365 "Dynamic Island LIVE ({next_pct}%) dispatched to {platform:?}"
366 ));
367 } else {
368 let _: bool = dispatch_native_action(
369 NATIVE_ACTION_ISLAND,
370 WINDOW_ISLAND_STOP_CMD,
371 WINDOW_ISLAND_STOP_MSG,
372 );
373 let _: bool = native_feedback.set(WINDOW_ISLAND_ENDED.to_string());
374 }
375 };
376 let on_register_proto = move |_: &UiEvent| {
377 let mut reg: ProtocolRegistry = ProtocolRegistry::new();
378 let spec: ProtocolRegistration = ProtocolRegistration::new(
379 "euv".to_string(),
380 WINDOW_PROTO_APP_NAME.to_string(),
381 SHOWCASE_BUNDLE_ID.to_string(),
382 );
383 let native_ok: bool =
384 dispatch_native_action(NATIVE_ACTION_PROTOCOL, "euv", SHOWCASE_BUNDLE_ID);
385 if let Ok(desc) = reg.register(spec, platform) {
386 let tag: &str = if native_ok {
387 WINDOW_PROTO_TAG_BRIDGED
388 } else {
389 WINDOW_PROTO_TAG_VERIFIED
390 };
391 let msg: String = format!("Registered euv:// via {} ({tag})", desc.get_mechanism());
392 let _: bool = proto_status.set_if_changed(msg.clone());
393 let _: bool = native_feedback.set(msg);
394 }
395 };
396 let on_request_cam = move |_: &UiEvent| {
397 let mut mgr: PermissionManager = PermissionManager::new();
398 let desc: PermissionDescriptor = mgr.request(
399 SystemPermission::Camera,
400 WINDOW_CAMERA_REASON.to_string(),
401 platform,
402 );
403 let msg: String = format!("{:?} ({})", desc.get_status(), desc.get_native_key());
404 let _: bool = cam_status.set_if_changed(msg.clone());
405 let _: bool = native_feedback.set(format!("Permission requested: {msg}"));
406 };
407 let on_a11y_haptic = move |_: &UiEvent| {
408 let mut svc: PlatformServiceHub = PlatformServiceHub::new(platform);
409 let fired: bool = svc.trigger_haptic(HapticStyle::Medium);
410 svc.announce_a11y(WINDOW_A11Y_PULSE_MSG.to_string(), A11yLiveRegion::Polite);
411 let _: bool = a11y_count.update(|v: &mut u32| *v += 1);
412 let _: bool = haptic_count.update(|v: &mut u32| *v += 1);
413 let _: bool = native_feedback.set(format!(
414 "Dispatched Haptic pulse (ok={fired}) + A11y announcement #{}",
415 a11y_count.get_untracked()
416 ));
417 };
418 let mut body_id: NodeId = NodeId::default();
419 let card: NodeId = view! {
420 EuvCard {
421 title: WINDOW_CARD_TITLE.to_string()
422 tokens: tokens
423 subtitle: WINDOW_CARD_SUB
424 column {
425 node_ref: body_id
426 role: A11yRole::Region
427 a11y_label: WINDOW_A11Y_TELEMETRY
428 style: {
429 width: Length::Percent(100.0)
430 gap: SPACE_SM
431 }
432 text {
433 style: {
434 width: Length::Percent(100.0)
435 font_size: 13.0
436 font_weight: FontWeight::SemiBold
437 color: p.get_card_foreground()
438 }
439 { feedback_text }
440 }
441 text {
442 style: {
443 width: Length::Percent(100.0)
444 font_size: 13.0
445 color: p.get_primary()
446 }
447 { island_line }
448 }
449 text {
450 style: {
451 width: Length::Percent(100.0)
452 font_size: 12.5
453 color: p.get_muted_foreground()
454 }
455 { proto_cam_line }
456 }
457 text {
458 style: {
459 width: Length::Percent(100.0)
460 font_size: 12.5
461 color: p.get_muted_foreground()
462 }
463 { a11y_haptic_line }
464 }
465 EuvActionRow {
466 EuvButton {
467 label: WINDOW_BTN_TOGGLE_ISLAND.to_string()
468 tokens: tokens
469 on_click: on_toggle_island
470 }
471 EuvButton {
472 label: WINDOW_BTN_REGISTER_PROTO.to_string()
473 tokens: tokens
474 outline()
475 on_click: on_register_proto
476 }
477 EuvButton {
478 label: WINDOW_BTN_REQUEST_CAMERA.to_string()
479 tokens: tokens
480 outline()
481 on_click: on_request_cam
482 }
483 EuvButton {
484 label: WINDOW_BTN_A11Y_HAPTIC.to_string()
485 tokens: tokens
486 outline()
487 on_click: on_a11y_haptic
488 }
489 }
490 }
491 }
492 };
493 (card, body_id)
494}
495
496pub(crate) fn mount_window_island_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
507 let target_plat_idx: Signal<usize> = state.get_os_target_platform_idx();
508 let island_mode_idx: Signal<usize> = state.get_island_mode_idx();
509 let island_active: Signal<bool> = state.get_island_active();
510 let island_progress: Signal<u8> = state.get_island_progress();
511 let sys_notifs: Signal<Vec<(String, String)>> = state.get_system_notifications();
512 let pill_text = move || -> String {
513 let tp: PlatformKind = WINDOW_ALL_PLATFORMS[target_plat_idx.get() % 7];
514 let im: IslandPresentationMode = WINDOW_ALL_ISLAND_MODES[island_mode_idx.get() % 6];
515 let def_im: IslandPresentationMode = PlatformServiceHub::default_island_mode(tp);
516 let active: bool = island_active.get();
517 let pct: u8 = island_progress.get();
518 let state_tag: &str = if active {
519 WINDOW_ISLAND_STATE_LIVE
520 } else {
521 WINDOW_ISLAND_STATE_IDLE
522 };
523 format!(
524 "[{state_tag}] Dynamic Island ({tp:?}) | Mode: {im:?} (OS Default: {def_im:?}) | Progress: {pct}%"
525 )
526 };
527 let on_alert_notif = move |_: &UiEvent| {
528 let tp: PlatformKind = WINDOW_ALL_PLATFORMS[target_plat_idx.get_untracked() % 7];
529 let mut svc: PlatformServiceHub = PlatformServiceHub::new(tp);
530 let n: SystemNotification = SystemNotification::new(
531 WINDOW_NOTIF_ALERT_ID.to_string(),
532 format!("{tp:?} Alert Notification"),
533 WINDOW_NOTIF_ALERT_BODY.to_string(),
534 );
535 svc.send_notification(n.clone());
536 let _: bool = sys_notifs.update(|v: &mut Vec<(String, String)>| {
537 v.insert(0, (n.get_title().clone(), n.get_body().clone()));
538 v.truncate(5);
539 });
540 };
541 let on_silent_notif = move |_: &UiEvent| {
542 let tp: PlatformKind = WINDOW_ALL_PLATFORMS[target_plat_idx.get_untracked() % 7];
543 let mut svc: PlatformServiceHub = PlatformServiceHub::new(tp);
544 let mut n: SystemNotification = SystemNotification::new(
545 WINDOW_NOTIF_SYNC_ID.to_string(),
546 format!("{tp:?} Silent Sync (Badge 3)"),
547 WINDOW_NOTIF_SYNC_BODY.to_string(),
548 );
549 n.set_silent(true);
550 n.set_badge_count(Some(3));
551 svc.send_notification(n.clone());
552 let _: bool = sys_notifs.update(|v: &mut Vec<(String, String)>| {
553 v.insert(0, (n.get_title().clone(), n.get_body().clone()));
554 v.truncate(5);
555 });
556 };
557 let on_clear_notifs = move |_: &UiEvent| {
558 let _: bool = sys_notifs.set_if_changed(Vec::new());
559 };
560 view! {
561 EuvCard {
562 title: WINDOW_ISLAND_CARD_TITLE.to_string()
563 tokens: tokens
564 subtitle: WINDOW_ISLAND_CARD_SUB
565 column {
566 style: {
567 width: Length::Percent(100.0)
568 gap: SPACE_SM
569 }
570 EuvSegmented {
571 options: vec![
572 WINDOW_PLAT_IOS.to_string(),
573 WINDOW_PLAT_IPADOS.to_string(),
574 LABEL_PLATFORM_ANDROID.to_string(),
575 LABEL_PLATFORM_MACOS.to_string(),
576 WINDOW_PLAT_WINDOWS.to_string(),
577 WINDOW_PLAT_LINUX.to_string(),
578 WINDOW_PLAT_WEB.to_string(),
579 ]
580 selected: target_plat_idx
581 tokens: tokens
582 }
583 EuvSegmented {
584 options: vec![
585 WINDOW_MODE_COMPACT.to_string(),
586 WINDOW_MODE_MINIMAL.to_string(),
587 WINDOW_MODE_EXPANDED.to_string(),
588 WINDOW_MODE_LOCKSCREEN.to_string(),
589 WINDOW_MODE_FALLBACK.to_string(),
590 WINDOW_MODE_STATUSBAR.to_string(),
591 ]
592 selected: island_mode_idx
593 tokens: tokens
594 }
595 column {
596 style: {
597 width: Length::Percent(100.0)
598 padding: Edges::all(SPACE_MD)
599 gap: SPACE_XS
600 background: Color::hex(0x09090B)
601 radius: 20.0
602 overflow: Overflow::Hidden
603 }
604 text {
605 style: {
606 width: Length::Percent(100.0)
607 font_size: 12.0
608 font_weight: FontWeight::SemiBold
609 color: Color::hex(0xF8FAFC)
610 }
611 { pill_text }
612 }
613 }
614 EuvActionRow {
615 EuvButton {
616 label: WINDOW_BTN_ALERT_NOTIF.to_string()
617 tokens: tokens
618 sm()
619 on_click: on_alert_notif
620 }
621 EuvButton {
622 label: WINDOW_BTN_SILENT_NOTIF.to_string()
623 tokens: tokens
624 outline()
625 sm()
626 on_click: on_silent_notif
627 }
628 EuvButton {
629 label: WINDOW_BTN_CLEAR_NOTIFS.to_string()
630 tokens: tokens
631 outline()
632 sm()
633 on_click: on_clear_notifs
634 }
635 }
636 EuvSonner {
637 messages: sys_notifs
638 tokens: tokens
639 }
640 }
641 }
642 }
643}
644
645pub(crate) fn mount_window_permissions_card(
657 state: &ShowcaseState,
658 native_feedback: Signal<String>,
659 tokens: ThemeTokens,
660) -> NodeId {
661 let platform: PlatformKind = current_platform();
662 let target_plat_idx: Signal<usize> = state.get_os_target_platform_idx();
663 let perm_statuses: Signal<Vec<PermissionStatus>> = state.get_permission_statuses();
664 let vp_sig: Signal<Size> = use_viewport_size();
665 let matrix_grid_style = move || -> Style {
666 let cols: u16 = responsive_grid_columns(vp_sig.get().get_width(), 2);
667 Style::default()
668 .grid(cols)
669 .width(Length::Percent(100.0))
670 .gap(SPACE_SM)
671 };
672 let build_perm_cards = move || -> Vec<NodeId> {
673 let live: ThemeTokens = live_tokens_untracked(tokens);
674 let live_p: ThemePalette = live.get_palette();
675 let live_g: ThemeGeometry = live.get_geometry();
676 let tp: PlatformKind = WINDOW_ALL_PLATFORMS[target_plat_idx.get() % 7];
677 let statuses: Vec<PermissionStatus> = perm_statuses.get();
678 WINDOW_ALL_PERMS
679 .iter()
680 .copied()
681 .enumerate()
682 .map(|(idx, perm): (usize, SystemPermission)| {
683 let st: PermissionStatus = statuses
684 .get(idx)
685 .copied()
686 .unwrap_or(PermissionStatus::NotDetermined);
687 let native_key: &'static str = perm.native_key(tp);
688 let row_title: String = format!("{perm:?} [{st:?}]");
689 let key_line: String = native_key.to_string();
690 let on_req = move |_: &UiEvent| {
691 let mut mgr: PermissionManager = PermissionManager::new();
692 let desc: PermissionDescriptor =
693 mgr.request(perm, format!("Test {perm:?} access"), platform);
694 let _: bool = perm_statuses.update(|vec: &mut Vec<PermissionStatus>| {
695 if let Some(slot) = vec.get_mut(idx) {
696 *slot = desc.get_status();
697 }
698 });
699 let _: bool = native_feedback.set(format!(
700 "Requested {perm:?} ({}) -> {:?}",
701 perm.native_key(platform),
702 desc.get_status()
703 ));
704 };
705 let on_deny = move |_: &UiEvent| {
706 let _: bool = perm_statuses.update(|vec: &mut Vec<PermissionStatus>| {
707 if let Some(slot) = vec.get_mut(idx) {
708 *slot = PermissionStatus::Denied;
709 }
710 });
711 let _: bool = native_feedback.set(format!("Marked {perm:?} as Denied"));
712 };
713 view! {
714 column {
715 style: {
716 width: Length::Percent(100.0)
717 padding: Edges::all(SPACE_MD)
718 gap: SPACE_XS
719 background: live_p.get_card()
720 border: (live_g.get_border_width(), live_p.get_border())
721 radius: live_g.get_radius_sm()
722 overflow: Overflow::Hidden
723 }
724 text {
725 style: {
726 width: Length::Percent(100.0)
727 font_size: 12.5
728 font_weight: FontWeight::SemiBold
729 color: live_p.get_card_foreground()
730 }
731 { row_title }
732 }
733 text {
734 style: {
735 width: Length::Percent(100.0)
736 font_size: 11.5
737 font_family: FontFamily::Monospace
738 color: live_p.get_muted_foreground()
739 }
740 { key_line }
741 }
742 EuvActionRow {
743 EuvButton {
744 label: WINDOW_BTN_PERM_REQUEST.to_string()
745 tokens: live
746 outline()
747 sm()
748 on_click: on_req
749 }
750 EuvButton {
751 label: WINDOW_BTN_PERM_DENY.to_string()
752 tokens: live
753 destructive()
754 sm()
755 on_click: on_deny
756 }
757 }
758 }
759 }
760 })
761 .collect()
762 };
763 view! {
764 EuvCard {
765 title: WINDOW_PERMS_CARD_TITLE.to_string()
766 tokens: tokens
767 subtitle: WINDOW_PERMS_CARD_SUB
768 grid {
769 bind_style: matrix_grid_style
770 bind_children: build_perm_cards
771 }
772 }
773 }
774}
775
776pub fn mount_window_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
787 let ctx_win: Context = current_context();
788 let native_feedback: Signal<String> = Signal::new(WINDOW_READY_FEEDBACK.to_string());
789 let dpr_sig: Signal<f32> = Signal::new(1.0);
790 let fs_sig: Signal<bool> = state.get_fullscreen();
791 let prev_fs: Rc<Cell<bool>> = Rc::new(Cell::new(fs_sig.get_untracked()));
792 let (win_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
793 let _: SystemEventSubscription = on_system_event(move |ev: &SystemEvent| {
794 if let SystemEvent::Resize { scale_factor, .. } = ev {
795 let _: bool = dpr_sig.set_if_changed(*scale_factor);
796 }
797 });
798 Effect::new(move || {
799 let now_fs: bool = fs_sig.get();
800 if prev_fs.replace(now_fs) != now_fs {
801 let arg: &str = if now_fs { "on" } else { "off" };
802 let _: bool = dispatch_native_action(NATIVE_ACTION_FULLSCREEN, arg, "");
803 let _: bool = native_feedback.set(format!("Immersive fullscreen mode: {arg}"));
804 }
805 })
806 });
807 let viewport_card: NodeId = mount_window_viewport_card(state, dpr_sig, tokens);
808 let hardware_card: NodeId = mount_window_hardware_card(tokens);
809 let fps_card: NodeId = mount_window_fps_card(state, tokens);
810 let (services_card, body_id): (NodeId, NodeId) =
811 mount_window_services_card(state, native_feedback, tokens);
812 let island_card: NodeId = mount_window_island_card(state, tokens);
813 let perms_card: NodeId = mount_window_permissions_card(state, native_feedback, tokens);
814 let top_grid: NodeId = mount_responsive_grid(vec![viewport_card, services_card], 2);
815 let mid_grid: NodeId = mount_responsive_grid(vec![fps_card, hardware_card], 2);
816 let page: NodeId = view! {
817 EuvPage {
818 title: WINDOW_TITLE.to_string()
819 subtitle: WINDOW_SUBTITLE.to_string()
820 tokens: tokens
821 { top_grid }
822 { mid_grid }
823 { island_card }
824 { perms_card }
825 }
826 };
827 ctx_win.get_scene().with_write(
828 |tree: &mut SceneTree| {
829 tree.attach_scope(body_id, win_scope);
830 },
831 (),
832 );
833 page
834}