1use super::*;
2
3style! {
4 c_full_col {
5 FlexDirection::Column
6 width: Length::Percent(100.0)
7 height: Length::Percent(100.0)
8 }
9 c_action_row {
10 FlexDirection::Row
11 FlexWrap::Wrap
12 AlignItems::Center
13 width: Length::Percent(100.0)
14 gap: SPACE_SM
15 }
16 c_scheme_grid {
17 columns: 4
18 width: Length::Percent(100.0)
19 gap: SPACE_SM
20 }
21}
22
23fn ensure_showcase_routes_registered(state: &ShowcaseState) {
29 if state.get_router_ready().replace(true) {
30 return;
31 }
32 let all_routes: [(&'static str, &'static str); 16] = [
33 (ROUTE_OVERVIEW, NAV_LABEL_OVERVIEW),
34 (ROUTE_CHARTS, NAV_LABEL_CHARTS),
35 (ROUTE_MARKDOWN, NAV_LABEL_MARKDOWN),
36 (ROUTE_REACTIVE, NAV_LABEL_REACTIVE),
37 (ROUTE_RENDER, NAV_LABEL_RENDER),
38 (ROUTE_WINDOW, NAV_LABEL_WINDOW),
39 (ROUTE_FORMS, NAV_LABEL_FORMS),
40 (ROUTE_THEMES, NAV_LABEL_THEMES),
41 (ROUTE_DATA, NAV_LABEL_DATA),
42 (ROUTE_GAME, NAV_LABEL_GAME),
43 (ROUTE_GAME_3D, NAV_LABEL_GAME_3D),
44 (ROUTE_MEDIA, NAV_LABEL_MEDIA),
45 (ROUTE_LAB, NAV_LABEL_LAB),
46 (ROUTE_OVERLAYS, NAV_LABEL_OVERLAYS),
47 (ROUTE_DYNAMIC, NAV_LABEL_DYNAMIC),
48 (ROUTE_STRESS, NAV_LABEL_STRESS),
49 ];
50 let mut router: EuvRouter = state.get_router().clone();
51 for (path, label) in all_routes.into_iter() {
52 let st: ShowcaseState = state.clone();
53 router = router.route_component(path, label, move |_: &EuvRouteMatch| {
54 let tok: ThemeTokens = untracked(|| st.get_theme().get_tokens().get());
55 ShowcasePage::new(path, st.clone(), tok)
56 });
57 }
58 let _: EuvRouter = router;
59}
60
61pub fn mount_showcase_root(state: &ShowcaseState) -> NodeId {
71 provide_theme(state.get_theme().clone());
72 ensure_showcase_routes_registered(state);
73 let global_banner: Signal<ShowcaseGlobalBanner> =
74 global_state!(ShowcaseGlobalBanner = ShowcaseGlobalBanner::default());
75 let state_c: ShowcaseState = state.clone();
76 let bg_state: ShowcaseState = state.clone();
77 let fg_state: ShowcaseState = state.clone();
78 let sys_state: ShowcaseState = state.clone();
79 let sys_log_sig: Signal<Vec<String>> = state.get_system_event_log();
80 let sys_count_sig: Signal<u32> = state.get_system_event_count();
81 let (ev_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
82 let _: SystemEventSubscription = on_background(move || {
83 bg_state.freeze_for_background();
84 });
85 let _: SystemEventSubscription = on_foreground(move || {
86 fg_state.restore_from_foreground();
87 });
88 let _: SystemEventSubscription = on_system_event(move |ev: &SystemEvent| {
89 if matches!(ev, SystemEvent::Terminate) {
90 sys_state.freeze_for_background();
91 let _: usize = EuvOverlayStack::dismiss_all();
92 reset_fullscreen_state();
93 } else if matches!(ev, SystemEvent::Foreground) {
94 sys_state.restore_from_foreground();
95 }
96 let next_seq: u32 = sys_count_sig.get_untracked().saturating_add(1);
97 let _: bool = sys_count_sig.set(next_seq);
98 let entry: String = format!("#{next_seq}: {ev:?}");
99 let _: bool = sys_log_sig.update(|items: &mut Vec<String>| {
100 items.insert(0, entry);
101 if items.len() > SYS_EVENTS_LOG_LIMIT {
102 items.truncate(SYS_EVENTS_LOG_LIMIT);
103 }
104 });
105 });
106 on_event!(ShowcasePulseEvent => move |ev: &ShowcasePulseEvent| {
107 let src: String = ev.get_source().clone();
108 let _: bool = global_banner.update(|b: &mut ShowcaseGlobalBanner| {
109 let next_pulses: u32 = b.get_pulses().saturating_add(1);
110 b.set_pulses(next_pulses);
111 b.set_last_source(src);
112 });
113 })
114 });
115 let root_node: NodeId = view! {
116 column {
117 width: Length::Percent(100.0)
118 height: Length::Percent(100.0)
119 bind_children: move || {
120 let tokens: ThemeTokens = untracked(|| state_c.get_theme().get_tokens().get());
121 let hub: DynamicUpdateHub = state_c.get_dynamic_hub().clone();
122 let _: u64 = hub.routes_signal().get();
123 let cmd_open: Signal<bool> = state_c.get_cmd_palette_open();
124 let cmd_query: Signal<String> = state_c.get_cmd_palette_query();
125 let cmd_items: Vec<String> = vec![
126 CMD_ITEM_OVERVIEW.to_string(),
127 CMD_ITEM_MARKDOWN.to_string(),
128 CMD_ITEM_LAB.to_string(),
129 CMD_ITEM_GAME_3D.to_string(),
130 CMD_ITEM_MEDIA.to_string(),
131 CMD_ITEM_DYNAMIC.to_string(),
132 CMD_ITEM_STRESS.to_string(),
133 CMD_ITEM_WINDOW.to_string(),
134 CMD_ITEM_THEMES.to_string(),
135 CMD_ITEM_CHARTS.to_string(),
136 CMD_ITEM_TOGGLE_MODE.to_string(),
137 ];
138 let cmd_sel: Signal<Option<usize>> = Signal::new(None);
139 let cmd_route: Signal<String> = state_c.get_route();
140 let cmd_state: ShowcaseState = state_c.clone();
141 let cmd_list: NodeId = view! {
142 EuvCommand {
143 items: cmd_items
144 selected: cmd_sel
145 tokens: tokens
146 query: cmd_query
147 placeholder: CMD_PLACEHOLDER
148 }
149 };
150 let (cmd_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
151 Effect::new(move || {
152 if let Some(idx) = cmd_sel.get() {
153 match idx {
154 0 => {
155 let _: bool = cmd_route.set_if_changed(ROUTE_OVERVIEW.to_string());
156 }
157 1 => {
158 let _: bool = cmd_route.set_if_changed(ROUTE_MARKDOWN.to_string());
159 }
160 2 => {
161 let _: bool = cmd_route.set_if_changed(ROUTE_LAB.to_string());
162 }
163 3 => {
164 let _: bool = cmd_route.set_if_changed(ROUTE_GAME_3D.to_string());
165 }
166 4 => {
167 let _: bool = cmd_route.set_if_changed(ROUTE_MEDIA.to_string());
168 }
169 5 => {
170 let _: bool = cmd_route.set_if_changed(ROUTE_DYNAMIC.to_string());
171 }
172 6 => {
173 let _: bool = cmd_route.set_if_changed(ROUTE_STRESS.to_string());
174 }
175 7 => {
176 let _: bool = cmd_route.set_if_changed(ROUTE_WINDOW.to_string());
177 }
178 8 => {
179 let _: bool = cmd_route.set_if_changed(ROUTE_THEMES.to_string());
180 }
181 9 => {
182 let _: bool = cmd_route.set_if_changed(ROUTE_CHARTS.to_string());
183 }
184 _ => {
185 cmd_state.toggle_theme_mode();
186 }
187 }
188 let _: bool = cmd_sel.set_if_changed(None);
189 let _: bool = cmd_open.set_if_changed(false);
190 }
191 })
192 });
193 let cmd_modal: NodeId = view! {
194 EuvModal {
195 open: cmd_open
196 title: CMD_MODAL_TITLE.to_string()
197 body: cmd_list
198 tokens: tokens
199 }
200 };
201 let rctx: Context = current_context();
202 let cmd_theme_sig: Memo<ThemeTokens> = state_c.get_theme().get_tokens();
203 let prev_cmd_tok: Rc<Cell<ThemeTokens>> = Rc::new(Cell::new(tokens));
204 let cmd_theme_ctx: Context = rctx.clone();
205 let (cmd_theme_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
206 Effect::new(move || {
207 let next_tok: ThemeTokens = cmd_theme_sig.get();
208 let old_tok: ThemeTokens = prev_cmd_tok.replace(next_tok);
209 if old_tok == next_tok {
210 return;
211 }
212 cmd_theme_ctx.get_scene().with_write(
213 |tree: &mut SceneTree| {
214 remap_subtree_theme_in_place(tree, cmd_modal, old_tok, next_tok);
215 },
216 (),
217 );
218 })
219 });
220 rctx.get_scene().with_write(
221 |tree: &mut SceneTree| {
222 tree.attach_scope(cmd_modal, cmd_scope);
223 tree.attach_scope(cmd_modal, cmd_theme_scope);
224 },
225 (),
226 );
227 let state_shell: ShowcaseState = state_c.clone();
228 let hub_shell: DynamicUpdateHub = hub.clone();
229 let global_wasm_slot: NodeId = view! {
230 slot {
231 id: WASM_GLOBAL_ROOT_SLOT
232 hub: hub
233 style: c_full_col()
234 fallback: move || {
235 let mut nav_items: Vec<EuvNavItem> = ShowcaseState::nav_items();
236 for dyn_route in hub_shell.registered_routes().into_iter() {
237 if dyn_route == ROUTE_DYNAMIC_PANEL {
238 continue;
239 }
240 if !nav_items
241 .iter()
242 .any(|item: &EuvNavItem| item.get_path().as_str() == dyn_route.as_str())
243 {
244 let label: String = hub_shell
245 .page_title(&dyn_route)
246 .filter(|t: &String| !t.is_empty())
247 .unwrap_or_else(|| dyn_route.clone());
248 nav_items.push(EuvNavItem::new(dyn_route, label).section(NAV_SEC_RUNTIME));
249 }
250 }
251 let nav: NodeId = view! {
252 EuvSidebarNav {
253 items: nav_items
254 active_route: state_shell.get_route()
255 tokens: tokens
256 }
257 };
258 let bottom_items: Vec<EuvNavItem> = vec![
259 EuvNavItem::new(
260 ROUTE_OVERVIEW.to_string(),
261 BNAV_HOME_LABEL.to_string(),
262 )
263 .section(BNAV_HOME_ICON),
264 EuvNavItem::new(
265 ROUTE_MARKDOWN.to_string(),
266 BNAV_DOCS_LABEL.to_string(),
267 )
268 .section(BNAV_DOCS_ICON),
269 EuvNavItem::new(ROUTE_LAB.to_string(), BNAV_CASES_LABEL.to_string())
270 .section(BNAV_CASES_ICON),
271 EuvNavItem::new(
272 ROUTE_STRESS.to_string(),
273 BNAV_STRESS_LABEL.to_string(),
274 )
275 .section(BNAV_STRESS_ICON),
276 EuvNavItem::new(
277 ROUTE_GAME_3D.to_string(),
278 BNAV_3D_LABEL.to_string(),
279 )
280 .section(BNAV_3D_ICON),
281 ];
282 let bottom_nav: NodeId = view! {
283 EuvBottomNav {
284 items: bottom_items
285 active_route: state_shell.get_route()
286 tokens: tokens
287 }
288 };
289 let swipe_order: Vec<String> = vec![
290 ROUTE_OVERVIEW.to_string(),
291 ROUTE_MARKDOWN.to_string(),
292 ROUTE_LAB.to_string(),
293 ROUTE_STRESS.to_string(),
294 ROUTE_GAME_3D.to_string(),
295 ROUTE_CHARTS.to_string(),
296 ROUTE_FORMS.to_string(),
297 ROUTE_MEDIA.to_string(),
298 ROUTE_OVERLAYS.to_string(),
299 ROUTE_THEMES.to_string(),
300 ROUTE_DATA.to_string(),
301 ROUTE_REACTIVE.to_string(),
302 ROUTE_RENDER.to_string(),
303 ROUTE_WINDOW.to_string(),
304 ROUTE_GAME.to_string(),
305 ROUTE_DYNAMIC.to_string(),
306 ];
307 let state_for_outlet: ShowcaseState = state_shell.clone();
308 let router: EuvRouter = state_shell
309 .get_router()
310 .clone()
311 .with_dynamic_hub(hub_shell.clone());
312 let route_sig: Signal<String> = state_shell.get_route();
313 let cur_target: String = route_sig.get_untracked();
314 if router.get_current_path().get_untracked() != cur_target {
315 router.replace(&cur_target);
316 }
317 let breadcrumb_sig: Signal<String> = Signal::new(
318 ShowcaseState::breadcrumb_for_route(&cur_target),
319 );
320 let page_pad_sig: Signal<Edges> = Signal::new(Edges::all(SPACE_LG));
321 let router_sync_in: EuvRouter = router.clone();
322 let router_path_sig: Signal<String> = router.get_current_path();
323 let sctx: Context = current_context();
324 let (sync_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
325 let _: Effect = Effect::new(move || {
326 let target: String = route_sig.get();
327 let _: bool = breadcrumb_sig
328 .set_if_changed(ShowcaseState::breadcrumb_for_route(&target));
329 if router_sync_in.get_current_path().get_untracked() != target {
330 router_sync_in.push(&target);
331 }
332 });
333 Effect::new(move || {
334 let rp: String = router_path_sig.get();
335 if route_sig.get_untracked() != rp {
336 let _: bool = route_sig.set_if_changed(rp);
337 }
338 })
339 });
340 let page_node: NodeId = router
341 .outlet(move |matched: &EuvRouteMatch| {
342 let tok: ThemeTokens = untracked(|| {
343 state_for_outlet.get_theme().get_tokens().get()
344 });
345 mount_route_by_name(matched.get_path(), &state_for_outlet, tok)
346 })
347 .with_theme(state_shell.get_theme().clone())
348 .with_page_padding(page_pad_sig)
349 .with_route_order(swipe_order.clone())
350 .with_double_back_exit(true)
351 .mount();
352 sctx.get_scene().with_write(
353 |tree: &mut SceneTree| {
354 tree.attach_scope(page_node, sync_scope);
355 },
356 (),
357 );
358 let st_dark_top: ShowcaseState = state_shell.clone();
359 let st_scheme_top: ShowcaseState = state_shell.clone();
360 let st_dark_mobile: ShowcaseState = state_shell.clone();
361 let st_scheme_mobile: ShowcaseState = state_shell.clone();
362 let theme_mode_sig: Signal<ThemeMode> = state_shell.get_theme().get_mode();
363 let icon_btn_style_desk = move || -> Style {
364 let live_tok: ThemeTokens = use_live_tokens(tokens);
365 let live_p: ThemePalette = live_tok.get_palette();
366 let live_g: ThemeGeometry = live_tok.get_geometry();
367 Style::default()
368 .row()
369 .width(Length::Px(30.0))
370 .height(Length::Px(30.0))
371 .justify(JustifyContent::Center)
372 .align(AlignItems::Center)
373 .background(live_p.get_background())
374 .border(live_g.get_border_width(), live_p.get_border())
375 .radius(live_g.get_radius_md())
376 .cursor(CursorIcon::Pointer)
377 };
378 let icon_btn_style_mob = move || -> Style {
379 let live_tok: ThemeTokens = use_live_tokens(tokens);
380 let live_p: ThemePalette = live_tok.get_palette();
381 let live_g: ThemeGeometry = live_tok.get_geometry();
382 Style::default()
383 .row()
384 .width(Length::Px(28.0))
385 .height(Length::Px(28.0))
386 .justify(JustifyContent::Center)
387 .align(AlignItems::Center)
388 .background(live_p.get_background())
389 .border(live_g.get_border_width(), live_p.get_border())
390 .radius(live_g.get_radius_md())
391 .cursor(CursorIcon::Pointer)
392 };
393 let paint_search_desk = move |bounds: Rect, dl: &mut DisplayList| {
394 let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
395 draw_euv_icon(EuvIconName::Search, bounds, dl, live_p.get_foreground());
396 };
397 let paint_search_mob = move |bounds: Rect, dl: &mut DisplayList| {
398 let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
399 draw_euv_icon(EuvIconName::Search, bounds, dl, live_p.get_foreground());
400 };
401 let paint_scheme_desk = move |bounds: Rect, dl: &mut DisplayList| {
402 let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
403 draw_euv_icon(EuvIconName::Palette, bounds, dl, live_p.get_primary());
404 };
405 let paint_scheme_mob = move |bounds: Rect, dl: &mut DisplayList| {
406 let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
407 draw_euv_icon(EuvIconName::Palette, bounds, dl, live_p.get_primary());
408 };
409 let paint_mode_desk = move |bounds: Rect, dl: &mut DisplayList| {
410 let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
411 let glyph: EuvIconName = match theme_mode_sig.get_untracked() {
412 ThemeMode::Dark => EuvIconName::Sun,
413 ThemeMode::Light => EuvIconName::Moon,
414 };
415 draw_euv_icon(glyph, bounds, dl, live_p.get_foreground());
416 };
417 let paint_mode_mob = move |bounds: Rect, dl: &mut DisplayList| {
418 let live_p: ThemePalette = live_tokens_untracked(tokens).get_palette();
419 let glyph: EuvIconName = match theme_mode_sig.get_untracked() {
420 ThemeMode::Dark => EuvIconName::Sun,
421 ThemeMode::Light => EuvIconName::Moon,
422 };
423 draw_euv_icon(glyph, bounds, dl, live_p.get_foreground());
424 };
425 let on_open_cmd_desktop = move |_: &UiEvent| {
426 let _: bool = cmd_open.set_if_changed(true);
427 };
428 let on_open_cmd_mobile = move |_: &UiEvent| {
429 let _: bool = cmd_open.set_if_changed(true);
430 };
431 let on_cycle_scheme_desktop = move |_: &UiEvent| {
432 st_scheme_top.next_scheme();
433 };
434 let on_cycle_scheme_mobile = move |_: &UiEvent| {
435 st_scheme_mobile.next_scheme();
436 };
437 let on_toggle_mode_desktop = move |_: &UiEvent| {
438 st_dark_top.toggle_theme_mode();
439 };
440 let on_toggle_mode_mobile = move |_: &UiEvent| {
441 st_dark_mobile.toggle_theme_mode();
442 };
443 let top_actions: NodeId = view! {
444 row {
445 gap: SPACE_XS
446 align: AlignItems::Center
447 row {
448 bind_style: icon_btn_style_desk
449 role: A11yRole::Button
450 a11y_label: BTN_SEARCH_A11Y.to_string()
451 on_click: on_open_cmd_desktop
452 canvas {
453 width: Length::Px(15.0)
454 height: Length::Px(15.0)
455 painter: paint_search_desk
456 }
457 }
458 row {
459 bind_style: icon_btn_style_desk
460 role: A11yRole::Button
461 a11y_label: BTN_SCHEME_A11Y.to_string()
462 on_click: on_cycle_scheme_desktop
463 canvas {
464 width: Length::Px(15.0)
465 height: Length::Px(15.0)
466 painter: paint_scheme_desk
467 }
468 }
469 row {
470 bind_style: icon_btn_style_desk
471 role: A11yRole::Button
472 a11y_label: BTN_MODE_A11Y.to_string()
473 on_click: on_toggle_mode_desktop
474 canvas {
475 width: Length::Px(15.0)
476 height: Length::Px(15.0)
477 painter: paint_mode_desk
478 }
479 }
480 }
481 };
482 let mobile_actions: NodeId = view! {
483 row {
484 gap: SPACE_XS
485 align: AlignItems::Center
486 row {
487 bind_style: icon_btn_style_mob
488 role: A11yRole::Button
489 a11y_label: BTN_SEARCH_A11Y.to_string()
490 on_click: on_open_cmd_mobile
491 canvas {
492 width: Length::Px(14.0)
493 height: Length::Px(14.0)
494 painter: paint_search_mob
495 }
496 }
497 row {
498 bind_style: icon_btn_style_mob
499 role: A11yRole::Button
500 a11y_label: BTN_SCHEME_A11Y.to_string()
501 on_click: on_cycle_scheme_mobile
502 canvas {
503 width: Length::Px(14.0)
504 height: Length::Px(14.0)
505 painter: paint_scheme_mob
506 }
507 }
508 row {
509 bind_style: icon_btn_style_mob
510 role: A11yRole::Button
511 a11y_label: BTN_MODE_A11Y.to_string()
512 on_click: on_toggle_mode_mobile
513 canvas {
514 width: Length::Px(14.0)
515 height: Length::Px(14.0)
516 painter: paint_mode_mob
517 }
518 }
519 }
520 };
521 view! {
522 EuvAppShell {
523 brand: SHOWCASE_BRAND.to_string()
524 sidebar: nav
525 main_content: page_node
526 tokens: tokens
527 theme: state_shell.get_theme().clone()
528 page_padding: page_pad_sig
529 route: state_shell.get_route()
530 breadcrumb: breadcrumb_sig
531 top_bar_actions: top_actions
532 mobile_header_actions: mobile_actions
533 bottom_nav: bottom_nav
534 swipe_routes: swipe_order
535 show_fps: true
536 }
537 }
538 }
539 }
540 };
541 vec![global_wasm_slot, cmd_modal]
542 }
543 }
544 };
545 let root_ctx: Context = current_context();
546 root_ctx.get_scene().with_write(
547 |tree: &mut SceneTree| {
548 tree.attach_scope(root_node, ev_scope);
549 },
550 (),
551 );
552 root_node
553}
554
555pub fn mount_active_route(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
566 let route: String = state.get_route().get_untracked();
567 mount_route_by_name(&route, state, tokens)
568}
569
570pub(crate) fn mount_route_by_name(
582 route: &str,
583 state: &ShowcaseState,
584 tokens: ThemeTokens,
585) -> NodeId {
586 match route {
587 ROUTE_CHARTS => mount_charts_page(state, tokens),
588 ROUTE_MARKDOWN => mount_markdown_page(state, tokens),
589 ROUTE_REACTIVE => mount_reactive_page(state, tokens),
590 ROUTE_RENDER => mount_render_page(state, tokens),
591 ROUTE_WINDOW => mount_window_page(state, tokens),
592 ROUTE_FORMS => mount_forms_page(state, tokens),
593 ROUTE_THEMES => mount_themes_page(state, tokens),
594 ROUTE_DATA => mount_data_page(state, tokens),
595 ROUTE_GAME => mount_game_page(state, tokens),
596 ROUTE_GAME_3D => mount_game3d_page(state, tokens),
597 ROUTE_MEDIA => mount_media_page(state, tokens),
598 ROUTE_LAB => mount_lab_page(state, tokens),
599 ROUTE_OVERLAYS => mount_overlays_page(state, tokens),
600 ROUTE_DYNAMIC => mount_dynamic_page(state, tokens),
601 ROUTE_STRESS => mount_stress_page(state, tokens),
602 _ => mount_overview_page(state, tokens),
603 }
604}
605
606pub fn mount_overview_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
617 let p: ThemePalette = tokens.get_palette();
618 let g: ThemeGeometry = tokens.get_geometry();
619 let route_sig: Signal<String> = state.get_route();
620 let frozen_sig: Signal<usize> = state.get_router().get_frozen_count();
621 let mounts_sig: Signal<u32> = state.get_lifecycle_mounts();
622 let freezes_sig: Signal<u32> = state.get_lifecycle_freezes();
623 let resumes_sig: Signal<u32> = state.get_lifecycle_resumes();
624 let last_ev_sig: Signal<String> = state.get_lifecycle_last_event();
625 let entries_sig: Signal<Vec<EuvRouteLifecycleEntry>> =
626 state.get_router().get_lifecycle_entries();
627 let local_counter: LocalState<u32> = local_state!(1_u32);
628 let global_banner: Signal<ShowcaseGlobalBanner> =
629 global_state!(ShowcaseGlobalBanner = ShowcaseGlobalBanner::default());
630 let dir_items: [(&str, &str, &str, &str); 15] = [
631 (
632 ROUTE_CHARTS,
633 HOME_DIR_TAG_CH,
634 NAV_LABEL_CHARTS,
635 HOME_DIR_DESC_CH,
636 ),
637 (
638 ROUTE_MARKDOWN,
639 HOME_DIR_TAG_MD,
640 NAV_LABEL_MARKDOWN,
641 HOME_DIR_DESC_MD,
642 ),
643 (ROUTE_LAB, HOME_DIR_TAG_LB, NAV_LABEL_LAB, HOME_DIR_DESC_LB),
644 (
645 ROUTE_STRESS,
646 HOME_DIR_TAG_ST,
647 NAV_LABEL_STRESS,
648 HOME_DIR_DESC_ST,
649 ),
650 (
651 ROUTE_GAME_3D,
652 HOME_DIR_TAG_3D,
653 NAV_LABEL_GAME_3D,
654 HOME_DIR_DESC_3D,
655 ),
656 (
657 ROUTE_FORMS,
658 HOME_DIR_TAG_FM,
659 NAV_LABEL_FORMS,
660 HOME_DIR_DESC_FM,
661 ),
662 (
663 ROUTE_MEDIA,
664 HOME_DIR_TAG_ME,
665 NAV_LABEL_MEDIA,
666 HOME_DIR_DESC_ME,
667 ),
668 (
669 ROUTE_OVERLAYS,
670 HOME_DIR_TAG_OV,
671 NAV_LABEL_OVERLAYS,
672 HOME_DIR_DESC_OV,
673 ),
674 (
675 ROUTE_THEMES,
676 HOME_DIR_TAG_TH,
677 NAV_LABEL_THEMES,
678 HOME_DIR_DESC_TH,
679 ),
680 (
681 ROUTE_DATA,
682 HOME_DIR_TAG_DT,
683 NAV_LABEL_DATA,
684 HOME_DIR_DESC_DT,
685 ),
686 (
687 ROUTE_REACTIVE,
688 HOME_DIR_TAG_RX,
689 NAV_LABEL_REACTIVE,
690 HOME_DIR_DESC_RX,
691 ),
692 (
693 ROUTE_RENDER,
694 HOME_DIR_TAG_RN,
695 NAV_LABEL_RENDER,
696 HOME_DIR_DESC_RN,
697 ),
698 (
699 ROUTE_WINDOW,
700 HOME_DIR_TAG_OS,
701 NAV_LABEL_WINDOW,
702 HOME_DIR_DESC_OS,
703 ),
704 (
705 ROUTE_GAME,
706 HOME_DIR_TAG_2D,
707 NAV_LABEL_GAME,
708 HOME_DIR_DESC_2D,
709 ),
710 (
711 ROUTE_DYNAMIC,
712 HOME_DIR_TAG_OT,
713 NAV_LABEL_DYNAMIC,
714 HOME_DIR_DESC_OT,
715 ),
716 ];
717 let dir_rows: Vec<NodeId> = dir_items
718 .iter()
719 .map(|(path, tag, label, desc): &(&str, &str, &str, &str)| {
720 let target: String = (*path).to_string();
721 let badge_txt: String = (*tag).to_string();
722 let title_txt: String = (*label).to_string();
723 let desc_txt: String = (*desc).to_string();
724 let on_dir_click = move |_: &UiEvent| {
725 let _: bool = route_sig.set_if_changed(target.clone());
726 };
727 view! {
728 row {
729 width: Length::Percent(100.0)
730 padding: Edges::symmetric(SPACE_SM, SPACE_MD)
731 align: AlignItems::Center
732 justify: JustifyContent::SpaceBetween
733 gap: SPACE_SM
734 radius: g.get_radius_md()
735 background: p.get_background()
736 border: (g.get_border_width(), p.get_border())
737 cursor: CursorIcon::Pointer
738 on_click: on_dir_click
739 row {
740 flex_grow: 1.0
741 flex_shrink: 1.0
742 min_width: Length::Px(0.0)
743 align: AlignItems::Center
744 gap: SPACE_SM
745 overflow: Overflow::Hidden
746 row {
747 width: Length::Px(34.0)
748 height: Length::Px(34.0)
749 flex_shrink: 0.0
750 radius: 99.0
751 background: p.get_primary().with_alpha(26)
752 justify: JustifyContent::Center
753 align: AlignItems::Center
754 text {
755 font_size: 11.5
756 font_family: FontFamily::Monospace
757 font_weight: FontWeight::Bold
758 color: p.get_primary()
759 text_align: TextAlign::Center
760 text_overflow: TextOverflow::Clip
761 { badge_txt }
762 }
763 }
764 column {
765 flex_grow: 1.0
766 flex_shrink: 1.0
767 min_width: Length::Px(0.0)
768 gap: 2.0
769 overflow: Overflow::Hidden
770 text {
771 width: Length::Percent(100.0)
772 font_size: 14.0
773 font_weight: FontWeight::SemiBold
774 color: p.get_foreground()
775 overflow: Overflow::Hidden
776 text_overflow: TextOverflow::Ellipsis
777 { title_txt }
778 }
779 text {
780 width: Length::Percent(100.0)
781 font_size: 12.0
782 color: p.get_muted_foreground()
783 overflow: Overflow::Hidden
784 text_overflow: TextOverflow::Ellipsis
785 { desc_txt }
786 }
787 }
788 }
789 text {
790 flex_shrink: 0.0
791 font_size: 14.0
792 font_weight: FontWeight::Bold
793 color: p.get_muted_foreground()
794 text_overflow: TextOverflow::Clip
795 { HOME_DIR_ARROW }
796 }
797 }
798 }
799 })
800 .collect();
801 let hero_style: Style = style! {
802 FlexDirection::Column
803 Overflow::Hidden
804 width: Length::Percent(100.0)
805 padding: Edges::all(SPACE_XL)
806 gap: SPACE_MD
807 background: p.get_card()
808 border: (g.get_border_width().max(1.0), p.get_primary().with_alpha(96))
809 radius: g.get_radius_xl()
810 shadow: g.get_shadow_md()
811 };
812 let on_open_markdown = move |_: &UiEvent| {
813 let _: bool = route_sig.set_if_changed(ROUTE_MARKDOWN.to_string());
814 };
815 let on_open_charts = move |_: &UiEvent| {
816 let _: bool = route_sig.set_if_changed(ROUTE_CHARTS.to_string());
817 };
818 let on_open_3d = move |_: &UiEvent| {
819 let _: bool = route_sig.set_if_changed(ROUTE_GAME_3D.to_string());
820 };
821 let on_open_stress = move |_: &UiEvent| {
822 let _: bool = route_sig.set_if_changed(ROUTE_STRESS.to_string());
823 };
824 let on_open_reactive = move |_: &UiEvent| {
825 let _: bool = route_sig.set_if_changed(ROUTE_REACTIVE.to_string());
826 };
827 let lifecycle_stats_text = move || -> String {
828 format!(
829 "Frozen Pages: {} | Mounts: {} | Freezes: {} | Resumes: {}",
830 frozen_sig.get(),
831 mounts_sig.get(),
832 freezes_sig.get(),
833 resumes_sig.get()
834 )
835 };
836 let last_hook_text = move || -> String { format!("Last Hook: {}", last_ev_sig.get()) };
837 let cached_routes_text = move || -> String {
838 let entries: Vec<EuvRouteLifecycleEntry> = entries_sig.get();
839 let summary: Vec<String> = entries
840 .iter()
841 .map(|e: &EuvRouteLifecycleEntry| format!("{}={:?}", e.get_path(), e.get_phase()))
842 .collect();
843 if summary.is_empty() {
844 LIFECYCLE_ACTIVE_DEFAULT.to_string()
845 } else {
846 format!("Cached Routes: {}", summary.join(" | "))
847 }
848 };
849 let global_local_text = move || -> String {
850 let gb: ShowcaseGlobalBanner = global_banner.get();
851 let last_src: &str = if gb.get_last_source().is_empty() {
852 SOURCE_NONE
853 } else {
854 gb.get_last_source().as_str()
855 };
856 format!(
857 "GlobalState Pulses: {} (source: {}) | LocalState (preserved across Freeze): {}",
858 gb.get_pulses(),
859 last_src,
860 local_counter.get()
861 )
862 };
863 let on_emit_pulse = move |_: &UiEvent| {
864 let seq: u32 = local_counter.get_untracked();
865 emit!(ShowcasePulseEvent {
866 source: ROUTE_OVERVIEW.to_string(),
867 seq,
868 });
869 };
870 let on_local_inc = move |_: &UiEvent| {
871 let _: bool = local_counter.update(|v: &mut u32| *v += 1);
872 };
873 let on_open_game = move |_: &UiEvent| {
874 let _: bool = route_sig.set_if_changed(ROUTE_GAME.to_string());
875 };
876 let on_open_window = move |_: &UiEvent| {
877 let _: bool = route_sig.set_if_changed(ROUTE_WINDOW.to_string());
878 };
879 view! {
880 EuvPage {
881 title: OVERVIEW_TITLE.to_string()
882 subtitle: OVERVIEW_SUBTITLE.to_string()
883 tokens: tokens
884 EuvCard {
885 title: HOME_DIR_TITLE.to_string()
886 tokens: tokens
887 subtitle: HOME_DIR_SUBTITLE
888 column {
889 width: Length::Percent(100.0)
890 gap: SPACE_SM
891 ..dir_rows
892 }
893 }
894 view {
895 style: hero_style
896 row {
897 width: Length::Percent(100.0)
898 flex_wrap: FlexWrap::Wrap
899 align: AlignItems::Center
900 gap: SPACE_XS
901 EuvBadge {
902 label: HERO_BADGE_VER.to_string()
903 tone: EuvTone::Primary
904 tokens: tokens
905 }
906 EuvBadge {
907 label: HERO_BADGE_ZERO_WV.to_string()
908 tone: EuvTone::Success
909 tokens: tokens
910 }
911 EuvBadge {
912 label: HERO_BADGE_EVA.to_string()
913 tone: EuvTone::Neutral
914 tokens: tokens
915 }
916 EuvBadge {
917 label: HERO_BADGE_FREEZE.to_string()
918 tone: EuvTone::Warning
919 tokens: tokens
920 }
921 }
922 text {
923 width: Length::Percent(100.0)
924 font_size: 20.0
925 font_weight: FontWeight::Bold
926 color: p.get_foreground()
927 { HERO_HEADLINE }
928 }
929 text {
930 width: Length::Percent(100.0)
931 font_size: 13.5
932 color: p.get_muted_foreground()
933 { HERO_DESCRIPTION }
934 }
935 EuvActionRow {
936 EuvButton {
937 label: BTN_OPEN_CHARTS.to_string()
938 tokens: tokens
939 on_click: on_open_charts
940 }
941 EuvButton {
942 label: BTN_OPEN_MARKDOWN.to_string()
943 tokens: tokens
944 secondary()
945 on_click: on_open_markdown
946 }
947 EuvButton {
948 label: BTN_OPEN_3D_RT.to_string()
949 tokens: tokens
950 secondary()
951 on_click: on_open_3d
952 }
953 EuvButton {
954 label: BTN_OPEN_STRESS_LAB.to_string()
955 tokens: tokens
956 outline()
957 on_click: on_open_stress
958 }
959 EuvButton {
960 label: BTN_TRY_REACTIVITY.to_string()
961 tokens: tokens
962 outline()
963 on_click: on_open_reactive
964 }
965 }
966 }
967 EuvStatGrid {
968 EuvStatCard {
969 label: STAT_PLATFORMS_LABEL.to_string()
970 value: STAT_PLATFORMS_VAL.to_string()
971 caption: STAT_PLATFORMS_CAP.to_string()
972 tokens: tokens
973 }
974 EuvStatCard {
975 label: STAT_SCHEMES_LABEL.to_string()
976 value: STAT_SCHEMES_VAL.to_string()
977 caption: STAT_SCHEMES_CAP.to_string()
978 tokens: tokens
979 }
980 EuvStatCard {
981 label: STAT_RENDER_LABEL.to_string()
982 value: STAT_RENDER_VAL.to_string()
983 caption: STAT_RENDER_CAP.to_string()
984 tokens: tokens
985 }
986 }
987 EuvCard {
988 title: CARD_LIFECYCLE_TITLE.to_string()
989 tokens: tokens
990 subtitle: CARD_LIFECYCLE_SUB
991 text {
992 width: Length::Percent(100.0)
993 font_size: 13.5
994 font_weight: FontWeight::SemiBold
995 color: p.get_primary()
996 { lifecycle_stats_text }
997 }
998 text {
999 width: Length::Percent(100.0)
1000 font_size: 12.5
1001 font_family: FontFamily::Monospace
1002 color: p.get_muted_foreground()
1003 { last_hook_text }
1004 }
1005 text {
1006 width: Length::Percent(100.0)
1007 font_size: 12.5
1008 color: p.get_foreground()
1009 { cached_routes_text }
1010 }
1011 text {
1012 width: Length::Percent(100.0)
1013 font_size: 12.5
1014 font_weight: FontWeight::Medium
1015 color: p.get_success()
1016 { global_local_text }
1017 }
1018 EuvActionRow {
1019 EuvButton {
1020 label: BTN_EMIT_PULSE.to_string()
1021 tokens: tokens
1022 sm()
1023 on_click: on_emit_pulse
1024 }
1025 EuvButton {
1026 label: BTN_LOCAL_INC.to_string()
1027 tokens: tokens
1028 secondary()
1029 sm()
1030 on_click: on_local_inc
1031 }
1032 EuvButton {
1033 label: BTN_OPEN_GAME_ENGINE.to_string()
1034 tokens: tokens
1035 outline()
1036 sm()
1037 on_click: on_open_game
1038 }
1039 EuvButton {
1040 label: BTN_OPEN_OS_SERVICES.to_string()
1041 tokens: tokens
1042 outline()
1043 sm()
1044 on_click: on_open_window
1045 }
1046 }
1047 }
1048 EuvCard {
1049 title: CARD_PLATFORMS_TITLE.to_string()
1050 tokens: tokens
1051 subtitle: CARD_PLATFORMS_SUB
1052 EuvTable {
1053 headers: vec![
1054 TABLE_COL_TARGET.to_string(),
1055 TABLE_COL_BACKEND.to_string(),
1056 TABLE_COL_GPU.to_string(),
1057 ]
1058 rows: vec![
1059 vec![ROW_WEB.to_string(), ROW_WEB_API.to_string(), ROW_WEB_GPU.to_string()],
1060 vec![ROW_MACOS.to_string(), ROW_MACOS_API.to_string(), ROW_MACOS_GPU.to_string()],
1061 vec![ROW_IOS.to_string(), ROW_IOS_API.to_string(), ROW_MACOS_GPU.to_string()],
1062 vec![ROW_ANDROID.to_string(), ROW_ANDROID_API.to_string(), ROW_ANDROID_GPU.to_string()],
1063 vec![ROW_WINDOWS.to_string(), ROW_WINDOWS_API.to_string(), ROW_WINDOWS_GPU.to_string()],
1064 vec![ROW_LINUX.to_string(), ROW_LINUX_API.to_string(), ROW_ANDROID_GPU.to_string()],
1065 ]
1066 tokens: tokens
1067 }
1068 }
1069 }
1070 }
1071}
1072
1073pub fn mount_markdown_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1084 let p: ThemePalette = tokens.get_palette();
1085 let eva: CodeThemePalette = CodeThemePalette::resolve(tokens.get_mode());
1086 let st_toggle: ShowcaseState = state.clone();
1087 let theme_mode_sig: Signal<ThemeMode> = state.get_theme().get_mode();
1088 let lang_tab: Signal<usize> = state.get_markdown_lang_tab();
1089 let selectable_sig: Signal<bool> = state.get_markdown_selectable();
1090 let copy_log: Signal<String> = state.get_markdown_copy_log();
1091 let link_log: Signal<String> = state.get_markdown_link_log();
1092 let tasks_toggled: Signal<u32> = state.get_markdown_tasks_toggled();
1093 let copy_log_doc: Signal<String> = copy_log;
1094 let link_log_doc: Signal<String> = link_log;
1095 let tasks_doc: Signal<u32> = tasks_toggled;
1096 let active_theme_desc = move || -> String {
1097 match theme_mode_sig.get() {
1098 ThemeMode::Light => MD_THEME_DESC_LIGHT.to_string(),
1099 ThemeMode::Dark => MD_THEME_DESC_DARK.to_string(),
1100 }
1101 };
1102 let swatch_nodes: Vec<NodeId> = (0usize..6usize)
1103 .map(|slot: usize| {
1104 let swatch_style = move || -> Style {
1105 let live_eva: CodeThemePalette = CodeThemePalette::resolve(theme_mode_sig.get());
1106 let col: Color = match slot {
1107 0 => live_eva.get_background(),
1108 1 => live_eva.get_keyword(),
1109 2 => live_eva.get_function(),
1110 3 => live_eva.get_number(),
1111 4 => live_eva.get_constant(),
1112 _ => live_eva.get_property(),
1113 };
1114 Style::default()
1115 .width(Length::Px(22.0))
1116 .height(Length::Px(22.0))
1117 .radius(6.0)
1118 .background(col)
1119 .border(1.0, live_eva.get_border())
1120 };
1121 view! {
1122 view {
1123 bind_style: swatch_style
1124 }
1125 }
1126 })
1127 .collect();
1128 let on_toggle_eva = move |_: &UiEvent| {
1129 st_toggle.toggle_theme_mode();
1130 };
1131 let on_emit_pulse = move |_: &UiEvent| {
1132 emit!(ShowcasePulseEvent {
1133 source: ROUTE_MARKDOWN.to_string(),
1134 seq: 1,
1135 });
1136 };
1137 let build_code_tab = move || -> Vec<NodeId> {
1138 let tab: usize = lang_tab.get();
1139 let is_sel: bool = selectable_sig.get();
1140 let live_tok: ThemeTokens = live_tokens_untracked(tokens);
1141 let (src, lang, fname): (&str, &str, &str) = match tab {
1142 1 => (MD_SAMPLE_TS, MD_LANG_TS, MD_FILE_TS),
1143 2 => (MD_SAMPLE_JSON, MD_LANG_JSON, MD_FILE_JSON),
1144 3 => (MD_SAMPLE_DIFF, MD_LANG_DIFF, MD_FILE_DIFF),
1145 _ => (MD_SAMPLE_RUST, MD_LANG_RUST, MD_FILE_RUST),
1146 };
1147 let cb_log: Signal<String> = copy_log;
1148 let block: NodeId = EuvCodeBlock::new(src.to_string(), live_tok)
1149 .language(lang)
1150 .filename(fname)
1151 .line_numbers(true)
1152 .max_height(260.0)
1153 .selectable(is_sel)
1154 .on_copy(move |txt: &str| {
1155 let _: bool = cb_log.set(format!(
1156 "Copied {} bytes ({lang}) via Eva Bold EuvCodeBlock",
1157 txt.len()
1158 ));
1159 })
1160 .mount();
1161 vec![block]
1162 };
1163 let telemetry_text = move || -> String {
1164 format!(
1165 "Copy: {} | Link: {} | Tasks Toggled: {} | Selectable: {}",
1166 copy_log.get(),
1167 link_log.get(),
1168 tasks_toggled.get(),
1169 selectable_sig.get()
1170 )
1171 };
1172 let build_md_doc = move || -> Vec<NodeId> {
1173 let is_sel: bool = selectable_sig.get();
1174 let live_tok: ThemeTokens = live_tokens_untracked(tokens);
1175 let doc_node: NodeId = EuvMarkdown::new(MD_FULL_DOCUMENT.to_string(), live_tok)
1176 .selectable(is_sel)
1177 .on_link(move |url: &str| {
1178 let _: bool = link_log_doc.set(url.to_string());
1179 })
1180 .on_copy(move |code: &str| {
1181 let _: bool =
1182 copy_log_doc.set(format!("Copied {} bytes from Markdown block", code.len()));
1183 })
1184 .on_toggle_task(move |_idx: usize, _checked: bool| {
1185 let _: bool = tasks_doc.update(|n: &mut u32| *n += 1);
1186 })
1187 .mount();
1188 vec![doc_node]
1189 };
1190 view! {
1191 EuvPage {
1192 title: MD_STUDIO_TITLE.to_string()
1193 subtitle: MD_STUDIO_SUBTITLE.to_string()
1194 tokens: tokens
1195 EuvCard {
1196 title: MD_THEME_CARD_TITLE.to_string()
1197 tokens: tokens
1198 subtitle: MD_THEME_CARD_SUB
1199 text {
1200 font_size: 12.5
1201 font_family: FontFamily::Monospace
1202 font_weight: FontWeight::SemiBold
1203 color: eva.get_keyword()
1204 { active_theme_desc }
1205 }
1206 row {
1207 width: Length::Percent(100.0)
1208 align: AlignItems::Center
1209 flex_wrap: FlexWrap::Wrap
1210 gap: SPACE_SM
1211 ..swatch_nodes
1212 }
1213 EuvActionRow {
1214 EuvButton {
1215 label: BTN_TOGGLE_EVA_MODE.to_string()
1216 tokens: tokens
1217 sm()
1218 on_click: on_toggle_eva
1219 }
1220 EuvButton {
1221 label: BTN_EMIT_PULSE.to_string()
1222 tokens: tokens
1223 outline()
1224 sm()
1225 on_click: on_emit_pulse
1226 }
1227 EuvSwitch {
1228 checked: selectable_sig
1229 label: MD_SELECTABLE_LABEL.to_string()
1230 tokens: tokens
1231 }
1232 }
1233 }
1234 EuvCard {
1235 title: MD_CODE_CARD_TITLE.to_string()
1236 tokens: tokens
1237 subtitle: MD_CODE_CARD_SUB
1238 EuvSegmented {
1239 options: vec![
1240 MD_TAB_RUST.to_string(),
1241 MD_TAB_TS.to_string(),
1242 MD_TAB_JSON.to_string(),
1243 MD_TAB_DIFF.to_string(),
1244 ]
1245 selected: lang_tab
1246 tokens: tokens
1247 }
1248 column {
1249 width: Length::Percent(100.0)
1250 bind_children: build_code_tab
1251 }
1252 text {
1253 font_size: 12.0
1254 font_family: FontFamily::Monospace
1255 color: p.get_primary()
1256 { telemetry_text }
1257 }
1258 }
1259 EuvCard {
1260 title: MD_DOC_CARD_TITLE.to_string()
1261 tokens: tokens
1262 subtitle: MD_DOC_CARD_SUB
1263 column {
1264 width: Length::Percent(100.0)
1265 bind_children: build_md_doc
1266 }
1267 }
1268 }
1269 }
1270}
1271
1272pub fn mount_reactive_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1283 let p: ThemePalette = tokens.get_palette();
1284 let counter: Signal<i32> = state.get_counter();
1285 let doubled: Memo<i32> = state.get_doubled();
1286 view! {
1287 EuvPage {
1288 title: REACTIVE_TITLE.to_string()
1289 subtitle: REACTIVE_SUBTITLE.to_string()
1290 tokens: tokens
1291 EuvCard {
1292 title: REACTIVE_CARD_TITLE.to_string()
1293 tokens: tokens
1294 subtitle: REACTIVE_CARD_SUB
1295 column {
1296 gap: SPACE_MD
1297 text {
1298 font_size: 18.0
1299 font_weight: FontWeight::Bold
1300 color: p.get_foreground()
1301 { move || format!("{PREFIX_COUNTER}{}", counter.get()) }
1302 }
1303 text {
1304 font_size: 15.0
1305 color: p.get_primary()
1306 { move || format!("{PREFIX_DOUBLED}{}", doubled.get()) }
1307 }
1308 EuvActionRow {
1309 EuvButton {
1310 label: BTN_INCREMENT.to_string()
1311 tokens: tokens
1312 on_click: move |_: &UiEvent| {
1313 let _: bool = counter.update(|v: &mut i32| *v += 1);
1314 }
1315 }
1316 EuvButton {
1317 label: BTN_BATCH_TEN.to_string()
1318 tokens: tokens
1319 secondary()
1320 on_click: move |_: &UiEvent| {
1321 batch(|| {
1322 for _ in 0..10 {
1323 let _: bool = counter.update(|v: &mut i32| *v += 1);
1324 }
1325 });
1326 }
1327 }
1328 EuvButton {
1329 label: BTN_RESET.to_string()
1330 tokens: tokens
1331 outline()
1332 on_click: move |_: &UiEvent| {
1333 let _: bool = counter.set_if_changed(0);
1334 }
1335 }
1336 }
1337 }
1338 }
1339 }
1340 }
1341}
1342
1343pub fn mount_render_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1354 let p: ThemePalette = tokens.get_palette();
1355 let g: ThemeGeometry = tokens.get_geometry();
1356 let mode_idx: Signal<usize> = state.get_render_mode_index();
1357 view! {
1358 EuvPage {
1359 title: RENDER_TITLE.to_string()
1360 subtitle: RENDER_SUBTITLE.to_string()
1361 tokens: tokens
1362 EuvCard {
1363 title: RENDER_CARD_TITLE.to_string()
1364 tokens: tokens
1365 subtitle: RENDER_CARD_SUB
1366 EuvSegmented {
1367 options: vec![
1368 MODE_AUTO.to_string(),
1369 MODE_SOFTWARE.to_string(),
1370 MODE_HARDWARE.to_string(),
1371 MODE_HYBRID.to_string(),
1372 ]
1373 selected: mode_idx
1374 tokens: tokens
1375 }
1376 column {
1377 gap: SPACE_SM
1378 text {
1379 font_size: 13.0
1380 font_weight: FontWeight::Medium
1381 color: p.get_primary()
1382 { move || format!("Active Pipeline Selection: {}", match mode_idx.get() { 1 => MODE_SOFTWARE, 2 => MODE_HARDWARE, 3 => MODE_HYBRID, _ => MODE_AUTO }) }
1383 }
1384 text {
1385 font_size: 13.0
1386 font_weight: FontWeight::Medium
1387 color: p.get_muted_foreground()
1388 { CANVAS_LABEL }
1389 }
1390 canvas {
1391 width: Length::Percent(100.0)
1392 height: Length::Px(140.0)
1393 background: p.get_muted()
1394 border: (g.get_border_width(), p.get_border())
1395 radius: g.get_radius_md()
1396 painter: move |bounds: Rect, dl: &mut DisplayList| {
1397 let bw: f32 = bounds.get_width().max(120.0);
1398 let rect_w: f32 = (bw * 0.28).clamp(56.0, 160.0);
1399 let circle_r: f32 = (bw * 0.08).clamp(20.0, 42.0);
1400 let circle_x: f32 = bounds.get_x() + 16.0 + rect_w + circle_r + 20.0;
1401 let line_x0: f32 = (circle_x + circle_r + 16.0).min(bounds.right() - 24.0);
1402 let line_x1: f32 = (bounds.right() - 16.0).max(line_x0);
1403 dl.push(DrawCommand::FillRoundedRect {
1404 rect: Rect::new(bounds.get_x() + 16.0, bounds.get_y() + 16.0, rect_w, 108.0),
1405 color: p.get_primary(),
1406 radius: CornerRadius::all(14.0),
1407 border: Border::default(),
1408 });
1409 dl.push(DrawCommand::Circle {
1410 center: Point::new(circle_x.min(bounds.right() - circle_r - 8.0), bounds.get_y() + 70.0),
1411 radius: circle_r,
1412 color: p.get_success(),
1413 });
1414 dl.push(DrawCommand::Line {
1415 from: Point::new(line_x0, bounds.get_y() + 28.0),
1416 to: Point::new(line_x1, bounds.get_y() + 112.0),
1417 color: p.get_warning(),
1418 width: 3.0,
1419 });
1420 }
1421 }
1422 }
1423 }
1424 }
1425 }
1426}
1427
1428pub fn mount_window_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
1439 let p: ThemePalette = tokens.get_palette();
1440 let font_info: SystemFontInfo = NativeSystemFont::system().font_info();
1441 let gpu_driver: NativeGpuDriver = NativeGpuDriver::probe(GraphicsBackend::Metal);
1442 let gpu_info: &GpuAdapterInfo = gpu_driver.get_adapter();
1443 let platform: PlatformKind = current_platform();
1444 let caps: PlatformCapabilities = PlatformCapabilities::for_platform(platform);
1445 let hub: PlatformServiceHub = PlatformServiceHub::new(platform);
1446 let cam_key: &'static str = SystemPermission::Camera.native_key(platform);
1447 let island_active: Signal<bool> = state.get_island_active();
1448 let island_progress: Signal<u8> = state.get_island_progress();
1449 let cam_status: Signal<String> = state.get_camera_perm_status();
1450 let proto_status: Signal<String> = state.get_protocol_status();
1451 let a11y_count: Signal<u32> = state.get_a11y_announcements();
1452 let haptic_count: Signal<u32> = state.get_haptic_pulses();
1453 let bp_sig: Signal<Breakpoint> = use_breakpoint();
1454 let vp_sig: Signal<Size> = use_viewport_size();
1455 let summary: String = format!(
1456 "Platform: {:?} | Font: {} ({:?}) | GPU: {} (shader_ok={})",
1457 platform,
1458 font_info.get_family_name(),
1459 font_info.get_backend(),
1460 gpu_info.get_device_name(),
1461 gpu_info.get_shader_compiled()
1462 );
1463 let native_feedback: Signal<String> = Signal::new(
1464 "Ready — tap any OS capability below to trigger native platform feedback".to_string(),
1465 );
1466 let fs_sig: Signal<bool> = state.get_fullscreen();
1467 let ctx_win: Context = current_context();
1468 let prev_fs: Rc<Cell<bool>> = Rc::new(Cell::new(fs_sig.get_untracked()));
1469 let (fs_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
1470 Effect::new(move || {
1471 let now_fs: bool = fs_sig.get();
1472 if prev_fs.replace(now_fs) != now_fs {
1473 let arg: &str = if now_fs { "on" } else { "off" };
1474 let _: bool = dispatch_native_action(NATIVE_ACTION_FULLSCREEN, arg, "");
1475 let _: bool = native_feedback.set(format!("Immersive fullscreen mode: {arg}"));
1476 }
1477 })
1478 });
1479 let target_plat_idx: Signal<usize> = state.get_os_target_platform_idx();
1480 let island_mode_idx: Signal<usize> = state.get_island_mode_idx();
1481 let sys_notifs: Signal<Vec<(String, String)>> = state.get_system_notifications();
1482 let perm_statuses: Signal<Vec<PermissionStatus>> = state.get_permission_statuses();
1483 let all_platforms: [PlatformKind; 7] = [
1484 PlatformKind::Ios,
1485 PlatformKind::IpadOs,
1486 PlatformKind::Android,
1487 PlatformKind::MacOs,
1488 PlatformKind::Windows,
1489 PlatformKind::Linux,
1490 PlatformKind::Web,
1491 ];
1492 let all_island_modes: [IslandPresentationMode; 6] = [
1493 IslandPresentationMode::Compact,
1494 IslandPresentationMode::Minimal,
1495 IslandPresentationMode::Expanded,
1496 IslandPresentationMode::LockScreen,
1497 IslandPresentationMode::FallbackNotification,
1498 IslandPresentationMode::FallbackStatusBar,
1499 ];
1500 let all_perms: [SystemPermission; 14] = [
1501 SystemPermission::Camera,
1502 SystemPermission::Microphone,
1503 SystemPermission::LocationWhenInUse,
1504 SystemPermission::LocationAlways,
1505 SystemPermission::Notifications,
1506 SystemPermission::Photos,
1507 SystemPermission::Contacts,
1508 SystemPermission::Calendar,
1509 SystemPermission::Bluetooth,
1510 SystemPermission::Biometrics,
1511 SystemPermission::FileStorage,
1512 SystemPermission::ClipboardRead,
1513 SystemPermission::MotionSensors,
1514 SystemPermission::LocalNetwork,
1515 ];
1516 let fps_limit_sig: Signal<Option<u32>> = ctx_win.get_fps_limit();
1517 let live_fps_sig: Signal<f32> = ctx_win.get_live_fps();
1518 let native_hz_sig: Signal<f32> = ctx_win.get_display_refresh_rate();
1519 let fps_idx: Signal<usize> = Signal::new(match fps_limit_sig.get_untracked() {
1520 Some(30) => 1,
1521 Some(60) => 2,
1522 Some(120) => 3,
1523 Some(144) => 4,
1524 Some(240) => 5,
1525 _ => 0,
1526 });
1527 let (fps_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
1528 Effect::new(move || {
1529 let next_cap: Option<u32> = match fps_idx.get() {
1530 1 => Some(30),
1531 2 => Some(60),
1532 3 => Some(120),
1533 4 => Some(144),
1534 5 => Some(240),
1535 _ => None,
1536 };
1537 let _: bool = fps_limit_sig.set_if_changed(next_cap);
1538 })
1539 });
1540 let mut body_id: NodeId = NodeId::default();
1541 let mut fps_card_id: NodeId = NodeId::default();
1542 let app_state_sig: Signal<AppState> = use_app_state();
1543 let sys_theme_sig: Signal<SystemTheme> = use_system_theme();
1544 let net_status_sig: Signal<NetworkStatus> = use_network_status();
1545 let kb_height_sig: Signal<f32> = use_keyboard_height();
1546 let safe_area_sig: Signal<SafeAreaInsets> = use_safe_area();
1547 let sys_log_sig: Signal<Vec<String>> = state.get_system_event_log();
1548 let sys_count_sig: Signal<u32> = state.get_system_event_count();
1549 let bg_frozen_sig: Signal<bool> = state.get_bg_frozen();
1550 let bg_freeze_cnt: Signal<u32> = state.get_bg_freeze_count();
1551 let bg_restore_cnt: Signal<u32> = state.get_bg_restore_count();
1552 let page_appear_count: Signal<u32> = Signal::new(0);
1553 let page_disappear_count: Signal<u32> = Signal::new(0);
1554 let _: SystemEventSubscription = on_appear(move || {
1555 let _: bool = page_appear_count.update(|n: &mut u32| *n = n.saturating_add(1));
1556 });
1557 let _: SystemEventSubscription = on_disappear(move || {
1558 let _: bool = page_disappear_count.update(|n: &mut u32| *n = n.saturating_add(1));
1559 });
1560 let sys_primary_line = move || -> String {
1561 format!(
1562 "AppState: {:?} | OS Theme: {:?} | Network: {:?}",
1563 app_state_sig.get(),
1564 sys_theme_sig.get(),
1565 net_status_sig.get()
1566 )
1567 };
1568 let sys_freeze_line = move || -> String {
1569 let mode: &str = if bg_frozen_sig.get() {
1570 BG_FREEZE_STATUS_FROZEN
1571 } else {
1572 BG_FREEZE_STATUS_ACTIVE
1573 };
1574 format!(
1575 "Background Freeze: {mode} | Freezes: {} | Restores: {}",
1576 bg_freeze_cnt.get(),
1577 bg_restore_cnt.get()
1578 )
1579 };
1580 let sys_secondary_line = move || -> String {
1581 let sa: SafeAreaInsets = safe_area_sig.get();
1582 format!(
1583 "Keyboard: {:.0}px | SafeArea: T{:.0} R{:.0} B{:.0} L{:.0} | Page Appear: {} / Disappear: {} | Total Events: {}",
1584 kb_height_sig.get(),
1585 sa.get_top(),
1586 sa.get_right(),
1587 sa.get_bottom(),
1588 sa.get_left(),
1589 page_appear_count.get(),
1590 page_disappear_count.get(),
1591 sys_count_sig.get()
1592 )
1593 };
1594 let build_sys_log_rows = move || -> Vec<NodeId> {
1595 let live_tok: ThemeTokens = live_tokens_untracked(tokens);
1596 let live_p: ThemePalette = live_tok.get_palette();
1597 sys_log_sig
1598 .get()
1599 .into_iter()
1600 .map(|entry: String| {
1601 view! {
1602 text {
1603 width: Length::Percent(100.0)
1604 font_size: 12.0
1605 font_family: FontFamily::Monospace
1606 color: live_p.get_muted_foreground()
1607 { entry }
1608 }
1609 }
1610 })
1611 .collect()
1612 };
1613 let page: NodeId = view! {
1614 EuvPage {
1615 title: WINDOW_TITLE.to_string()
1616 subtitle: WINDOW_SUBTITLE.to_string()
1617 tokens: tokens
1618 EuvCard {
1619 title: SYS_EVENTS_CARD_TITLE.to_string()
1620 tokens: tokens
1621 subtitle: SYS_EVENTS_CARD_SUB
1622 selectable: true
1623 text {
1624 width: Length::Percent(100.0)
1625 font_size: 13.5
1626 font_weight: FontWeight::SemiBold
1627 color: p.get_primary()
1628 { sys_primary_line }
1629 }
1630 text {
1631 width: Length::Percent(100.0)
1632 font_size: 12.5
1633 font_weight: FontWeight::Medium
1634 color: p.get_success()
1635 { sys_freeze_line }
1636 }
1637 text {
1638 width: Length::Percent(100.0)
1639 font_size: 12.5
1640 font_family: FontFamily::Monospace
1641 color: p.get_foreground()
1642 { sys_secondary_line }
1643 }
1644 column {
1645 width: Length::Percent(100.0)
1646 padding: Edges::all(SPACE_SM)
1647 gap: 4.0
1648 background: p.get_muted()
1649 radius: tokens.get_geometry().get_radius_md()
1650 overflow: Overflow::Hidden
1651 bind_children: build_sys_log_rows
1652 }
1653 }
1654 EuvCard {
1655 title: WINDOW_CARD_TITLE.to_string()
1656 tokens: tokens
1657 subtitle: WINDOW_CARD_SUB
1658 column {
1659 node_ref: body_id
1660 role: A11yRole::Region
1661 a11y_label: "Platform Telemetry"
1662 gap: SPACE_MD
1663 text {
1664 font_size: 13.0
1665 font_weight: FontWeight::SemiBold
1666 color: p.get_success()
1667 { move || native_feedback.get() }
1668 }
1669 text {
1670 font_size: 14.0
1671 font_weight: FontWeight::Medium
1672 color: p.get_foreground()
1673 { summary }
1674 }
1675 text {
1676 font_size: 13.0
1677 font_weight: FontWeight::SemiBold
1678 color: p.get_primary()
1679 { move || {
1680 let vp: Size = vp_sig.get();
1681 format!("Live Viewport: {:.0}x{:.0} | Breakpoint: {:?}", vp.get_width(), vp.get_height(), bp_sig.get())
1682 } }
1683 }
1684 text {
1685 font_size: 13.0
1686 color: p.get_primary()
1687 { move || format!("Dynamic Island: active={} ({}%) | Mode: {:?} | Biometrics: {:?}", island_active.get(), island_progress.get(), PlatformServiceHub::default_island_mode(platform), hub.biometric_kind()) }
1688 }
1689 text {
1690 font_size: 13.0
1691 color: p.get_muted_foreground()
1692 { move || format!("Protocol: {} | Camera: {} ({cam_key})", proto_status.get(), cam_status.get()) }
1693 }
1694 text {
1695 font_size: 13.0
1696 color: p.get_muted_foreground()
1697 { move || format!("A11y Bridge: {} (announcements={}) | Haptics: {} (pulses={})", caps.get_accessibility_bridge(), a11y_count.get(), caps.get_haptics(), haptic_count.get()) }
1698 }
1699 EuvActionRow {
1700 EuvButton {
1701 label: "Toggle Dynamic Island".to_string()
1702 tokens: tokens
1703 on_click: move |_: &UiEvent| {
1704 let next_active: bool = !island_active.get_untracked();
1705 let _: bool = island_active.set_if_changed(next_active);
1706 let next_pct: u8 = if next_active {
1707 let cur: u8 = island_progress.get_untracked();
1708 if cur >= 100 { 25 } else { (cur + 25).min(100) }
1709 } else {
1710 island_progress.get_untracked()
1711 };
1712 let _: bool = island_progress.set_if_changed(next_pct);
1713 let mut svc: PlatformServiceHub = PlatformServiceHub::new(platform);
1714 if next_active {
1715 let mut content: LiveActivityContent = LiveActivityContent::new(
1716 "Euv Live Activity".to_string(),
1717 format!("Active ({next_pct}%) on {platform:?}"),
1718 );
1719 content.set_progress_percent(Some(next_pct));
1720 let _ = svc.start_live_activity("euv-showcase-island".to_string(), content);
1721 let _: bool = native_feedback.set(format!(
1722 "Dynamic Island LIVE ({next_pct}%) dispatched to {platform:?}"
1723 ));
1724 } else {
1725 let _: bool = dispatch_native_action(
1726 NATIVE_ACTION_ISLAND,
1727 "stop",
1728 "Dynamic Island paused",
1729 );
1730 let _: bool = native_feedback.set("Dynamic Island session ended".to_string());
1731 }
1732 }
1733 }
1734 EuvButton {
1735 label: "Register euv:// Protocol".to_string()
1736 tokens: tokens
1737 secondary()
1738 on_click: move |_: &UiEvent| {
1739 let mut reg: ProtocolRegistry = ProtocolRegistry::new();
1740 let spec: ProtocolRegistration = ProtocolRegistration::new(
1741 "euv".to_string(),
1742 "euv Native Showcase".to_string(),
1743 SHOWCASE_BUNDLE_ID.to_string(),
1744 );
1745 let native_ok: bool =
1746 dispatch_native_action(NATIVE_ACTION_PROTOCOL, "euv", SHOWCASE_BUNDLE_ID);
1747 if let Ok(desc) = reg.register(spec, platform) {
1748 let tag: &str = if native_ok { "OS Bridged" } else { "Verified" };
1749 let msg: String = format!("Registered euv:// via {} ({tag})", desc.get_mechanism());
1750 let _: bool = proto_status.set_if_changed(msg.clone());
1751 let _: bool = native_feedback.set(msg);
1752 }
1753 }
1754 }
1755 EuvButton {
1756 label: "Request Camera Permission".to_string()
1757 tokens: tokens
1758 outline()
1759 on_click: move |_: &UiEvent| {
1760 let mut mgr: PermissionManager = PermissionManager::new();
1761 let desc: PermissionDescriptor = mgr.request(
1762 SystemPermission::Camera,
1763 "Native camera preview".to_string(),
1764 platform,
1765 );
1766 let msg: String = format!("{:?} ({})", desc.get_status(), desc.get_native_key());
1767 let _: bool = cam_status.set_if_changed(msg.clone());
1768 let _: bool = native_feedback.set(format!("Permission requested: {msg}"));
1769 }
1770 }
1771 EuvButton {
1772 label: "Announce A11y + Haptic".to_string()
1773 tokens: tokens
1774 outline()
1775 on_click: move |_: &UiEvent| {
1776 let mut svc: PlatformServiceHub = PlatformServiceHub::new(platform);
1777 let fired: bool = svc.trigger_haptic(HapticStyle::Medium);
1778 svc.announce_a11y(
1779 "euv native accessibility pulse".to_string(),
1780 A11yLiveRegion::Polite,
1781 );
1782 let _: bool = a11y_count.update(|v: &mut u32| *v += 1);
1783 let _: bool = haptic_count.update(|v: &mut u32| *v += 1);
1784 let _: bool = native_feedback.set(format!(
1785 "Dispatched Haptic pulse (ok={fired}) + A11y announcement #{}",
1786 a11y_count.get_untracked()
1787 ));
1788 }
1789 }
1790 }
1791 EuvSwitch {
1792 checked: fs_sig
1793 label: SWITCH_FULLSCREEN.to_string()
1794 tokens: tokens
1795 }
1796 EuvCodeBlock {
1797 code: CODE_WINDOW_SNIPPET.to_string()
1798 tokens: tokens
1799 }
1800 }
1801 }
1802 EuvCard {
1803 title: "Cross-Platform Frame Rate Limiter".to_string()
1804 tokens: tokens
1805 node_ref: fps_card_id
1806 subtitle: "Prioritizes native hardware refresh rate (120Hz/144Hz/180Hz+) across Desktop, Web, Android & iOS"
1807 EuvSegmented {
1808 options: vec![
1809 "Native Auto".to_string(),
1810 "30 FPS".to_string(),
1811 "60 FPS".to_string(),
1812 "120 FPS".to_string(),
1813 "144 FPS".to_string(),
1814 "240 FPS".to_string(),
1815 ]
1816 selected: fps_idx
1817 tokens: tokens
1818 }
1819 text {
1820 font_size: 13.0
1821 font_weight: FontWeight::SemiBold
1822 color: p.get_primary()
1823 { move || {
1824 let native_hz: f32 = native_hz_sig.get();
1825 let cap_txt: String = match fps_limit_sig.get() {
1826 None => format!("Native Auto ({native_hz:.0} Hz)"),
1827 Some(v) => format!("Capped at {v} FPS"),
1828 };
1829 let live_fps: f32 = live_fps_sig.get();
1830 if !live_fps.is_finite() || live_fps <= 0.05 {
1831 format!("Frame Rate Policy: {cap_txt} | Status: Idle (0.0 FPS)")
1832 } else {
1833 format!(
1834 "Frame Rate Policy: {cap_txt} | Live Measured: {live_fps:.1} FPS"
1835 )
1836 }
1837 } }
1838 }
1839 }
1840 EuvCard {
1841 title: "Cross-Platform Dynamic Island & Notifications".to_string()
1842 tokens: tokens
1843 subtitle: "Test Live Activities across all 7 platforms and dispatch native OS notifications"
1844 EuvSegmented {
1845 options: vec![
1846 "iOS".to_string(),
1847 "iPadOS".to_string(),
1848 LABEL_PLATFORM_ANDROID.to_string(),
1849 LABEL_PLATFORM_MACOS.to_string(),
1850 "Windows".to_string(),
1851 "Linux".to_string(),
1852 "Web".to_string(),
1853 ]
1854 selected: target_plat_idx
1855 tokens: tokens
1856 }
1857 EuvSegmented {
1858 options: vec![
1859 "Compact".to_string(),
1860 "Minimal".to_string(),
1861 "Expanded".to_string(),
1862 "LockScreen".to_string(),
1863 "FallbackNotif".to_string(),
1864 "StatusBar".to_string(),
1865 ]
1866 selected: island_mode_idx
1867 tokens: tokens
1868 }
1869 column {
1870 width: Length::Percent(100.0)
1871 padding: Edges::all(SPACE_MD)
1872 gap: SPACE_XS
1873 background: Color::hex(0x09090B)
1874 radius: 20.0
1875 text {
1876 font_size: 12.0
1877 font_weight: FontWeight::SemiBold
1878 color: Color::hex(0xF8FAFC)
1879 { move || {
1880 let tp: PlatformKind = all_platforms[target_plat_idx.get() % 7];
1881 let im: IslandPresentationMode = all_island_modes[island_mode_idx.get() % 6];
1882 let def_im: IslandPresentationMode = PlatformServiceHub::default_island_mode(tp);
1883 let active: bool = island_active.get();
1884 let pct: u8 = island_progress.get();
1885 let state_tag: &str = if active { "LIVE" } else { "IDLE" };
1886 format!(
1887 "[{state_tag}] Dynamic Island ({tp:?}) | Mode: {im:?} (OS Default: {def_im:?}) | Progress: {pct}%"
1888 )
1889 } }
1890 }
1891 }
1892 EuvActionRow {
1893 EuvButton {
1894 label: "Trigger Alert Notification".to_string()
1895 tokens: tokens
1896 sm()
1897 on_click: move |_: &UiEvent| {
1898 let tp: PlatformKind = all_platforms[target_plat_idx.get_untracked() % 7];
1899 let mut svc: PlatformServiceHub = PlatformServiceHub::new(tp);
1900 let n: SystemNotification = SystemNotification::new(
1901 "euv-alert".to_string(),
1902 format!("{tp:?} Alert Notification"),
1903 "High-priority native OS alert dispatched cleanly".to_string(),
1904 );
1905 svc.send_notification(n.clone());
1906 let _: bool = sys_notifs.update(|v: &mut Vec<(String, String)>| {
1907 v.insert(0, (n.get_title().clone(), n.get_body().clone()));
1908 v.truncate(5);
1909 });
1910 }
1911 }
1912 EuvButton {
1913 label: "Trigger Silent + Badge(3)".to_string()
1914 tokens: tokens
1915 secondary()
1916 sm()
1917 on_click: move |_: &UiEvent| {
1918 let tp: PlatformKind = all_platforms[target_plat_idx.get_untracked() % 7];
1919 let mut svc: PlatformServiceHub = PlatformServiceHub::new(tp);
1920 let mut n: SystemNotification = SystemNotification::new(
1921 "euv-sync".to_string(),
1922 format!("{tp:?} Silent Sync (Badge 3)"),
1923 "Background OTA sync completed silently".to_string(),
1924 );
1925 n.set_silent(true);
1926 n.set_badge_count(Some(3));
1927 svc.send_notification(n.clone());
1928 let _: bool = sys_notifs.update(|v: &mut Vec<(String, String)>| {
1929 v.insert(0, (n.get_title().clone(), n.get_body().clone()));
1930 v.truncate(5);
1931 });
1932 }
1933 }
1934 EuvButton {
1935 label: "Clear Notifications".to_string()
1936 tokens: tokens
1937 outline()
1938 sm()
1939 on_click: move |_: &UiEvent| {
1940 let _: bool = sys_notifs.set_if_changed(Vec::new());
1941 }
1942 }
1943 }
1944 EuvSonner {
1945 messages: sys_notifs
1946 tokens: tokens
1947 }
1948 }
1949 EuvCard {
1950 title: "Complete 14-Category OS Permissions Matrix".to_string()
1951 tokens: tokens
1952 subtitle: "Inspect per-platform native entitlement keys and test Grant / Deny flows"
1953 column {
1954 width: Length::Percent(100.0)
1955 gap: SPACE_XS
1956 bind_children: move || {
1957 let tp: PlatformKind = all_platforms[target_plat_idx.get() % 7];
1958 let statuses: Vec<PermissionStatus> = perm_statuses.get();
1959 let g: ThemeGeometry = tokens.get_geometry();
1960 all_perms
1961 .iter()
1962 .copied()
1963 .enumerate()
1964 .map(|(idx, perm): (usize, SystemPermission)| {
1965 let st: PermissionStatus = statuses
1966 .get(idx)
1967 .copied()
1968 .unwrap_or(PermissionStatus::NotDetermined);
1969 let native_key: &'static str = perm.native_key(tp);
1970 view! {
1971 column {
1972 width: Length::Percent(100.0)
1973 padding: Edges::symmetric(SPACE_SM, SPACE_SM)
1974 gap: SPACE_XS
1975 background: p.get_card()
1976 border: (g.get_border_width(), p.get_border())
1977 radius: g.get_radius_sm()
1978 text {
1979 width: Length::Percent(100.0)
1980 font_size: 12.0
1981 color: p.get_foreground()
1982 { format!("{perm:?} [{st:?}] · {native_key}") }
1983 }
1984 EuvActionRow {
1985 EuvButton {
1986 label: "Request".to_string()
1987 tokens: tokens
1988 outline()
1989 sm()
1990 on_click: move |_: &UiEvent| {
1991 let mut mgr: PermissionManager = PermissionManager::new();
1992 let desc: PermissionDescriptor =
1993 mgr.request(perm, format!("Test {perm:?} access"), platform);
1994 let _: bool = perm_statuses.update(|vec: &mut Vec<PermissionStatus>| {
1995 if let Some(slot) = vec.get_mut(idx) {
1996 *slot = desc.get_status();
1997 }
1998 });
1999 let _: bool = native_feedback.set(format!(
2000 "Requested {perm:?} ({}) -> {:?}",
2001 perm.native_key(platform),
2002 desc.get_status()
2003 ));
2004 }
2005 }
2006 EuvButton {
2007 label: "Deny".to_string()
2008 tokens: tokens
2009 destructive()
2010 sm()
2011 on_click: move |_: &UiEvent| {
2012 let _: bool = perm_statuses.update(|vec: &mut Vec<PermissionStatus>| {
2013 if let Some(slot) = vec.get_mut(idx) {
2014 *slot = PermissionStatus::Denied;
2015 }
2016 });
2017 let _: bool = native_feedback.set(format!("Marked {perm:?} as Denied"));
2018 }
2019 }
2020 }
2021 }
2022 }
2023 })
2024 .collect()
2025 }
2026 }
2027 }
2028 }
2029 };
2030 ctx_win.get_scene().with_write(
2031 |tree: &mut SceneTree| {
2032 tree.attach_scope(body_id, fs_scope);
2033 tree.attach_scope(fps_card_id, fps_scope);
2034 },
2035 (),
2036 );
2037 page
2038}
2039
2040pub fn mount_lab_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2051 let p: ThemePalette = tokens.get_palette();
2052 let g: ThemeGeometry = tokens.get_geometry();
2053 let ctx: Context = current_context();
2054 let chart_data: Vec<EuvChartPoint> = vec![
2055 EuvChartPoint::new("Mon".to_string(), 60.0),
2056 EuvChartPoint::new("Tue".to_string(), 88.0),
2057 EuvChartPoint::new("Wed".to_string(), 118.0),
2058 EuvChartPoint::new("Thu".to_string(), 104.0),
2059 EuvChartPoint::new("Fri".to_string(), 120.0),
2060 EuvChartPoint::new("Sat".to_string(), 116.0),
2061 ];
2062 let left_split: NodeId = view! {
2063 text {
2064 font_size: 13.0
2065 color: p.get_foreground()
2066 "Left Split Pane (Drag handle ->)"
2067 }
2068 };
2069 let right_split: NodeId = view! {
2070 text {
2071 font_size: 13.0
2072 color: p.get_muted_foreground()
2073 "Right Split Pane (Zero rebuild on drag)"
2074 }
2075 };
2076 let rtl_sig: Signal<bool> = state.get_lab_rtl_mode();
2077 let block_scroll: Signal<bool> = state.get_lab_block_scroll_chain();
2078 let stop_bubble: Signal<bool> = state.get_lab_stop_click_bubble();
2079 let parent_clicks: Signal<u32> = state.get_lab_parent_clicks();
2080 let child_clicks: Signal<u32> = state.get_lab_child_clicks();
2081 let preserve_cnt: Signal<u32> = state.get_lab_resize_preserve_count();
2082 let modal_open: Signal<bool> = state.get_modal_open();
2083 let drawer_open: Signal<bool> = state.get_drawer_open();
2084 let attach_vis: Signal<bool> = Signal::new(true);
2085 let q_sel: Signal<Option<usize>> = Signal::new(Some(0));
2086 let touches_sig: Signal<Vec<(u64, Point)>> = ctx.get_active_touches();
2087 let pad_bounds_cell: Rc<Cell<Rect>> = Rc::new(Cell::new(Rect::default()));
2088 let pad_bounds_memo: Rc<Cell<Rect>> = Rc::clone(&pad_bounds_cell);
2089 let pad_bounds_paint: Rc<Cell<Rect>> = Rc::clone(&pad_bounds_cell);
2090 let touch_ids_memo: Memo<Vec<u64>> = Memo::new(move || {
2091 let pad_rect: Rect = pad_bounds_memo.get();
2092 if pad_rect.get_width() <= 0.0 || pad_rect.get_height() <= 0.0 {
2093 return Vec::new();
2094 }
2095 touches_sig
2096 .get()
2097 .into_iter()
2098 .filter(|(_, pt): &(u64, Point)| pad_rect.contains(*pt))
2099 .map(|(id, _): (u64, Point)| id)
2100 .collect()
2101 });
2102 let ai_tick: Signal<u32> = Signal::new(0);
2103 let ai_fps_sig: Signal<f32> = ctx.get_live_fps();
2104 let ai_hz_sig: Signal<f32> = ctx.get_display_refresh_rate();
2105 let ai_route_sig: Signal<String> = state.get_route();
2106 let ai_scheme_sig: Signal<DesignScheme> = state.get_theme().get_scheme();
2107 let mut touch_pad_id: NodeId = NodeId::default();
2108 let page: NodeId = view! {
2109 EuvPage {
2110 title: "UI & Edge-Case Lab".to_string()
2111 subtitle: "Full shadcn/ui component parity + multi-touch, propagation, overlay stack, AI Schema v1, and resize-preservation tests".to_string()
2112 tokens: tokens
2113 EuvCard {
2114 title: "Multi-Touch & Gesture Isolation Pad".to_string()
2115 tokens: tokens
2116 subtitle: "Simultaneous multi-finger tracking with pointer IDs, pinch distance line, and gesture non-penetration"
2117 row {
2118 width: Length::Percent(100.0)
2119 height: Length::Px(22.0)
2120 align: AlignItems::Center
2121 overflow: Overflow::Hidden
2122 text {
2123 width: Length::Percent(100.0)
2124 font_size: 12.5
2125 font_weight: FontWeight::Medium
2126 color: p.get_primary()
2127 overflow: Overflow::Hidden
2128 text_overflow: TextOverflow::Ellipsis
2129 { move || {
2130 let ids: Vec<u64> = touch_ids_memo.get();
2131 if ids.is_empty() {
2132 TOUCH_PAD_READY_TEXT.to_string()
2133 } else {
2134 let labels: String = ids
2135 .iter()
2136 .map(|id: &u64| format!("#{id}"))
2137 .collect::<Vec<String>>()
2138 .join(" ");
2139 format!("Inside Pad: {} | Pointers: {labels}", ids.len())
2140 }
2141 } }
2142 }
2143 }
2144 canvas {
2145 node_ref: touch_pad_id
2146 width: Length::Percent(100.0)
2147 height: Length::Px(170.0)
2148 background: p.get_muted()
2149 border: (g.get_border_width(), p.get_border())
2150 radius: g.get_radius_md()
2151 stop_scroll_propagation: true
2152 stop_event_propagation: true
2153 painter: move |bounds: Rect, dl: &mut DisplayList| {
2154 pad_bounds_paint.set(bounds);
2155 let pts: Vec<(u64, Point)> = touches_sig.get_untracked();
2156 let palette: [Color; 5] = [
2157 Color::hex(0x2563EB),
2158 Color::hex(0x16A34A),
2159 Color::hex(0xEA580C),
2160 Color::hex(0x9333EA),
2161 Color::hex(0xDC2626),
2162 ];
2163 let inside_pts: Vec<(u64, Point)> = pts
2164 .into_iter()
2165 .filter(|(_, pt): &(u64, Point)| bounds.contains(*pt))
2166 .collect();
2167 if inside_pts.is_empty() {
2168 let mut hint_style: TextStyle = TextStyle::default();
2169 hint_style
2170 .set_font_size(12.0)
2171 .set_color(p.get_muted_foreground())
2172 .set_align(TextAlign::Center);
2173 dl.push(DrawCommand::TextRun {
2174 rect: Rect::new(
2175 bounds.get_x() + 12.0,
2176 bounds.get_y() + (bounds.get_height() - 18.0) * 0.5,
2177 (bounds.get_width() - 24.0).max(1.0),
2178 20.0,
2179 ),
2180 text: TOUCH_PAD_CANVAS_HINT.to_string(),
2181 style: hint_style,
2182 });
2183 return;
2184 }
2185 if inside_pts.len() >= 2 {
2186 for pair in inside_pts.windows(2) {
2187 dl.push(DrawCommand::Line {
2188 from: pair[0].1,
2189 to: pair[1].1,
2190 color: p.get_primary().multiply_alpha(0.75),
2191 width: 2.0,
2192 });
2193 }
2194 }
2195 for (idx, (pid, pt)) in inside_pts.iter().enumerate() {
2196 let col: Color = palette[idx % palette.len()];
2197 dl.push(DrawCommand::Circle {
2198 center: *pt,
2199 radius: 26.0,
2200 color: col.multiply_alpha(0.24),
2201 });
2202 dl.push(DrawCommand::Circle {
2203 center: *pt,
2204 radius: 10.0,
2205 color: col,
2206 });
2207 let mut tag_style: TextStyle = TextStyle::default();
2208 tag_style
2209 .set_font_size(11.0)
2210 .set_weight(FontWeight::Bold)
2211 .set_color(col);
2212 dl.push(DrawCommand::TextRun {
2213 rect: Rect::new(pt.get_x() + 14.0, pt.get_y() - 24.0, 96.0, 16.0),
2214 text: format!("#{pid}({:.0},{:.0})", pt.get_x(), pt.get_y()),
2215 style: tag_style,
2216 });
2217 }
2218 let mut hud_style: TextStyle = TextStyle::default();
2219 hud_style
2220 .set_font_size(11.5)
2221 .set_weight(FontWeight::Medium)
2222 .set_color(p.get_foreground());
2223 dl.push(DrawCommand::TextRun {
2224 rect: Rect::new(
2225 bounds.get_x() + 10.0,
2226 bounds.get_y() + 8.0,
2227 (bounds.get_width() - 20.0).max(1.0),
2228 18.0,
2229 ),
2230 text: format!("Live Contacts Inside Pad: {}", inside_pts.len()),
2231 style: hud_style,
2232 });
2233 }
2234 }
2235 }
2236 EuvCard {
2237 title: "AI Schema v1 & Reactive Telemetry Bridge".to_string()
2238 tokens: tokens
2239 subtitle: "Live introspection of SceneTree bounds, A11y tree, reactive graph, FPS, and interactive agent actions"
2240 text {
2241 width: Length::Percent(100.0)
2242 font_size: 12.5
2243 color: p.get_foreground()
2244 { move || {
2245 let _: u32 = ai_tick.get();
2246 let rs: ReactiveStats = reactive_stats();
2247 #[cfg(debug_assertions)]
2248 let proto_label: &str = AI_SCHEMA_PROTOCOL_VERSION;
2249 #[cfg(not(debug_assertions))]
2250 let proto_label: &str = AI_SCHEMA_RELEASE_STRIPPED;
2251 let bridge_label: &str = if DevAutomationBridge::is_enabled() {
2252 AI_BRIDGE_STATUS_ACTIVE
2253 } else {
2254 AI_BRIDGE_STATUS_OFF
2255 };
2256 let ai_fps: f32 = ai_fps_sig.get();
2257 let ai_hz: f32 = ai_hz_sig.get().clamp(30.0, 480.0);
2258 let fps_display: String = if !ai_fps.is_finite() || ai_fps <= 0.05 {
2259 LABEL_FPS_IDLE.to_string()
2260 } else {
2261 format!("{ai_fps:.1}")
2262 };
2263 format!(
2264 "Protocol: {} ({}) | Route: {} | Scheme: {} | Display: {:.0}Hz | Live FPS: {} | Signals: {} | Memos: {} | Effects: {} | Scopes: {} | Clock: {}",
2265 proto_label,
2266 bridge_label,
2267 ai_route_sig.get(),
2268 ai_scheme_sig.get().as_str(),
2269 ai_hz,
2270 fps_display,
2271 rs.get_live_signals(),
2272 rs.get_live_memos(),
2273 rs.get_live_effects(),
2274 rs.get_live_scopes(),
2275 rs.get_clock()
2276 )
2277 } }
2278 }
2279 EuvActionRow {
2280 EuvButton {
2281 label: "Refresh AI Telemetry".to_string()
2282 tokens: tokens
2283 outline()
2284 sm()
2285 on_click: move |_: &UiEvent| {
2286 let _: bool = ai_tick.update(|v: &mut u32| *v = v.wrapping_add(1));
2287 }
2288 }
2289 }
2290 EuvCodeBlock {
2291 code: "GET /ai/schema | /ai/snapshot | /ai/a11y | /ai/health\nPOST /ai/query | /ai/action | /ai/script (dev-only; 0B in release)".to_string()
2292 tokens: tokens
2293 }
2294 }
2295 EuvCard {
2296 title: "Complete shadcn/ui Component Parity".to_string()
2297 tokens: tokens
2298 subtitle: "Trace, Attachment, Bubble, Marker, Questionnaire, Chart, Combobox, DataTable, DatePicker, InputGroup, Item, NativeSelect, NavigationMenu, Resizable, Separator, Direction, Avatar, Kbd, Spinner, Skeleton, Breadcrumb, Empty"
2299 row {
2300 style: c_action_row()
2301 EuvMarker {
2302 code: "01".to_string()
2303 label: "Zero WebView".to_string()
2304 tone: EuvTone::Primary
2305 tokens: tokens
2306 }
2307 EuvMarker {
2308 code: "02".to_string()
2309 label: "120+ FPS".to_string()
2310 tone: EuvTone::Success
2311 tokens: tokens
2312 }
2313 EuvMarker {
2314 code: "03".to_string()
2315 label: "Multi-Touch".to_string()
2316 tone: EuvTone::Warning
2317 tokens: tokens
2318 }
2319 EuvAvatar {
2320 initials: "EU".to_string()
2321 size: 32.0
2322 tokens: tokens
2323 }
2324 EuvKbd {
2325 key: "Cmd+K".to_string()
2326 tokens: tokens
2327 }
2328 EuvSpinner {
2329 size: 18.0
2330 tokens: tokens
2331 }
2332 }
2333 EuvTrace {
2334 title: "Frame Pipeline Trace (1.42ms Total)".to_string()
2335 spans: vec![
2336 EuvTraceSpan::new("layout.compute".to_string(), 0.14, 0.0, 0.12, EuvTone::Primary),
2337 EuvTraceSpan::new("bvh.raytrace_gi".to_string(), 0.88, 0.12, 0.60, EuvTone::Success),
2338 EuvTraceSpan::new("fxaa.tonemap".to_string(), 0.24, 0.72, 0.16, EuvTone::Warning),
2339 EuvTraceSpan::new("present.blit".to_string(), 0.16, 0.88, 0.12, EuvTone::Neutral),
2340 ]
2341 tokens: tokens
2342 }
2343 EuvAttachment {
2344 filename: "vice-boulevard-rt.wasm".to_string()
2345 meta: "48.2 KB · application/wasm · SHA-verified".to_string()
2346 visible: attach_vis
2347 tokens: tokens
2348 }
2349 EuvBubble {
2350 author: "Euv Runtime".to_string()
2351 content: "All 60+ shadcn/ui components rendered directly via Rust SceneTree with zero WebView.".to_string()
2352 tokens: tokens
2353 timestamp: "09:41"
2354 }
2355 EuvBubble {
2356 author: "Developer".to_string()
2357 content: "Verify multi-touch, text wrapping, blinking input caret & uncapped FPS live!".to_string()
2358 tokens: tokens
2359 timestamp: "09:42"
2360 outgoing: true
2361 }
2362 EuvQuestionnaire {
2363 prompt: "Preferred native target deployment pipeline?".to_string()
2364 options: vec![
2365 "Universal Native (Android + iOS + Desktop + Web)".to_string(),
2366 "Dynamic OTA .wasm Hot-Swap Modules".to_string(),
2367 "Embedded 3D Ray-Traced Engine Viewport".to_string(),
2368 ]
2369 selected: q_sel
2370 tokens: tokens
2371 }
2372 EuvNavigationMenu {
2373 items: vec![
2374 (
2375 "Architecture".to_string(),
2376 "Arena signals + deterministic Flexbox/Grid + retained scene graph.".to_string(),
2377 ),
2378 (
2379 "3D Engine".to_string(),
2380 "PBR metallic-roughness + BVH ray-traced shadows/reflections + FXAA.".to_string(),
2381 ),
2382 (
2383 "Media Suite".to_string(),
2384 "Pure-Rust Image, SVG, GIF, LIVE Photo, Video, WAV Audio, PDF, HTML.".to_string(),
2385 ),
2386 ]
2387 active: state.get_lab_nav_menu_active()
2388 tokens: tokens
2389 }
2390 EuvChart {
2391 title: "Frame Rate Telemetry (Bar)".to_string()
2392 kind: EuvChartKind::Bar
2393 data: chart_data.clone()
2394 tokens: tokens
2395 }
2396 EuvChart {
2397 title: "3D Ray-Tracing Throughput (Area)".to_string()
2398 kind: EuvChartKind::Area
2399 data: chart_data
2400 tokens: tokens
2401 }
2402 EuvCombobox {
2403 options: vec![
2404 "euv Native Rust".to_string(),
2405 "WebAssembly Zero-JS".to_string(),
2406 "Android ARM64 JNI".to_string(),
2407 "iOS CoreText Metal".to_string(),
2408 "macOS AppKit Retina".to_string(),
2409 ]
2410 selected: state.get_lab_combobox_selected()
2411 open: state.get_lab_combobox_open()
2412 tokens: tokens
2413 query: state.get_lab_combobox_query()
2414 placeholder: "Filter frameworks..."
2415 }
2416 EuvDatePicker {
2417 month_label: LABEL_CALENDAR_MONTH.to_string()
2418 selected_day: state.get_lab_date_day()
2419 open: state.get_lab_date_open()
2420 tokens: tokens
2421 }
2422 EuvInputGroup {
2423 value: state.get_lab_input_group_val()
2424 tokens: tokens
2425 prefix: "https://"
2426 placeholder: "subdomain"
2427 suffix: ".euv.dev"
2428 }
2429 EuvNativeSelect {
2430 options: vec![
2431 "60 Hz Standard".to_string(),
2432 "120 Hz ProMotion".to_string(),
2433 "Unlocked Benchmark".to_string(),
2434 ]
2435 selected: state.get_lab_native_select_idx()
2436 tokens: tokens
2437 }
2438 EuvDataTable {
2439 headers: vec!["Target".to_string(), "Font Engine".to_string(), "Status".to_string()]
2440 rows: vec![
2441 vec![LABEL_PLATFORM_ANDROID.to_string(), "Skia Paint AA".to_string(), "1:1 DPI".to_string()],
2442 vec!["iOS / iPadOS".to_string(), "CoreText @3x".to_string(), "ProMotion".to_string()],
2443 vec![LABEL_PLATFORM_MACOS.to_string(), "CoreText Retina".to_string(), "Live Resize".to_string()],
2444 vec!["WebAssembly".to_string(), "Canvas2D AA".to_string(), "Zero-JS".to_string()],
2445 ]
2446 tokens: tokens
2447 filter: state.get_lab_table_filter()
2448 sort_ascending: state.get_lab_table_sort_asc()
2449 selected_row: state.get_lab_table_selected()
2450 }
2451 EuvResizable {
2452 left: left_split
2453 right: right_split
2454 split_ratio: state.get_lab_split_ratio()
2455 tokens: tokens
2456 }
2457 EuvItem {
2458 title: "Production shadcn/ui Alignment".to_string()
2459 tokens: tokens
2460 leading: "EU"
2461 description: "Unified layout grammar across all 17 design schemes with per-theme surface/radius tokens"
2462 trailing: LAB_ITEM_VER
2463 }
2464 column {
2465 width: Length::Percent(100.0)
2466 gap: SPACE_SM
2467 EuvBreadcrumb {
2468 segments: vec!["Euv Studio".to_string(), "Design System".to_string(), "Components".to_string()]
2469 tokens: tokens
2470 active: state.get_breadcrumb_active()
2471 }
2472 EuvTypography {
2473 text: "Unified shadcn/ui Typography & Surface Tokens".to_string()
2474 variant: EuvTypographyVariant::H3
2475 tokens: tokens
2476 }
2477 EuvSkeleton {
2478 width: 260.0
2479 height: 18.0
2480 tokens: tokens
2481 }
2482 EuvEmpty {
2483 title: "No Pending Warnings".to_string()
2484 description: "All layout, scroll, shadow and typography checks passed.".to_string()
2485 tokens: tokens
2486 }
2487 }
2488 }
2489 EuvCard {
2490 title: "Boundary & Event Penetration Regression Lab".to_string()
2491 tokens: tokens
2492 subtitle: "Verify scroll lock, flexible event bubbling, overlay back stack, RTL alignment, and zero-rebuild resize preservation"
2493 EuvSeparator {
2494 label: "EDGE-CASE REGRESSION SUITE".to_string()
2495 tokens: tokens
2496 }
2497 column {
2498 width: Length::Percent(100.0)
2499 bind_children: move || {
2500 let dir: EuvTextDirection = if rtl_sig.get() {
2501 EuvTextDirection::Rtl
2502 } else {
2503 EuvTextDirection::Ltr
2504 };
2505 vec![view! {
2506 EuvDirection {
2507 direction: dir
2508 child: view! {
2509 text {
2510 font_size: 13.0
2511 color: p.get_foreground()
2512 { format!("Direction preview ({dir:?}): Unified layout alignment across LTR & RTL") }
2513 }
2514 }
2515 tokens: tokens
2516 }
2517 }]
2518 }
2519 }
2520 column {
2521 width: Length::Percent(100.0)
2522 gap: SPACE_XS
2523 EuvSwitch {
2524 checked: block_scroll
2525 label: "Lock Scroll Penetration".to_string()
2526 tokens: tokens
2527 }
2528 EuvSwitch {
2529 checked: stop_bubble
2530 label: "Stop Click Bubbling".to_string()
2531 tokens: tokens
2532 }
2533 EuvSwitch {
2534 checked: rtl_sig
2535 label: "RTL Direction".to_string()
2536 tokens: tokens
2537 }
2538 }
2539 EuvActionRow {
2540 EuvButton {
2541 label: "Increment Preserved Counter".to_string()
2542 tokens: tokens
2543 sm()
2544 on_click: move |_: &UiEvent| {
2545 let _: bool = preserve_cnt.update(|v: &mut u32| *v += 1);
2546 }
2547 }
2548 EuvButton {
2549 label: "Open Stacked Modal + Drawer".to_string()
2550 tokens: tokens
2551 secondary()
2552 sm()
2553 on_click: move |_: &UiEvent| {
2554 let _: bool = modal_open.set_if_changed(true);
2555 let _: bool = drawer_open.set_if_changed(true);
2556 }
2557 }
2558 EuvButton {
2559 label: "Dismiss Top Overlay (Back)".to_string()
2560 tokens: tokens
2561 outline()
2562 sm()
2563 on_click: move |_: &UiEvent| {
2564 let _: bool = EuvOverlayStack::dismiss_top();
2565 }
2566 }
2567 }
2568 text {
2569 font_size: 12.0
2570 color: p.get_muted_foreground()
2571 { move || format!(
2572 "Inner Clicks: {} | Outer Parent Clicks: {} | Resize-Preserved Counter: {} | Overlay Stack Depth: {}",
2573 child_clicks.get(),
2574 parent_clicks.get(),
2575 preserve_cnt.get(),
2576 EuvOverlayStack::active_count()
2577 ) }
2578 }
2579 column {
2580 width: Length::Percent(100.0)
2581 bind_children: move || {
2582 let locked: bool = block_scroll.get();
2583 let stop_clk: bool = stop_bubble.get();
2584 vec![view! {
2585 column {
2586 width: Length::Percent(100.0)
2587 padding: Edges::all(SPACE_MD)
2588 gap: SPACE_SM
2589 background: p.get_muted()
2590 border: (g.get_border_width(), p.get_border())
2591 radius: g.get_radius_md()
2592 on_click: move |_: &UiEvent| {
2593 let _: bool = parent_clicks.update(|v: &mut u32| *v += 1);
2594 }
2595 scroll {
2596 width: Length::Percent(100.0)
2597 height: Length::Px(110.0)
2598 padding: Edges::all(SPACE_SM)
2599 gap: SPACE_XS
2600 background: p.get_card()
2601 border: (g.get_border_width(), p.get_border())
2602 radius: g.get_radius_sm()
2603 stop_scroll_propagation: locked
2604 stop_event_propagation: stop_clk
2605 for row_i in 1..=8 {
2606 text {
2607 font_size: 12.0
2608 color: p.get_foreground()
2609 { format!("Nested Scroll Row #{row_i} (scroll_lock={locked}, stop_bubble={stop_clk})") }
2610 }
2611 }
2612 }
2613 EuvActionRow {
2614 EuvButton {
2615 label: "Click Inner Target".to_string()
2616 tokens: tokens
2617 secondary()
2618 sm()
2619 on_click: move |_: &UiEvent| {
2620 let _: bool = child_clicks.update(|v: &mut u32| *v += 1);
2621 }
2622 }
2623 }
2624 }
2625 }]
2626 }
2627 }
2628 }
2629 }
2630 };
2631 let touch_handle: SceneHandle = ctx.get_scene().clone();
2632 let (touch_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
2633 Effect::new(move || {
2634 let _: Vec<(u64, Point)> = touches_sig.get();
2635 touch_handle.mark_dirty(touch_pad_id, DIRTY_PAINT);
2636 })
2637 });
2638 ctx.get_scene().with_write(
2639 |tree: &mut SceneTree| {
2640 tree.attach_scope(touch_pad_id, touch_scope);
2641 },
2642 (),
2643 );
2644 page
2645}
2646
2647pub fn mount_forms_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2658 let p: ThemePalette = tokens.get_palette();
2659 let username: Signal<String> = state.get_username();
2660 let stepper: Signal<i64> = state.get_stepper_value();
2661 let rating: Signal<usize> = state.get_rating_value();
2662 let cal_day: Signal<u32> = state.get_calendar_day();
2663 let picker_color: Signal<Color> = state.get_picker_color();
2664 let picker_time: Signal<(u8, u8)> = state.get_picker_time();
2665 let tag_items: Signal<Vec<String>> = state.get_tag_items();
2666 let input_node: NodeId = view! {
2667 EuvInput {
2668 value: username
2669 placeholder: PLACEHOLDER_USERNAME.to_string()
2670 tokens: tokens
2671 }
2672 };
2673 let collapsible_body: NodeId = view! {
2674 text {
2675 font_size: 13.0
2676 color: p.get_muted_foreground()
2677 "shadcn/ui Collapsible disclosure panel adapts across Mobile, Tablet, and Desktop."
2678 }
2679 };
2680 view! {
2681 EuvPage {
2682 title: FORMS_TITLE.to_string()
2683 subtitle: FORMS_SUBTITLE.to_string()
2684 tokens: tokens
2685 EuvCard {
2686 title: FORMS_CARD_TITLE.to_string()
2687 tokens: tokens
2688 subtitle: FORMS_CARD_SUB
2689 column {
2690 gap: SPACE_MD
2691 EuvTabs {
2692 labels: vec![TAB_GENERAL.to_string(), TAB_GRAPHICS.to_string(), TAB_SECURITY.to_string()]
2693 active: state.get_active_tab()
2694 tokens: tokens
2695 }
2696 EuvField {
2697 label: FIELD_USERNAME.to_string()
2698 control: input_node
2699 tokens: tokens
2700 }
2701 EuvTextarea {
2702 value: state.get_bio()
2703 placeholder: "Write notes...".to_string()
2704 height: 54.0
2705 tokens: tokens
2706 }
2707 row {
2708 style: c_action_row()
2709 EuvNumberInput {
2710 value: stepper
2711 tokens: tokens
2712 range(0, 20)
2713 step: 1
2714 }
2715 EuvToggle {
2716 pressed: state.get_pin_toggled()
2717 label: "Pin Config".to_string()
2718 tokens: tokens
2719 }
2720 EuvRating {
2721 value: rating
2722 max_stars: 5
2723 tokens: tokens
2724 }
2725 }
2726 EuvRadioGroup {
2727 options: vec!["Software CPU".to_string(), "Hardware GPU".to_string(), "Hybrid".to_string()]
2728 selected: state.get_radio_index()
2729 tokens: tokens
2730 }
2731 EuvSlider {
2732 value: state.get_slider_value()
2733 min: 0.0
2734 max: 100.0
2735 tokens: tokens
2736 }
2737 EuvSelect {
2738 options: vec!["Metal".to_string(), "Vulkan".to_string(), "Direct3D 12".to_string(), "WebGPU".to_string()]
2739 selected: state.get_select_index()
2740 open: state.get_select_open()
2741 tokens: tokens
2742 }
2743 EuvSwitch {
2744 checked: state.get_hardware_accel()
2745 label: SWITCH_HW_LABEL.to_string()
2746 tokens: tokens
2747 }
2748 EuvCheckbox {
2749 checked: state.get_agree_terms()
2750 label: CHECKBOX_TERMS_LABEL.to_string()
2751 tokens: tokens
2752 }
2753 text {
2754 font_size: 12.0
2755 color: p.get_muted_foreground()
2756 { move || format!("Handle: {} | Stepper: {} | Stars: {}/5 | Day: {}", username.get(), stepper.get(), rating.get(), cal_day.get()) }
2757 }
2758 EuvActionRow {
2759 EuvButton {
2760 label: BTN_PRIMARY_LABEL.to_string()
2761 tokens: tokens
2762 }
2763 EuvButton {
2764 label: BTN_SECONDARY_LABEL.to_string()
2765 tokens: tokens
2766 secondary() }
2767 EuvButton {
2768 label: BTN_OUTLINE_LABEL.to_string()
2769 tokens: tokens
2770 outline() }
2771 EuvButton {
2772 label: BTN_DESTRUCTIVE_LABEL.to_string()
2773 tokens: tokens
2774 destructive()
2775 on_click: move |_: &UiEvent| {
2776 let _: bool = username.set_if_changed(DEFAULT_USERNAME.to_string());
2777 }
2778 }
2779 }
2780 }
2781 }
2782 EuvCard {
2783 title: "shadcn/ui Extended Form Controls".to_string()
2784 tokens: tokens
2785 subtitle: FORMS_EXT_CARD_SUB
2786 column {
2787 gap: SPACE_MD
2788 EuvToggleGroup {
2789 options: vec!["Bold".to_string(), "Italic".to_string(), "Underline".to_string()]
2790 selected: state.get_toggle_group_index()
2791 tokens: tokens
2792 }
2793 EuvInputOtp {
2794 value: state.get_otp_code()
2795 length: 6
2796 tokens: tokens
2797 }
2798 EuvColorPicker {
2799 value: picker_color
2800 tokens: tokens
2801 }
2802 EuvTimePicker {
2803 value: picker_time
2804 tokens: tokens
2805 }
2806 EuvTagInput {
2807 tags: tag_items
2808 tokens: tokens
2809 placeholder: TAG_INPUT_PLACEHOLDER
2810 }
2811 text {
2812 font_size: 12.0
2813 color: p.get_muted_foreground()
2814 { move || {
2815 let c: Color = picker_color.get();
2816 let (hh, mm): (u8, u8) = picker_time.get();
2817 format!(
2818 "Color: #{:02X}{:02X}{:02X} | Time: {:02}:{:02} | Tags: {}",
2819 c.get_r(),
2820 c.get_g(),
2821 c.get_b(),
2822 hh,
2823 mm,
2824 tag_items.get().len()
2825 )
2826 } }
2827 }
2828 EuvCalendar {
2829 month_label: LABEL_CALENDAR_MONTH.to_string()
2830 days_in_month: 30
2831 selected_day: state.get_calendar_day()
2832 tokens: tokens
2833 }
2834 EuvCollapsible {
2835 open: state.get_collapsible_open()
2836 title: "Advanced Form Details".to_string()
2837 content: collapsible_body
2838 tokens: tokens
2839 }
2840 }
2841 }
2842 }
2843 }
2844}
2845
2846pub fn mount_themes_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2857 let p: ThemePalette = tokens.get_palette();
2858 let scheme_sig: Signal<DesignScheme> = state.get_theme().get_scheme();
2859 let mode_sig: Signal<ThemeMode> = state.get_theme().get_mode();
2860 let state_for_cycle: ShowcaseState = state.clone();
2861 let state_for_mode: ShowcaseState = state.clone();
2862 let scheme_cols: u16 = match use_breakpoint().get_untracked() {
2863 Breakpoint::Compact => 2,
2864 Breakpoint::Medium => 3,
2865 Breakpoint::Expanded => 4,
2866 };
2867 let all_schemes: [DesignScheme; 17] = DesignScheme::all();
2868 let cur_mode: ThemeMode = mode_sig.get_untracked();
2869 view! {
2870 EuvPage {
2871 title: THEMES_TITLE.to_string()
2872 subtitle: THEMES_SUBTITLE.to_string()
2873 tokens: tokens
2874 EuvCard {
2875 title: THEMES_CARD_TITLE.to_string()
2876 tokens: tokens
2877 subtitle: THEMES_CARD_SUB
2878 column {
2879 gap: SPACE_MD
2880 text {
2881 font_size: 15.0
2882 font_weight: FontWeight::SemiBold
2883 color: p.get_foreground()
2884 { move || format!("{PREFIX_ACTIVE_SCHEME}{} ({:?})", scheme_sig.get().as_str(), mode_sig.get()) }
2885 }
2886 EuvActionRow {
2887 EuvButton {
2888 label: BTN_NEXT_SCHEME.to_string()
2889 tokens: tokens
2890 on_click: move |_: &UiEvent| {
2891 state_for_cycle.next_scheme();
2892 }
2893 }
2894 EuvButton {
2895 label: BTN_TOGGLE_MODE.to_string()
2896 tokens: tokens
2897 outline()
2898 on_click: move |_: &UiEvent| {
2899 state_for_mode.toggle_theme_mode();
2900 }
2901 }
2902 }
2903 grid {
2904 style: c_scheme_grid()
2905 columns: scheme_cols
2906 for scheme in all_schemes.iter().copied() {
2907 EuvButton {
2908 label: scheme.as_str().to_string()
2909 tokens: ThemeTokens::resolve(scheme, cur_mode)
2910 sm()
2911 on_click: move |_: &UiEvent| {
2912 let _: bool = scheme_sig.set_if_changed(scheme);
2913 }
2914 }
2915 }
2916 }
2917 }
2918 }
2919 }
2920 }
2921}
2922
2923pub fn mount_data_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
2934 let p: ThemePalette = tokens.get_palette();
2935 let g: ThemeGeometry = tokens.get_geometry();
2936 let scroll_y: Signal<f32> = state.get_list_scroll_y();
2937 let vlist: EuvVirtualList =
2938 EuvVirtualList::new(10_000, 32.0, scroll_y, tokens).viewport_height(224.0);
2939 let vlist_down: EuvVirtualList = vlist.clone();
2940 let list_node: NodeId = vlist.mount_with(move |idx: usize| {
2941 view! {
2942 row {
2943 width: Length::Percent(100.0)
2944 height: Length::Px(32.0)
2945 padding: Edges::symmetric(SPACE_XS, SPACE_MD)
2946 align: AlignItems::Center
2947 border: (g.get_border_width(), p.get_border())
2948 text {
2949 font_size: 13.0
2950 color: p.get_foreground()
2951 { format!("{ROW_PREFIX}{idx}") }
2952 }
2953 }
2954 }
2955 });
2956 let aspect_inner: NodeId = view! {
2957 column {
2958 align: AlignItems::Center
2959 gap: SPACE_XS
2960 text {
2961 font_size: 14.0
2962 font_weight: FontWeight::SemiBold
2963 color: p.get_foreground()
2964 "16:9 shadcn AspectRatio"
2965 }
2966 text {
2967 font_size: 12.0
2968 color: p.get_muted_foreground()
2969 "Responsive container locked to 16:9 ratio"
2970 }
2971 }
2972 };
2973 let tree_sel: Signal<Option<String>> = state.get_tree_selected();
2974 view! {
2975 EuvPage {
2976 title: DATA_TITLE.to_string()
2977 subtitle: DATA_SUBTITLE.to_string()
2978 tokens: tokens
2979 EuvCard {
2980 title: DATA_CARD_TITLE.to_string()
2981 tokens: tokens
2982 subtitle: DATA_CARD_SUB
2983 column {
2984 gap: SPACE_MD
2985 EuvMenubar {
2986 menus: vec!["File".to_string(), "Edit".to_string(), "View".to_string(), "Profiles".to_string()]
2987 active_menu: state.get_menubar_active()
2988 tokens: tokens
2989 }
2990 row {
2991 style: c_action_row()
2992 EuvBadge {
2993 label: BADGE_READY.to_string()
2994 tone: EuvTone::Success
2995 tokens: tokens
2996 }
2997 EuvBadge {
2998 label: BADGE_LIVE.to_string()
2999 tone: EuvTone::Primary
3000 tokens: tokens
3001 }
3002 }
3003 EuvActionRow {
3004 EuvButton {
3005 label: BTN_SCROLL_DOWN.to_string()
3006 tokens: tokens
3007 on_click: move |_: &UiEvent| {
3008 vlist_down.scroll_by(160.0);
3009 }
3010 }
3011 EuvButton {
3012 label: BTN_SCROLL_TOP.to_string()
3013 tokens: tokens
3014 outline()
3015 on_click: move |_: &UiEvent| {
3016 let _: bool = scroll_y.set_if_changed(0.0);
3017 }
3018 }
3019 }
3020 text {
3021 font_size: 12.0
3022 color: p.get_muted_foreground()
3023 { move || format!("scroll_y={:.0}px | top_row=#{}", scroll_y.get(), (scroll_y.get() / 32.0).floor() as usize) }
3024 }
3025 EuvProgress {
3026 value: 0.84
3027 tokens: tokens
3028 }
3029 { list_node }
3030 EuvCommand {
3031 items: vec!["Switch to Dark Mode".to_string(), "Open OTA Updates".to_string(), "Run Physics Tick".to_string()]
3032 selected: state.get_command_selected()
3033 tokens: tokens
3034 query: state.get_command_query()
3035 placeholder: "Search commands..."
3036 }
3037 EuvCarousel {
3038 slides: vec![
3039 "Slide 1: Native Metal & Vulkan".to_string(),
3040 "Slide 2: Complete shadcn/ui Parity".to_string(),
3041 "Slide 3: Instant Responsive Resize".to_string(),
3042 ]
3043 active_slide: state.get_carousel_index()
3044 tokens: tokens
3045 }
3046 column {
3047 width: Length::Percent(100.0)
3048 max_width: Length::Px(360.0)
3049 EuvAspectRatio {
3050 ratio: 16.0 / 9.0
3051 child: aspect_inner
3052 tokens: tokens
3053 }
3054 }
3055 EuvPagination {
3056 current: state.get_page_index()
3057 total_pages: 12
3058 tokens: tokens
3059 }
3060 EuvSteps {
3061 labels: vec!["Layout".to_string(), "Paint".to_string(), "Present".to_string()]
3062 active: state.get_step_index()
3063 tokens: tokens
3064 }
3065 EuvTree {
3066 roots: vec![EuvTreeNode::new(
3067 TREE_NODE_WORKSPACE.to_string(),
3068 vec![
3069 EuvTreeNode::new(
3070 TREE_NODE_CORE.to_string(),
3071 vec![
3072 EuvTreeNode::new(TREE_NODE_RENDER.to_string(), Vec::new()),
3073 EuvTreeNode::new(TREE_NODE_REACTIVE.to_string(), Vec::new()),
3074 ],
3075 ),
3076 EuvTreeNode::new(TREE_NODE_UI.to_string(), Vec::new()),
3077 EuvTreeNode::new(TREE_NODE_PERF.to_string(), Vec::new()),
3078 ],
3079 )]
3080 tokens: tokens
3081 selected: state.get_tree_selected()
3082 }
3083 text {
3084 font_size: 12.0
3085 color: p.get_muted_foreground()
3086 { move || {
3087 let cur: String = tree_sel
3088 .get()
3089 .unwrap_or_else(|| TREE_NONE_SELECTED.to_string());
3090 format!("{TREE_SELECTED_PREFIX}: {cur}")
3091 } }
3092 }
3093 EuvAccordion {
3094 items: vec![EuvAccordionItem::new(
3095 "Virtualization".to_string(),
3096 "Only visible rows + overscan are materialized in O(visible).".to_string(),
3097 )]
3098 open_index: state.get_accordion_open()
3099 tokens: tokens
3100 }
3101 }
3102 }
3103 }
3104 }
3105}
3106
3107pub fn mount_game_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3118 let g: ThemeGeometry = tokens.get_geometry();
3119 let p: ThemePalette = tokens.get_palette();
3120 let host: GameEngineHost = state.get_game_host().clone();
3121 let host_btn: GameEngineHost = host.clone();
3122 let host_wave: GameEngineHost = host.clone();
3123 let host_left: GameEngineHost = host.clone();
3124 let host_up: GameEngineHost = host.clone();
3125 let host_down: GameEngineHost = host.clone();
3126 let host_right: GameEngineHost = host.clone();
3127 let host_dash: GameEngineHost = host.clone();
3128 let viewport: NodeId = host.mount_viewport(
3129 Style::default()
3130 .width(Length::Percent(100.0))
3131 .height(Length::Px(340.0))
3132 .border(g.get_border_width(), p.get_border())
3133 .radius(g.get_radius_md()),
3134 );
3135 let fs_2d_open: Signal<bool> = Signal::new(false);
3136 let fs_2d_portal: NodeId = mount_game_fullscreen_portal(
3137 fs_2d_open,
3138 &host,
3139 viewport,
3140 None,
3141 "2D Physics Arena",
3142 tokens,
3143 );
3144 view! {
3145 EuvPage {
3146 title: GAME_TITLE.to_string()
3147 subtitle: GAME_SUBTITLE.to_string()
3148 tokens: tokens
3149 EuvCard {
3150 title: GAME_CARD_TITLE.to_string()
3151 tokens: tokens
3152 subtitle: GAME_CARD_SUB
3153 column {
3154 gap: SPACE_MD
3155 EuvActionRow {
3156 EuvButton {
3157 label: BTN_STEP_PHYSICS.to_string()
3158 tokens: tokens
3159 sm()
3160 on_click: move |_: &UiEvent| {
3161 let _: u32 = host_btn.step(0.051);
3162 }
3163 }
3164 EuvButton {
3165 label: "Spawn Enemy Wave".to_string()
3166 tokens: tokens
3167 outline()
3168 sm()
3169 on_click: move |_: &UiEvent| {
3170 host_wave.ingest_event(&WindowEvent::KeyDown(
3171 WindowId::new(1),
3172 KeyEvent::new(KeyCode::Character('r'), Modifiers::default(), false),
3173 ));
3174 let _: u32 = host_wave.step(1.0 / 60.0);
3175 host_wave.ingest_event(&WindowEvent::KeyUp(
3176 WindowId::new(1),
3177 KeyEvent::new(KeyCode::Character('r'), Modifiers::default(), false),
3178 ));
3179 }
3180 }
3181 }
3182 { viewport }
3183 EuvActionRow {
3184 EuvButton {
3185 label: "Left (A)".to_string()
3186 tokens: tokens
3187 outline()
3188 sm()
3189 on_click: move |_: &UiEvent| {
3190 pulse_game_key(&host_left, KeyCode::ArrowLeft);
3191 }
3192 }
3193 EuvButton {
3194 label: "Up (W)".to_string()
3195 tokens: tokens
3196 outline()
3197 sm()
3198 on_click: move |_: &UiEvent| {
3199 pulse_game_key(&host_up, KeyCode::ArrowUp);
3200 }
3201 }
3202 EuvButton {
3203 label: "Down (S)".to_string()
3204 tokens: tokens
3205 outline()
3206 sm()
3207 on_click: move |_: &UiEvent| {
3208 pulse_game_key(&host_down, KeyCode::ArrowDown);
3209 }
3210 }
3211 EuvButton {
3212 label: "Right (D)".to_string()
3213 tokens: tokens
3214 outline()
3215 sm()
3216 on_click: move |_: &UiEvent| {
3217 pulse_game_key(&host_right, KeyCode::ArrowRight);
3218 }
3219 }
3220 EuvButton {
3221 label: "Dash (E)".to_string()
3222 tokens: tokens
3223 secondary()
3224 sm()
3225 on_click: move |_: &UiEvent| {
3226 pulse_game_key(&host_dash, KeyCode::Character('e'));
3227 }
3228 }
3229 EuvButton {
3230 label: "Fullscreen".to_string()
3231 tokens: tokens
3232 sm()
3233 on_click: move |_: &UiEvent| {
3234 let _: bool = fs_2d_open.set_if_changed(true);
3235 }
3236 }
3237 }
3238 { fs_2d_portal }
3239 }
3240 }
3241 }
3242 }
3243}
3244
3245fn mount_game_fullscreen_portal(
3260 open: Signal<bool>,
3261 host: &GameEngineHost,
3262 inline_viewport: NodeId,
3263 cam_mode_opt: Option<Signal<u8>>,
3264 title: &str,
3265 tokens: ThemeTokens,
3266) -> NodeId {
3267 let ctx: Context = current_context();
3268 bind_fullscreen_context(&ctx);
3269 let fs_viewport: NodeId = host.mount_viewport(
3270 Style::default()
3271 .flex_grow(1.0)
3272 .flex_shrink(1.0)
3273 .min_height(Length::Px(0.0))
3274 .width(Length::Percent(100.0))
3275 .overflow(Overflow::Hidden)
3276 .stop_scroll_propagation(true)
3277 .stop_event_propagation(true),
3278 );
3279 let ctrl_left: NodeId =
3280 mount_game_control_button(FS_CTRL_LEFT, host, KeyCode::ArrowLeft, false, tokens);
3281 let ctrl_up: NodeId = mount_game_control_button(
3282 if cam_mode_opt.is_some() {
3283 FS_CTRL_DRIVE
3284 } else {
3285 FS_CTRL_UP
3286 },
3287 host,
3288 KeyCode::ArrowUp,
3289 true,
3290 tokens,
3291 );
3292 let ctrl_down: NodeId = mount_game_control_button(
3293 if cam_mode_opt.is_some() {
3294 FS_CTRL_REVERSE
3295 } else {
3296 FS_CTRL_DOWN
3297 },
3298 host,
3299 KeyCode::ArrowDown,
3300 false,
3301 tokens,
3302 );
3303 let ctrl_right: NodeId =
3304 mount_game_control_button(FS_CTRL_RIGHT, host, KeyCode::ArrowRight, false, tokens);
3305 let extra_ctrl: NodeId = if let Some(cam_sig) = cam_mode_opt {
3306 let on_cam = move |_: &UiEvent| {
3307 let next: u8 = (cam_sig.get_untracked() + 1) % 4;
3308 let _: bool = cam_sig.set_if_changed(next);
3309 };
3310 view! {
3311 EuvButton {
3312 label: FS_CTRL_CAMERA.to_string()
3313 tokens: tokens
3314 secondary()
3315 sm()
3316 on_click: on_cam
3317 }
3318 }
3319 } else {
3320 mount_game_control_button(FS_CTRL_DASH, host, KeyCode::Character('e'), false, tokens)
3321 };
3322 let on_exit = move |_: &UiEvent| {
3323 let _: bool = open.set_if_changed(false);
3324 };
3325 let paint_exit_icon = move |bounds: Rect, dl: &mut DisplayList| {
3326 draw_euv_icon(EuvIconName::Minimize, bounds, dl, Color::hex(0xFAFAFA));
3327 };
3328 let mut top_bar_id: NodeId = NodeId::default();
3329 let mut bottom_bar_id: NodeId = NodeId::default();
3330 let portal: NodeId = view! {
3331 portal {
3332 style: Style::default().column()
3333 display: Display::None
3334 position: Position::Fixed
3335 inset: (Some(0.0), Some(0.0), Some(0.0), Some(0.0))
3336 width: Length::Percent(100.0)
3337 height: Length::Percent(100.0)
3338 padding: Edges::all(0.0)
3339 margin: Edges::all(0.0)
3340 background: Color::hex(0x09090B)
3341 border: (0.0, COLOR_TRANSPARENT)
3342 radius: 0.0
3343 overflow: Overflow::Hidden
3344 pointer_events: PointerEvents::None
3345 stop_scroll_propagation: true
3346 stop_event_propagation: true
3347 z_index: Z_INDEX_FULLSCREEN
3348 row {
3349 node_ref: top_bar_id
3350 width: Length::Percent(100.0)
3351 flex_shrink: 0.0
3352 justify: JustifyContent::SpaceBetween
3353 align: AlignItems::Center
3354 padding: Edges::symmetric(SPACE_SM, SPACE_MD)
3355 background: Color::rgba(9, 9, 11, 236)
3356 text {
3357 flex_shrink: 1.0
3358 min_width: Length::Px(0.0)
3359 font_size: 14.0
3360 font_weight: FontWeight::SemiBold
3361 color: Color::hex(0xFAFAFA)
3362 text_overflow: TextOverflow::Ellipsis
3363 { title.to_string() }
3364 }
3365 row {
3366 width: Length::Px(28.0)
3367 height: Length::Px(28.0)
3368 justify: JustifyContent::Center
3369 align: AlignItems::Center
3370 radius: 6.0
3371 background: Color::rgba(255, 255, 255, 24)
3372 border: (1.0, Color::rgba(255, 255, 255, 44))
3373 cursor: CursorIcon::Pointer
3374 role: A11yRole::Button
3375 a11y_label: BTN_EXIT_FULLSCREEN.to_string()
3376 on_click: on_exit
3377 canvas {
3378 width: Length::Px(14.0)
3379 height: Length::Px(14.0)
3380 painter: paint_exit_icon
3381 }
3382 }
3383 }
3384 { fs_viewport }
3385 row {
3386 node_ref: bottom_bar_id
3387 width: Length::Percent(100.0)
3388 flex_shrink: 0.0
3389 padding: Edges::symmetric(SPACE_SM, SPACE_MD)
3390 background: Color::rgba(9, 9, 11, 232)
3391 EuvActionRow {
3392 { ctrl_left }
3393 { ctrl_up }
3394 { ctrl_down }
3395 { ctrl_right }
3396 { extra_ctrl }
3397 }
3398 }
3399 }
3400 };
3401 let handle: SceneHandle = ctx.get_scene().clone();
3402 let safe_sig: Signal<SafeAreaInsets> = ctx.get_safe_area();
3403 let prev_fs: Rc<Cell<bool>> = Rc::new(Cell::new(false));
3404 let fs_acquired: Rc<Cell<bool>> = Rc::new(Cell::new(false));
3405 let fs_cleanup: Rc<Cell<bool>> = Rc::clone(&fs_acquired);
3406 let (scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
3407 on_cleanup(move || {
3408 if fs_cleanup.replace(false) {
3409 exit_fullscreen();
3410 }
3411 });
3412 let _: Effect = EuvOverlayStack::bind_signal(open, FS_OVERLAY_NAME, Z_INDEX_FULLSCREEN);
3413 Effect::new(move || {
3414 let is_open: bool = open.get();
3415 let safe: SafeAreaInsets = safe_sig.get();
3416 if is_open != prev_fs.replace(is_open) {
3417 if is_open {
3418 if !fs_acquired.replace(true) {
3419 enter_fullscreen();
3420 }
3421 } else if fs_acquired.replace(false) {
3422 exit_fullscreen();
3423 }
3424 }
3425 handle.with_write(
3426 |tree: &mut SceneTree| {
3427 tree.cancel_subtree_transitions(portal);
3428 if let Some(n) = tree.get_node_mut(inline_viewport) {
3429 let mut st: Style = n.get_style();
3430 st.get_mut_layout().set_display(if is_open {
3431 Display::None
3432 } else {
3433 Display::Flex
3434 });
3435 n.set_style(st);
3436 tree.mark_dirty(inline_viewport, DIRTY_LAYOUT | DIRTY_PAINT);
3437 }
3438 if let Some(n) = tree.get_node_mut(portal) {
3439 let mut st: Style = n.get_style();
3440 st.get_mut_layout().set_display(if is_open {
3441 Display::Flex
3442 } else {
3443 Display::None
3444 });
3445 st.get_mut_paint()
3446 .set_pointer_events(if is_open {
3447 PointerEvents::Auto
3448 } else {
3449 PointerEvents::None
3450 })
3451 .set_opacity(1.0)
3452 .set_transform(Transform2D::default());
3453 n.set_style(st);
3454 }
3455 if let Some(n) = tree.get_node_mut(top_bar_id) {
3456 let mut st: Style = n.get_style();
3457 st.get_mut_layout().set_padding(Edges::new(
3458 SPACE_SM + safe.get_top(),
3459 SPACE_MD + safe.get_right(),
3460 SPACE_SM,
3461 SPACE_MD + safe.get_left(),
3462 ));
3463 n.set_style(st);
3464 tree.mark_dirty(top_bar_id, DIRTY_LAYOUT | DIRTY_PAINT);
3465 }
3466 if let Some(n) = tree.get_node_mut(bottom_bar_id) {
3467 let mut st: Style = n.get_style();
3468 st.get_mut_layout().set_padding(Edges::new(
3469 SPACE_SM,
3470 SPACE_MD + safe.get_right(),
3471 SPACE_SM + safe.get_bottom(),
3472 SPACE_MD + safe.get_left(),
3473 ));
3474 n.set_style(st);
3475 tree.mark_dirty(bottom_bar_id, DIRTY_LAYOUT | DIRTY_PAINT);
3476 }
3477 let dirty_l: u16 = DIRTY_LAYOUT | DIRTY_SUBTREE_LAYOUT;
3478 tree.mark_dirty(portal, dirty_l | DIRTY_PAINT);
3479 },
3480 (),
3481 );
3482 })
3483 });
3484 ctx.get_scene().with_write(
3485 |tree: &mut SceneTree| {
3486 tree.attach_scope(portal, scope);
3487 },
3488 (),
3489 );
3490 portal
3491}
3492
3493fn mount_game_control_button(
3507 label: &str,
3508 host: &GameEngineHost,
3509 code: KeyCode,
3510 primary: bool,
3511 tokens: ThemeTokens,
3512) -> NodeId {
3513 let host_down: GameEngineHost = host.clone();
3514 let host_up: GameEngineHost = host.clone();
3515 let host_click: GameEngineHost = host.clone();
3516 let node: NodeId = if primary {
3517 view! {
3518 EuvButton {
3519 label: label.to_string()
3520 tokens: tokens
3521 sm()
3522 on_click: move |_: &UiEvent| {
3523 pulse_game_key(&host_click, code);
3524 }
3525 }
3526 }
3527 } else {
3528 view! {
3529 EuvButton {
3530 label: label.to_string()
3531 tokens: tokens
3532 outline()
3533 sm()
3534 on_click: move |_: &UiEvent| {
3535 pulse_game_key(&host_click, code);
3536 }
3537 }
3538 }
3539 };
3540 let mut ctx: Context = current_context();
3541 ctx.on_pointer_down(node, move |_: &UiEvent| {
3542 host_down.press_key(code);
3543 });
3544 ctx.on_pointer_up(node, move |_: &UiEvent| {
3545 host_up.release_key(code);
3546 });
3547 node
3548}
3549
3550fn pulse_game_key(host: &GameEngineHost, code: KeyCode) {
3557 host.press_key(code);
3558 let _: u32 = host.step(0.08);
3559 host.release_key(code);
3560}
3561
3562pub fn mount_game3d_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3573 let g: ThemeGeometry = tokens.get_geometry();
3574 let p: ThemePalette = tokens.get_palette();
3575 let host: GameEngineHost = state.get_game3d_host().clone();
3576 let quality_sig: Signal<RenderQualityConfig> = state.get_engine3d_quality();
3577 let preset_idx: Signal<usize> = state.get_engine3d_preset_idx();
3578 let rt_idx: Signal<usize> = state.get_engine3d_rt_idx();
3579 let res_scale: Signal<f32> = state.get_engine3d_res_scale();
3580 let time_sig: Signal<f32> = state.get_engine3d_time_of_day();
3581 let import_sig: Signal<u64> = state.get_engine3d_import_queue();
3582 let status_sig: Signal<String> = state.get_engine3d_import_status();
3583 let cam_mode_sig: Signal<u8> = state.get_engine3d_camera_mode();
3584 let viewport: NodeId = host.mount_viewport(
3585 Style::default()
3586 .width(Length::Percent(100.0))
3587 .height(Length::Px(340.0))
3588 .border(g.get_border_width(), p.get_border())
3589 .radius(g.get_radius_md()),
3590 );
3591 let fs_3d_open: Signal<bool> = Signal::new(false);
3592 let fs_3d_portal: NodeId = mount_game_fullscreen_portal(
3593 fs_3d_open,
3594 &host,
3595 viewport,
3596 Some(cam_mode_sig),
3597 "Vice Boulevard 3D RT",
3598 tokens,
3599 );
3600 let res_slider: NodeId = view! {
3601 EuvSlider {
3602 value: res_scale
3603 min: 40.0
3604 max: 125.0
3605 tokens: tokens
3606 }
3607 };
3608 let sun_slider: NodeId = view! {
3609 EuvSlider {
3610 value: time_sig
3611 min: 6.0
3612 max: 23.0
3613 tokens: tokens
3614 }
3615 };
3616 let ctx: Context = current_context();
3617 let (sync_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
3618 Effect::new(move || {
3619 let p_idx: usize = preset_idx.get();
3620 let preset: QualityPreset = match p_idx {
3621 0 => QualityPreset::Low,
3622 1 => QualityPreset::Medium,
3623 3 => QualityPreset::Ultra,
3624 4 => QualityPreset::Cinematic,
3625 _ => QualityPreset::High,
3626 };
3627 let rt: RayTracingMode = match rt_idx.get() {
3628 0 => RayTracingMode::Off,
3629 1 => RayTracingMode::ShadowsOnly,
3630 3 => RayTracingMode::FullPathTracedGi,
3631 _ => RayTracingMode::ShadowsAndReflections,
3632 };
3633 let scale_pct: f32 = res_scale.get();
3634 let mut cfg: RenderQualityConfig = RenderQualityConfig::from_preset(preset);
3635 cfg.set_ray_tracing(rt);
3636 cfg.set_resolution_scale((scale_pct / 100.0).clamp(0.40, 1.25));
3637 let _: bool = quality_sig.set_if_changed(cfg);
3638 })
3639 });
3640 let mut sync_host_id: NodeId = NodeId::default();
3641 let page: NodeId = view! {
3642 EuvPage {
3643 title: GAME3D_TITLE.to_string()
3644 subtitle: GAME3D_SUBTITLE.to_string()
3645 tokens: tokens
3646 EuvCard {
3647 title: GAME3D_CARD_TITLE.to_string()
3648 tokens: tokens
3649 subtitle: GAME3D_CARD_SUB
3650 column {
3651 node_ref: sync_host_id
3652 width: Length::Percent(100.0)
3653 gap: SPACE_MD
3654 { viewport }
3655 EuvActionRow {
3656 { mount_game_control_button("Steer Left (A)", &host, KeyCode::ArrowLeft, false, tokens) }
3657 { mount_game_control_button("Drive Fwd (W)", &host, KeyCode::ArrowUp, false, tokens) }
3658 { mount_game_control_button("Reverse (S)", &host, KeyCode::ArrowDown, false, tokens) }
3659 { mount_game_control_button("Steer Right (D)", &host, KeyCode::ArrowRight, false, tokens) }
3660 EuvButton {
3661 label: "Switch Camera".to_string()
3662 tokens: tokens
3663 secondary()
3664 sm()
3665 on_click: move |_: &UiEvent| {
3666 let next: u8 = (cam_mode_sig.get_untracked() + 1) % 4;
3667 let _: bool = cam_mode_sig.set_if_changed(next);
3668 }
3669 }
3670 EuvButton {
3671 label: "Fullscreen 3D".to_string()
3672 tokens: tokens
3673 sm()
3674 on_click: move |_: &UiEvent| {
3675 let _: bool = fs_3d_open.set_if_changed(true);
3676 }
3677 }
3678 EuvButton {
3679 label: "Import .OBJ Monument".to_string()
3680 tokens: tokens
3681 secondary()
3682 sm()
3683 on_click: move |_: &UiEvent| {
3684 let cur: u64 = import_sig.get_untracked();
3685 let next: u64 = if cur.is_multiple_of(2) { cur + 1 } else { cur + 2 };
3686 let _: bool = import_sig.set_if_changed(next);
3687 }
3688 }
3689 EuvButton {
3690 label: "Import .glTF Tower".to_string()
3691 tokens: tokens
3692 outline()
3693 sm()
3694 on_click: move |_: &UiEvent| {
3695 let cur: u64 = import_sig.get_untracked();
3696 let next: u64 = if !cur.is_multiple_of(2) { cur + 1 } else { cur + 2 };
3697 let _: bool = import_sig.set_if_changed(next);
3698 }
3699 }
3700 }
3701 text {
3702 font_size: 12.0
3703 color: p.get_muted_foreground()
3704 { move || status_sig.get() }
3705 }
3706 EuvSegmented {
3707 options: vec![
3708 "Low".to_string(),
3709 "Medium".to_string(),
3710 "High".to_string(),
3711 "Ultra".to_string(),
3712 "Cinematic".to_string(),
3713 ]
3714 selected: preset_idx
3715 tokens: tokens
3716 }
3717 EuvSegmented {
3718 options: vec![
3719 "RT Off".to_string(),
3720 "RT Shadows".to_string(),
3721 "RT Refl".to_string(),
3722 "RT Full GI".to_string(),
3723 ]
3724 selected: rt_idx
3725 tokens: tokens
3726 }
3727 EuvField {
3728 label: "Runtime Render Resolution Scale (%)".to_string()
3729 control: res_slider
3730 tokens: tokens
3731 }
3732 EuvField {
3733 label: "Time of Day / Sun Lighting (6h Dawn -> 17h Sunset -> 22h Night)".to_string()
3734 control: sun_slider
3735 tokens: tokens
3736 }
3737 { fs_3d_portal }
3738 }
3739 }
3740 }
3741 };
3742 ctx.get_scene().with_write(
3743 |tree: &mut SceneTree| {
3744 tree.attach_scope(sync_host_id, sync_scope);
3745 },
3746 (),
3747 );
3748 page
3749}
3750
3751pub fn mount_overlays_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
3762 let p: ThemePalette = tokens.get_palette();
3763 let modal_open: Signal<bool> = state.get_modal_open();
3764 let drawer_open: Signal<bool> = state.get_drawer_open();
3765 let sheet_open: Signal<bool> = state.get_sheet_open();
3766 let toast_visible: Signal<bool> = state.get_toast_visible();
3767 let notif_visible: Signal<bool> = state.get_notif_visible();
3768 let alert_open: Signal<bool> = state.get_alert_dialog_open();
3769 let ctx_sel: Signal<Option<usize>> = Signal::new(None);
3770 let tip_btn: NodeId = view! {
3771 EuvButton {
3772 label: "Hover Tooltip".to_string()
3773 tokens: tokens
3774 outline()
3775 sm()
3776 }
3777 };
3778 let modal_body: NodeId = view! {
3779 column {
3780 width: Length::Percent(100.0)
3781 gap: SPACE_MD
3782 text {
3783 font_size: 13.0
3784 color: p.get_muted_foreground()
3785 { MODAL_BODY_TEXT }
3786 }
3787 row {
3788 width: Length::Percent(100.0)
3789 justify: JustifyContent::End
3790 EuvButton {
3791 label: BTN_CLOSE_MODAL.to_string()
3792 tokens: tokens
3793 outline()
3794 on_click: move |_: &UiEvent| {
3795 let _: bool = modal_open.set_if_changed(false);
3796 }
3797 }
3798 }
3799 }
3800 };
3801 let drawer_body: NodeId = view! {
3802 column {
3803 width: Length::Percent(100.0)
3804 gap: SPACE_MD
3805 text {
3806 font_size: 13.0
3807 color: p.get_muted_foreground()
3808 "Native slide-over drawer surface"
3809 }
3810 row {
3811 width: Length::Percent(100.0)
3812 justify: JustifyContent::End
3813 EuvButton {
3814 label: "Close Drawer".to_string()
3815 tokens: tokens
3816 outline()
3817 on_click: move |_: &UiEvent| {
3818 let _: bool = drawer_open.set_if_changed(false);
3819 }
3820 }
3821 }
3822 }
3823 };
3824 let sheet_body: NodeId = view! {
3825 column {
3826 width: Length::Percent(100.0)
3827 gap: SPACE_MD
3828 text {
3829 font_size: 13.0
3830 color: p.get_muted_foreground()
3831 "Native bottom action sheet"
3832 }
3833 row {
3834 width: Length::Percent(100.0)
3835 justify: JustifyContent::End
3836 EuvButton {
3837 label: "Close Sheet".to_string()
3838 tokens: tokens
3839 outline()
3840 on_click: move |_: &UiEvent| {
3841 let _: bool = sheet_open.set_if_changed(false);
3842 }
3843 }
3844 }
3845 }
3846 };
3847 view! {
3848 EuvPage {
3849 title: OVERLAYS_TITLE.to_string()
3850 subtitle: OVERLAYS_SUBTITLE.to_string()
3851 tokens: tokens
3852 column {
3853 width: Length::Percent(100.0)
3854 gap: SPACE_LG
3855 EuvAlert {
3856 title: ALERT_TITLE.to_string()
3857 description: ALERT_DESC.to_string()
3858 tone: EuvTone::Primary
3859 tokens: tokens
3860 }
3861 EuvCard {
3862 title: OVERLAYS_CARD_TITLE.to_string()
3863 tokens: tokens
3864 subtitle: OVERLAYS_CARD_SUB
3865 EuvActionRow {
3866 EuvButton {
3867 label: BTN_OPEN_MODAL.to_string()
3868 tokens: tokens
3869 on_click: move |_: &UiEvent| {
3870 let _: bool = modal_open.set_if_changed(true);
3871 }
3872 }
3873 EuvButton {
3874 label: "Alert Dialog".to_string()
3875 tokens: tokens
3876 destructive()
3877 on_click: move |_: &UiEvent| {
3878 let _: bool = alert_open.set_if_changed(true);
3879 }
3880 }
3881 EuvButton {
3882 label: BTN_TOGGLE_TOAST.to_string()
3883 tokens: tokens
3884 secondary()
3885 on_click: move |_: &UiEvent| {
3886 let _: bool = toast_visible.update(|v: &mut bool| *v = !*v);
3887 }
3888 }
3889 EuvButton {
3890 label: "Toggle Drawer".to_string()
3891 tokens: tokens
3892 outline()
3893 on_click: move |_: &UiEvent| {
3894 let _: bool = drawer_open.update(|v: &mut bool| *v = !*v);
3895 }
3896 }
3897 EuvButton {
3898 label: "Toggle Sheet".to_string()
3899 tokens: tokens
3900 outline()
3901 on_click: move |_: &UiEvent| {
3902 let _: bool = sheet_open.update(|v: &mut bool| *v = !*v);
3903 }
3904 }
3905 EuvButton {
3906 label: "Toggle Notification".to_string()
3907 tokens: tokens
3908 outline()
3909 on_click: move |_: &UiEvent| {
3910 let _: bool = notif_visible.update(|v: &mut bool| *v = !*v);
3911 }
3912 }
3913 }
3914 EuvDropdown {
3915 label: "Quick Actions".to_string()
3916 items: vec!["Export PNG".to_string(), "Copy DeepLink".to_string()]
3917 tokens: tokens
3918 open: state.get_dropdown_open()
3919 selected: state.get_dropdown_selected()
3920 }
3921 EuvHoverCard {
3922 trigger_label: "@euv-dev".to_string()
3923 title: HOVER_CARD_ENGINE_TITLE.to_string()
3924 tokens: tokens
3925 open: state.get_hover_card_open()
3926 description: "Full ui.shadcn.com component alignment across all 7 native targets."
3927 }
3928 EuvTooltip {
3929 text: "Zero-WebView floating tooltip".to_string()
3930 trigger: tip_btn
3931 tokens: tokens
3932 }
3933 EuvContextMenu {
3934 trigger_label: "Context Menu Surface".to_string()
3935 items: vec![
3936 "Inspect Scene Node".to_string(),
3937 "Copy AI Selector".to_string(),
3938 "Capture Frame Hash".to_string(),
3939 ]
3940 tokens: tokens
3941 selected: ctx_sel
3942 }
3943 }
3944 EuvModal {
3945 open: modal_open
3946 title: MODAL_TITLE.to_string()
3947 body: modal_body
3948 tokens: tokens
3949 }
3950 EuvAlertDialog {
3951 open: alert_open
3952 title: "Are you absolutely sure?".to_string()
3953 confirmed: state.get_alert_dialog_confirmed()
3954 tokens: tokens
3955 description: "This shadcn AlertDialog confirms destructive operations cleanly."
3956 labels("Cancel", "Continue")
3957 }
3958 EuvDrawer {
3959 open: drawer_open
3960 title: "Inspector Drawer".to_string()
3961 body: drawer_body
3962 tokens: tokens
3963 }
3964 EuvSheet {
3965 open: sheet_open
3966 title: "Quick Sheet".to_string()
3967 body: sheet_body
3968 tokens: tokens
3969 }
3970 EuvToast {
3971 visible: toast_visible
3972 message: TOAST_TEXT.to_string()
3973 tone: EuvTone::Success
3974 tokens: tokens
3975 }
3976 EuvNotification {
3977 visible: notif_visible
3978 title: "Native Sync".to_string()
3979 message: "All 7 targets active.".to_string()
3980 tokens: tokens
3981 tone: EuvTone::Success
3982 }
3983 EuvLoading {
3984 active: state.get_loading_active()
3985 label: "Syncing...".to_string()
3986 tokens: tokens
3987 }
3988 }
3989 }
3990 }
3991}
3992
3993pub fn mount_dynamic_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
4004 state.ensure_wasm_registry_loaded();
4005 let p: ThemePalette = tokens.get_palette();
4006 let g: ThemeGeometry = tokens.get_geometry();
4007 let hub: DynamicUpdateHub = state.get_dynamic_hub().clone();
4008 let sibling_counter: Signal<i32> = state.get_sibling_counter();
4009 let action_log: Signal<String> = state.get_dynamic_action_log();
4010 let route_sig: Signal<String> = state.get_route();
4011 let tel_sig: Signal<DynamicTelemetry> = hub.telemetry();
4012 let banner_rev: Signal<u64> = hub.component_revision_signal(SLOT_PROMO_BANNER);
4013 let metrics_rev: Signal<u64> = hub.component_revision_signal(SLOT_METRICS_WIDGET);
4014 let panel_rev: Signal<u64> = hub.page_revision_signal(ROUTE_DYNAMIC_PANEL);
4015 let hub_v1: DynamicUpdateHub = hub.clone();
4016 let hub_v2: DynamicUpdateHub = hub.clone();
4017 let hub_rb: DynamicUpdateHub = hub.clone();
4018 let hub_m1: DynamicUpdateHub = hub.clone();
4019 let hub_mrb: DynamicUpdateHub = hub.clone();
4020 let hub_p1: DynamicUpdateHub = hub.clone();
4021 let hub_bundle: DynamicUpdateHub = hub.clone();
4022 let hub_prb: DynamicUpdateHub = hub.clone();
4023 let hub_inject: DynamicUpdateHub = hub.clone();
4024 let hub_for_status: DynamicUpdateHub = hub.clone();
4025 let wasm_mgr: WasmDynamicManager = state.get_wasm_manager().clone();
4026 let wasm_reg: RegistryWasmFetcher = state.get_wasm_registry().clone();
4027 let wasm_offline_sig: Signal<bool> = state.get_wasm_offline();
4028 let wasm_status_sig: Signal<String> = state.get_wasm_fault_status();
4029 let partial_scope: WasmDynamicScope = WasmDynamicScope::Partial {
4030 slot_id: SLOT_WASM_WIDGET.to_string(),
4031 };
4032 let partial_state_sig: Signal<WasmLoadState> = wasm_mgr.state_signal(&partial_scope);
4033 let global_state_sig: Signal<WasmLoadState> = wasm_mgr.state_signal(&WasmDynamicScope::Global);
4034 let wasm_tel_sig: Signal<WasmDynamicTelemetry> = wasm_mgr.telemetry();
4035 let m_p1: WasmDynamicManager = wasm_mgr.clone();
4036 let s_p1: Signal<String> = wasm_status_sig;
4037 let m_p2: WasmDynamicManager = wasm_mgr.clone();
4038 let s_p2: Signal<String> = wasm_status_sig;
4039 let m_prb: WasmDynamicManager = wasm_mgr.clone();
4040 let s_prb: Signal<String> = wasm_status_sig;
4041 let m_pun: WasmDynamicManager = wasm_mgr.clone();
4042 let s_pun: Signal<String> = wasm_status_sig;
4043 let r_off: RegistryWasmFetcher = wasm_reg.clone();
4044 let s_off: Signal<String> = wasm_status_sig;
4045 let m_g1: WasmDynamicManager = wasm_mgr.clone();
4046 let s_g1: Signal<String> = wasm_status_sig;
4047 let m_g2: WasmDynamicManager = wasm_mgr.clone();
4048 let s_g2: Signal<String> = wasm_status_sig;
4049 let m_gbad: WasmDynamicManager = wasm_mgr.clone();
4050 let s_gbad: Signal<String> = wasm_status_sig;
4051 let m_grb: WasmDynamicManager = wasm_mgr.clone();
4052 let s_grb: Signal<String> = wasm_status_sig;
4053 let m_f_retry: WasmDynamicManager = wasm_mgr.clone();
4054 let s_f_retry: Signal<String> = wasm_status_sig;
4055 let m_f_500: WasmDynamicManager = wasm_mgr.clone();
4056 let s_f_500: Signal<String> = wasm_status_sig;
4057 let m_f_corrupt: WasmDynamicManager = wasm_mgr.clone();
4058 let s_f_corrupt: Signal<String> = wasm_status_sig;
4059 let m_f_tamper: WasmDynamicManager = wasm_mgr.clone();
4060 let s_f_tamper: Signal<String> = wasm_status_sig;
4061 let m_f_sig: WasmDynamicManager = wasm_mgr.clone();
4062 let s_f_sig: Signal<String> = wasm_status_sig;
4063 let m_f_abi: WasmDynamicManager = wasm_mgr.clone();
4064 let s_f_abi: Signal<String> = wasm_status_sig;
4065 let m_f_exp: WasmDynamicManager = wasm_mgr.clone();
4066 let s_f_exp: Signal<String> = wasm_status_sig;
4067 let m_f_fuel: WasmDynamicManager = wasm_mgr.clone();
4068 let s_f_fuel: Signal<String> = wasm_status_sig;
4069 let m_f_trap: WasmDynamicManager = wasm_mgr.clone();
4070 let s_f_trap: Signal<String> = wasm_status_sig;
4071 let m_f_big: WasmDynamicManager = wasm_mgr.clone();
4072 let s_f_big: Signal<String> = wasm_status_sig;
4073 let m_f_cancel: WasmDynamicManager = wasm_mgr.clone();
4074 let s_f_cancel: Signal<String> = wasm_status_sig;
4075 let m_http: WasmDynamicManager = wasm_mgr.clone();
4076 let s_http: Signal<String> = wasm_status_sig;
4077 view! {
4078 EuvPage {
4079 title: DYNAMIC_TITLE.to_string()
4080 subtitle: DYNAMIC_SUBTITLE.to_string()
4081 tokens: tokens
4082 EuvCard {
4083 title: "Scoped / Partial Dynamic WASM Execution".to_string()
4084 tokens: tokens
4085 subtitle: "Download genuine .wasm binaries into a single native slot with checksum/signature verification, offline cache, interactive euv_on_event & rollback"
4086 column {
4087 gap: SPACE_MD
4088 EuvActionRow {
4089 EuvButton {
4090 label: "Download Real HTTP .wasm".to_string()
4091 tokens: tokens
4092 on_click: move |_: &UiEvent| {
4093 #[cfg(not(target_arch = "wasm32"))]
4094 {
4095 let bytes: Vec<u8> = build_partial_widget_wasm(
4096 "Live HTTP-Downloaded .wasm Module v3",
4097 3,
4098 0x059669,
4099 );
4100 let bytes_srv: Vec<u8> = bytes.clone();
4101 match TcpListener::bind("127.0.0.1:0") {
4102 Ok(listener) => {
4103 let port: u16 = listener
4104 .local_addr()
4105 .map(|addr: SocketAddr| addr.port())
4106 .unwrap_or(0);
4107 drop(spawn(move || {
4108 if let Ok((mut stream, _)) = listener.accept() {
4109 let mut req_buf: [u8; 512] = [0; 512];
4110 let _: Result<usize, Error> = stream.read(&mut req_buf);
4111 let hdr: String = format!(
4112 "HTTP/1.1 200 OK\r\nContent-Type: application/wasm\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
4113 bytes_srv.len()
4114 );
4115 let _: Result<(), Error> = stream.write_all(hdr.as_bytes());
4116 let _: Result<(), Error> = stream.write_all(&bytes_srv);
4117 let _: Result<(), Error> = stream.flush();
4118 }
4119 }));
4120 let url: String =
4121 format!("http://127.0.0.1:{port}/live-module-v3.wasm");
4122 let req: WasmDownloadRequest = WasmDownloadRequest::partial(
4123 url.clone(),
4124 SLOT_WASM_WIDGET.to_string(),
4125 3,
4126 )
4127 .with_checksum(compute_wasm_checksum(&bytes))
4128 .with_signature(compute_wasm_signature(
4129 &bytes,
4130 3,
4131 WASM_SHOWCASE_SIGNING_KEY,
4132 ))
4133 .with_allow_downgrade(true);
4134 match m_http.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4135 Ok(v) => {
4136 let _: bool = s_http.set(format!(
4137 "Downloaded {} bytes over real HTTP ({url}) -> executed & mounted .wasm v{v} natively!",
4138 bytes.len()
4139 ));
4140 }
4141 Err(e) => {
4142 let _: bool = s_http.set(format!("HTTP .wasm download failed: {e}"));
4143 }
4144 }
4145 }
4146 Err(err) => {
4147 let _: bool = s_http.set(format!("Local HTTP server bind error: {err}"));
4148 }
4149 }
4150 }
4151 #[cfg(target_arch = "wasm32")]
4152 {
4153 let bytes: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
4154 let req: WasmDownloadRequest = WasmDownloadRequest::partial(
4155 URL_WASM_PARTIAL_V1.to_string(),
4156 SLOT_WASM_WIDGET.to_string(),
4157 1,
4158 )
4159 .with_checksum(compute_wasm_checksum(&bytes))
4160 .with_signature(compute_wasm_signature(&bytes, 1, WASM_SHOWCASE_SIGNING_KEY))
4161 .with_allow_downgrade(true);
4162 match m_http.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4163 Ok(v) => { let _: bool = s_http.set(format!("Fetched & executed .wasm v{v} natively in browser sandbox")); }
4164 Err(e) => { let _: bool = s_http.set(format!("WASM fetch failed: {e}")); }
4165 }
4166 }
4167 }
4168 }
4169 EuvButton {
4170 label: "Download Partial WASM v1".to_string()
4171 tokens: tokens
4172 secondary()
4173 on_click: move |_: &UiEvent| {
4174 let bytes: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
4175 let req: WasmDownloadRequest = WasmDownloadRequest::partial(
4176 URL_WASM_PARTIAL_V1.to_string(),
4177 SLOT_WASM_WIDGET.to_string(),
4178 1,
4179 )
4180 .with_checksum(compute_wasm_checksum(&bytes))
4181 .with_signature(compute_wasm_signature(&bytes, 1, WASM_SHOWCASE_SIGNING_KEY))
4182 .with_allow_downgrade(true);
4183 match m_p1.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4184 Ok(v) => { let _: bool = s_p1.set(format!("Mounted Partial .wasm v{v} natively (verified checksum + signature)")); }
4185 Err(e) => { let _: bool = s_p1.set(format!("Partial v1 failed: {e}")); }
4186 }
4187 }
4188 }
4189 EuvButton {
4190 label: "Hot-Swap Partial WASM v2".to_string()
4191 tokens: tokens
4192 secondary()
4193 on_click: move |_: &UiEvent| {
4194 let bytes: Vec<u8> = build_partial_widget_wasm("Hot-Swapped Partial WASM Widget v2", 2, 0x7C3AED);
4195 let req: WasmDownloadRequest = WasmDownloadRequest::partial(
4196 URL_WASM_PARTIAL_V2.to_string(),
4197 SLOT_WASM_WIDGET.to_string(),
4198 2,
4199 )
4200 .with_checksum(compute_wasm_checksum(&bytes))
4201 .with_signature(compute_wasm_signature(&bytes, 2, WASM_SHOWCASE_SIGNING_KEY))
4202 .with_allow_downgrade(true);
4203 match m_p2.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4204 Ok(v) => { let _: bool = s_p2.set(format!("Hot-swapped Partial .wasm v{v} natively (sibling UI untouched)")); }
4205 Err(e) => { let _: bool = s_p2.set(format!("Partial v2 failed: {e}")); }
4206 }
4207 }
4208 }
4209 EuvButton {
4210 label: "Toggle Offline (Cache Hit)".to_string()
4211 tokens: tokens
4212 outline()
4213 on_click: move |_: &UiEvent| {
4214 let next: bool = !wasm_offline_sig.get_untracked();
4215 let _: bool = wasm_offline_sig.set(next);
4216 r_off.set_offline(next);
4217 let _: bool = s_off.set(if next {
4218 "Simulated OFFLINE enabled — re-downloading v1 will serve verified offline cache!".to_string()
4219 } else {
4220 "Simulated ONLINE restored — fetching live .wasm from CDN".to_string()
4221 });
4222 }
4223 }
4224 EuvButton {
4225 label: "Rollback Partial".to_string()
4226 tokens: tokens
4227 outline()
4228 on_click: move |_: &UiEvent| {
4229 match m_prb.rollback_partial(SLOT_WASM_WIDGET, "manual rollback") {
4230 Ok(v) => { let _: bool = s_prb.set(format!("Rolled back partial WASM slot to v{v}")); }
4231 Err(e) => { let _: bool = s_prb.set(format!("Rollback: {e}")); }
4232 }
4233 }
4234 }
4235 EuvButton {
4236 label: "Unmount Slot".to_string()
4237 tokens: tokens
4238 ghost()
4239 on_click: move |_: &UiEvent| {
4240 m_pun.unmount_partial(SLOT_WASM_WIDGET);
4241 let _: bool = s_pun.set("Unmounted partial WASM instance and restored compiled fallback".to_string());
4242 }
4243 }
4244 }
4245 slot {
4246 id: SLOT_WASM_WIDGET
4247 row {
4248 width: Length::Percent(100.0)
4249 padding: Edges::all(SPACE_MD)
4250 background: p.get_muted()
4251 border: (g.get_border_width(), p.get_border())
4252 radius: g.get_radius_md()
4253 text {
4254 font_size: 13.0
4255 color: p.get_muted_foreground()
4256 "Compiled Native Slot (v0) — click 'Download Partial WASM v1' to fetch, verify, execute .wasm in sandbox & render natively."
4257 }
4258 }
4259 }
4260 text {
4261 font_size: 12.0
4262 color: p.get_muted_foreground()
4263 { move || {
4264 let st: WasmLoadState = partial_state_sig.get();
4265 let gst: WasmLoadState = global_state_sig.get();
4266 let tel: WasmDynamicTelemetry = wasm_tel_sig.get();
4267 format!(
4268 "Partial={st:?} | Global={gst:?} | OK={}/{} Cache={} Retries={} Rollbacks={} Traps={} FuelStops={} Rejects={} Events={}",
4269 tel.get_downloads_succeeded(),
4270 tel.get_downloads_started(),
4271 tel.get_cache_hits(),
4272 tel.get_retries_performed(),
4273 tel.get_rollbacks_executed(),
4274 tel.get_sandbox_traps_caught(),
4275 tel.get_fuel_exhaustions_caught(),
4276 tel.get_integrity_rejections(),
4277 tel.get_events_handled()
4278 )
4279 } }
4280 }
4281 }
4282 }
4283 EuvCard {
4284 title: "Global / Full-App Dynamic WASM Takeover".to_string()
4285 tokens: tokens
4286 subtitle: "Atomically replace the entire native app shell from a downloaded .wasm release with automatic Last-Known-Good (LKG) rollback on any fault"
4287 column {
4288 gap: SPACE_MD
4289 EuvActionRow {
4290 EuvButton {
4291 label: "Download Global WASM v1".to_string()
4292 tokens: tokens
4293 on_click: move |_: &UiEvent| {
4294 let bytes: Vec<u8> =
4295 build_global_app_wasm("Global Dynamic WASM App Shell v1", 1);
4296 let req: WasmDownloadRequest =
4297 WasmDownloadRequest::global(URL_WASM_GLOBAL_V1.to_string(), 1)
4298 .with_checksum(compute_wasm_checksum(&bytes))
4299 .with_signature(compute_wasm_signature(
4300 &bytes,
4301 1,
4302 WASM_SHOWCASE_SIGNING_KEY,
4303 ))
4304 .with_allow_downgrade(true);
4305 match m_g1.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4306 Ok(v) => {
4307 let _: bool = s_g1
4308 .set(format!("Global .wasm v{v} took over root shell natively!"));
4309 }
4310 Err(e) => {
4311 let _: bool = s_g1.set(format!("Global v1 failed: {e}"));
4312 }
4313 }
4314 }
4315 }
4316 EuvButton {
4317 label: "Upgrade Global WASM v2".to_string()
4318 tokens: tokens
4319 secondary()
4320 on_click: move |_: &UiEvent| {
4321 let bytes: Vec<u8> =
4322 build_global_app_wasm("Global Dynamic WASM App Shell v2", 2);
4323 let req: WasmDownloadRequest =
4324 WasmDownloadRequest::global(URL_WASM_GLOBAL_V2.to_string(), 2)
4325 .with_checksum(compute_wasm_checksum(&bytes))
4326 .with_signature(compute_wasm_signature(
4327 &bytes,
4328 2,
4329 WASM_SHOWCASE_SIGNING_KEY,
4330 ))
4331 .with_allow_downgrade(true);
4332 match m_g2.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4333 Ok(v) => {
4334 let _: bool =
4335 s_g2.set(format!("Upgraded Global .wasm to v{v} atomically"));
4336 }
4337 Err(e) => {
4338 let _: bool = s_g2.set(format!("Global v2 failed: {e}"));
4339 }
4340 }
4341 }
4342 }
4343 EuvButton {
4344 label: "Faulty Global (Auto LKG Rollback)".to_string()
4345 tokens: tokens
4346 destructive()
4347 on_click: move |_: &UiEvent| {
4348 let req: WasmDownloadRequest =
4349 WasmDownloadRequest::global(URL_WASM_TRAP.to_string(), 99);
4350 match m_gbad.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4351 Ok(v) => {
4352 let _: bool = s_gbad.set(format!("Unexpected global mount v{v}"));
4353 }
4354 Err(e) => {
4355 let _: bool =
4356 s_gbad.set(format!("Global fault isolated & LKG preserved: {e}"));
4357 }
4358 }
4359 }
4360 }
4361 EuvButton {
4362 label: "Restore Native Shell".to_string()
4363 tokens: tokens
4364 outline()
4365 on_click: move |_: &UiEvent| {
4366 m_grb.restore_native_global();
4367 let _: bool = s_grb.set(STATUS_RESTORED_NATIVE_SHELL.to_string());
4368 }
4369 }
4370 }
4371 }
4372 }
4373 EuvCard {
4374 title: "All-Case Security, Fault & Sandbox Verification Matrix".to_string()
4375 tokens: tokens
4376 subtitle: "Verify every edge case live: auto-retry, offline cache, integrity rejection, ABI mismatch, infinite-loop fuel cutoff, trap isolation & stale cancel guard"
4377 column {
4378 gap: SPACE_MD
4379 EuvActionRow {
4380 EuvButton {
4381 label: "Timeout -> Auto Retry".to_string()
4382 tokens: tokens
4383 outline()
4384 sm()
4385 on_click: move |_: &UiEvent| {
4386 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TIMEOUT_RETRY.to_string(), SLOT_WASM_WIDGET.to_string(), 10).with_allow_downgrade(true);
4387 match m_f_retry.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY) {
4388 Ok(v) => { let _: bool = s_f_retry.set(format!("PASS Timeout->Retry recovered and mounted v{v}!")); }
4389 Err(e) => { let _: bool = s_f_retry.set(format!("Retry failed: {e}")); }
4390 }
4391 }
4392 }
4393 EuvButton {
4394 label: "HTTP 500".to_string()
4395 tokens: tokens
4396 outline()
4397 sm()
4398 on_click: move |_: &UiEvent| {
4399 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_HTTP_500.to_string(), SLOT_WASM_WIDGET.to_string(), 11).with_allow_downgrade(true);
4400 let res: String = format!("Handled HTTP 500 -> {:?}", m_f_500.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4401 let _: bool = s_f_500.set(res);
4402 }
4403 }
4404 EuvButton {
4405 label: "Corrupted Magic".to_string()
4406 tokens: tokens
4407 outline()
4408 sm()
4409 on_click: move |_: &UiEvent| {
4410 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_CORRUPTED.to_string(), SLOT_WASM_WIDGET.to_string(), 12).with_allow_downgrade(true);
4411 let res: String = format!("Blocked Corrupted Magic -> {:?}", m_f_corrupt.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4412 let _: bool = s_f_corrupt.set(res);
4413 }
4414 }
4415 EuvButton {
4416 label: "Tampered Checksum".to_string()
4417 tokens: tokens
4418 outline()
4419 sm()
4420 on_click: move |_: &UiEvent| {
4421 let good: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
4422 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TAMPERED.to_string(), SLOT_WASM_WIDGET.to_string(), 13)
4423 .with_checksum(compute_wasm_checksum(&good))
4424 .with_allow_downgrade(true);
4425 let res: String = format!("Blocked Tampered Checksum -> {:?}", m_f_tamper.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4426 let _: bool = s_f_tamper.set(res);
4427 }
4428 }
4429 EuvButton {
4430 label: "Invalid Signature".to_string()
4431 tokens: tokens
4432 outline()
4433 sm()
4434 on_click: move |_: &UiEvent| {
4435 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_PARTIAL_V1.to_string(), SLOT_WASM_WIDGET.to_string(), 14)
4436 .with_signature("euv-sig-v1:forged".to_string())
4437 .with_allow_downgrade(true);
4438 let res: String = format!("Blocked Forged Signature -> {:?}", m_f_sig.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4439 let _: bool = s_f_sig.set(res);
4440 }
4441 }
4442 EuvButton {
4443 label: "ABI Mismatch".to_string()
4444 tokens: tokens
4445 outline()
4446 sm()
4447 on_click: move |_: &UiEvent| {
4448 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_BAD_ABI.to_string(), SLOT_WASM_WIDGET.to_string(), 15).with_allow_downgrade(true);
4449 let res: String = format!("Blocked ABI Mismatch -> {:?}", m_f_abi.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4450 let _: bool = s_f_abi.set(res);
4451 }
4452 }
4453 EuvButton {
4454 label: "Missing Export".to_string()
4455 tokens: tokens
4456 outline()
4457 sm()
4458 on_click: move |_: &UiEvent| {
4459 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_MISSING_EXPORT.to_string(), SLOT_WASM_WIDGET.to_string(), 16).with_allow_downgrade(true);
4460 let res: String = format!("Blocked Missing Export -> {:?}", m_f_exp.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4461 let _: bool = s_f_exp.set(res);
4462 }
4463 }
4464 EuvButton {
4465 label: "Infinite-Loop Fuel".to_string()
4466 tokens: tokens
4467 outline()
4468 sm()
4469 on_click: move |_: &UiEvent| {
4470 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_FUEL_BOMB.to_string(), SLOT_WASM_WIDGET.to_string(), 17).with_allow_downgrade(true);
4471 let res: String = format!("Terminated Runaway Loop -> {:?}", m_f_fuel.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4472 let _: bool = s_f_fuel.set(res);
4473 }
4474 }
4475 EuvButton {
4476 label: "Runtime Trap".to_string()
4477 tokens: tokens
4478 outline()
4479 sm()
4480 on_click: move |_: &UiEvent| {
4481 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_TRAP.to_string(), SLOT_WASM_WIDGET.to_string(), 18).with_allow_downgrade(true);
4482 let res: String = format!("Isolated Runtime Trap -> {:?}", m_f_trap.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4483 let _: bool = s_f_trap.set(res);
4484 }
4485 }
4486 EuvButton {
4487 label: "Oversized Binary".to_string()
4488 tokens: tokens
4489 outline()
4490 sm()
4491 on_click: move |_: &UiEvent| {
4492 let req: WasmDownloadRequest = WasmDownloadRequest::partial(URL_WASM_OVERSIZED.to_string(), SLOT_WASM_WIDGET.to_string(), 19).with_allow_downgrade(true);
4493 let res: String = format!("Blocked Oversized Binary -> {:?}", m_f_big.load_and_mount(req, WASM_SHOWCASE_SIGNING_KEY));
4494 let _: bool = s_f_big.set(res);
4495 }
4496 }
4497 EuvButton {
4498 label: "Cancel / Stale Guard".to_string()
4499 tokens: tokens
4500 outline()
4501 sm()
4502 on_click: move |_: &UiEvent| {
4503 let gen_id: u64 = m_f_cancel.cancel_scope(&WasmDynamicScope::Partial { slot_id: SLOT_WASM_WIDGET.to_string() });
4504 let _: bool = s_f_cancel.set(format!("Cancelled scope request cleanly (generation #{gen_id} blocks stale responses)"));
4505 }
4506 }
4507 }
4508 text {
4509 font_size: 12.5
4510 font_weight: FontWeight::Medium
4511 color: p.get_primary()
4512 { move || wasm_status_sig.get() }
4513 }
4514 }
4515 }
4516 EuvCard {
4517 title: DYNAMIC_COMP_CARD_TITLE.to_string()
4518 tokens: tokens
4519 subtitle: DYNAMIC_COMP_CARD_SUB
4520 column {
4521 gap: SPACE_MD
4522 EuvActionRow {
4523 EuvButton {
4524 label: BTN_INC_SIBLING.to_string()
4525 tokens: tokens
4526 outline()
4527 on_click: move |_: &UiEvent| {
4528 let _: bool = sibling_counter.update(|v: &mut i32| *v += 1);
4529 }
4530 }
4531 }
4532 text {
4533 font_size: 13.0
4534 font_weight: FontWeight::SemiBold
4535 color: p.get_primary()
4536 { move || format!("Sibling State Preserved: count={}", sibling_counter.get()) }
4537 }
4538 EuvActionRow {
4539 EuvButton {
4540 label: BTN_PUSH_BANNER_V1.to_string()
4541 tokens: tokens
4542 on_click: move |_: &UiEvent| {
4543 let next_v: u64 = hub_v1
4544 .component_version(SLOT_PROMO_BANNER)
4545 .saturating_add(1);
4546 let mut badge: DynamicNodeSpec =
4547 DynamicNodeSpec::badge(format!("OTA v{next_v}"));
4548 badge
4549 .get_mut_style()
4550 .set_background_hex(Some(0x1D4ED8))
4551 .set_color_hex(Some(0xFFFFFF));
4552 let mut title: DynamicNodeSpec = DynamicNodeSpec::text(format!(
4553 "Dynamic JSON Banner v{next_v}: Surgical Component Patch"
4554 ));
4555 title
4556 .get_mut_style()
4557 .set_bold(true)
4558 .set_color_hex(Some(0x1E3A8A));
4559 let mut offer_btn: DynamicNodeSpec = DynamicNodeSpec::button(
4560 BTN_CLAIM_OFFER.to_string(),
4561 "claim_offer".to_string(),
4562 );
4563 offer_btn.set_payload(format!("json-v{next_v}"));
4564 let mut box_spec: DynamicNodeSpec = DynamicNodeSpec::row()
4565 .child(badge)
4566 .child(title)
4567 .child(offer_btn);
4568 box_spec
4569 .get_mut_style()
4570 .set_full_width(true)
4571 .set_padding(Some(12.0))
4572 .set_radius(Some(8.0))
4573 .set_background_hex(Some(0xEFF6FF))
4574 .set_border_width(Some(1.0))
4575 .set_border_hex(Some(0x93C5FD));
4576 let mut upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
4577 SLOT_PROMO_BANNER.to_string(),
4578 next_v,
4579 box_spec,
4580 );
4581 upd.sign();
4582 if let Ok(json) = upd.to_json() {
4583 let _: Result<u64, DynamicUpdateError> = hub_v1.apply_component_json(&json);
4584 }
4585 }
4586 }
4587 EuvButton {
4588 label: BTN_PUSH_BANNER_V2.to_string()
4589 tokens: tokens
4590 secondary()
4591 on_click: move |_: &UiEvent| {
4592 let next_v: u64 = hub_v2.component_version(SLOT_PROMO_BANNER).saturating_add(1).max(2);
4593 let hub_act: DynamicUpdateHub = hub_v2.clone();
4594 let _: Result<u64, DynamicUpdateError> = hub_v2.swap_component_builder(
4595 SLOT_PROMO_BANNER.to_string(),
4596 next_v,
4597 move || {
4598 let hub_click: DynamicUpdateHub = hub_act.clone();
4599 view! {
4600 row {
4601 width: Length::Percent(100.0)
4602 flex_wrap: FlexWrap::Wrap
4603 padding: Edges::all(SPACE_MD)
4604 gap: SPACE_MD
4605 align: AlignItems::Center
4606 background: Color::hex(0x064E3B)
4607 radius: 8.0
4608 text {
4609 font_size: 14.0
4610 font_weight: FontWeight::Bold
4611 color: Color::hex(0xECFDF5)
4612 { format!("Native Hot-Swapped Banner v{next_v} (Zero Restart)") }
4613 }
4614 EuvButton {
4615 label: BTN_CLAIM_OFFER.to_string()
4616 tokens: tokens
4617 on_click: move |_: &UiEvent| {
4618 hub_click.dispatch_action(DynamicActionEvent::new(
4619 SLOT_PROMO_BANNER.to_string(),
4620 "claim_offer".to_string(),
4621 format!("native-v{next_v}"),
4622 ));
4623 }
4624 }
4625 }
4626 }
4627 },
4628 );
4629 }
4630 }
4631 EuvButton {
4632 label: BTN_ROLLBACK_BANNER.to_string()
4633 tokens: tokens
4634 outline()
4635 on_click: move |_: &UiEvent| {
4636 let _: Result<u64, DynamicUpdateError> = hub_rb.rollback_component(SLOT_PROMO_BANNER);
4637 }
4638 }
4639 }
4640 slot {
4641 id: SLOT_PROMO_BANNER
4642 row {
4643 width: Length::Percent(100.0)
4644 padding: Edges::all(SPACE_MD)
4645 background: p.get_muted()
4646 border: (g.get_border_width(), p.get_border())
4647 radius: g.get_radius_md()
4648 text {
4649 font_size: 13.0
4650 color: p.get_foreground()
4651 "Compiled Fallback Banner (v0) — click a button above to hot-update only this component."
4652 }
4653 }
4654 }
4655 EuvActionRow {
4656 EuvButton {
4657 label: BTN_PATCH_METRICS.to_string()
4658 tokens: tokens
4659 on_click: move |_: &UiEvent| {
4660 let next_v: u64 = hub_m1.component_version(SLOT_METRICS_WIDGET).saturating_add(1);
4661 let mut card_spec: DynamicNodeSpec = DynamicNodeSpec::card(format!("Live Metrics Widget v{next_v}"))
4662 .child(DynamicNodeSpec::text(format!("Updated independently without touching promo_banner or sibling state (rev {next_v}).")));
4663 card_spec
4664 .get_mut_style()
4665 .set_background_hex(Some(0xFEFCE8))
4666 .set_border_width(Some(1.0))
4667 .set_border_hex(Some(0xFACC15));
4668 let mut upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
4669 SLOT_METRICS_WIDGET.to_string(),
4670 next_v,
4671 card_spec,
4672 );
4673 upd.sign();
4674 let _: Result<u64, DynamicUpdateError> = hub_m1.apply_component(upd);
4675 }
4676 }
4677 EuvButton {
4678 label: BTN_ROLLBACK_METRICS.to_string()
4679 tokens: tokens
4680 outline()
4681 on_click: move |_: &UiEvent| {
4682 let _: Result<u64, DynamicUpdateError> =
4683 hub_mrb.rollback_component(SLOT_METRICS_WIDGET);
4684 }
4685 }
4686 }
4687 slot {
4688 id: SLOT_METRICS_WIDGET
4689 row {
4690 width: Length::Percent(100.0)
4691 padding: Edges::all(SPACE_MD)
4692 background: p.get_muted()
4693 border: (g.get_border_width(), p.get_border())
4694 radius: g.get_radius_md()
4695 text {
4696 font_size: 13.0
4697 color: p.get_muted_foreground()
4698 "Compiled Fallback Metrics Widget (v0) — independent surgical slot."
4699 }
4700 }
4701 }
4702 }
4703 }
4704 EuvCard {
4705 title: DYNAMIC_PAGE_CARD_TITLE.to_string()
4706 tokens: tokens
4707 subtitle: DYNAMIC_PAGE_CARD_SUB
4708 column {
4709 gap: SPACE_MD
4710 EuvActionRow {
4711 EuvButton {
4712 label: BTN_UPDATE_PAGE_V1.to_string()
4713 tokens: tokens
4714 on_click: move |_: &UiEvent| {
4715 let next_v: u64 = hub_p1.page_version(ROUTE_DYNAMIC_PANEL).saturating_add(1);
4716 let spec: DynamicNodeSpec = DynamicNodeSpec::card(format!(
4717 "Hot-Updated Dynamic Page Panel v{next_v}"
4718 ))
4719 .child(DynamicNodeSpec::badge(format!("Page Revision v{next_v}")))
4720 .child(DynamicNodeSpec::text(
4721 "Page-level layout replaced live without restarting the application."
4722 .to_string(),
4723 ));
4724 let mut upd: DynamicPageUpdate = DynamicPageUpdate::new(
4725 ROUTE_DYNAMIC_PANEL.to_string(),
4726 format!("Dynamic Panel v{next_v}"),
4727 next_v,
4728 spec,
4729 );
4730 upd.sign();
4731 let _: Result<u64, DynamicUpdateError> = hub_p1.apply_page(upd);
4732 }
4733 }
4734 EuvButton {
4735 label: BTN_APPLY_BUNDLE.to_string()
4736 tokens: tokens
4737 secondary()
4738 on_click: move |_: &UiEvent| {
4739 let next_comp_v: u64 = hub_bundle
4740 .component_version(SLOT_METRICS_WIDGET)
4741 .saturating_add(1);
4742 let next_page_v: u64 = hub_bundle
4743 .page_version(ROUTE_DYNAMIC_PANEL)
4744 .saturating_add(1);
4745 let mut comp_upd: DynamicComponentUpdate = DynamicComponentUpdate::new(
4746 SLOT_METRICS_WIDGET.to_string(),
4747 next_comp_v,
4748 DynamicNodeSpec::card(format!("Atomic Bundle Metrics v{next_comp_v}")).child(
4749 DynamicNodeSpec::text(
4750 "Committed together with page panel inside one atomic transaction."
4751 .to_string(),
4752 ),
4753 ),
4754 );
4755 comp_upd.sign();
4756 let mut page_upd: DynamicPageUpdate = DynamicPageUpdate::new(
4757 ROUTE_DYNAMIC_PANEL.to_string(),
4758 format!("Atomic Panel v{next_page_v}"),
4759 next_page_v,
4760 DynamicNodeSpec::card(format!("Atomic Bundle Page Panel v{next_page_v}")).child(
4761 DynamicNodeSpec::text(
4762 "Both component slot and page slot updated atomically via signed JSON."
4763 .to_string(),
4764 ),
4765 ),
4766 );
4767 page_upd.sign();
4768 let bundle: DynamicUpdateBundle =
4769 DynamicUpdateBundle::new("ota-atomic-bundle".to_string(), next_page_v)
4770 .push_component(comp_upd)
4771 .push_page(page_upd);
4772 if let Ok(json) = bundle.to_json() {
4773 let _: Result<DynamicTelemetry, DynamicUpdateError> =
4774 hub_bundle.apply_bundle_json(&json);
4775 }
4776 }
4777 }
4778 EuvButton {
4779 label: BTN_ROLLBACK_PAGE.to_string()
4780 tokens: tokens
4781 outline()
4782 on_click: move |_: &UiEvent| {
4783 let _: Result<u64, DynamicUpdateError> = hub_prb.rollback_page(ROUTE_DYNAMIC_PANEL);
4784 }
4785 }
4786 EuvButton {
4787 label: BTN_INJECT_ROUTE.to_string()
4788 tokens: tokens
4789 secondary()
4790 on_click: move |_: &UiEvent| {
4791 let next_v: u64 = hub_inject.page_version(ROUTE_PROMO_LIVE).saturating_add(1);
4792 let mut back_btn: DynamicNodeSpec = DynamicNodeSpec::button(
4793 BTN_RETURN_DYNAMIC.to_string(),
4794 "return_dynamic".to_string(),
4795 );
4796 back_btn.set_payload(format!("from-promo-v{next_v}"));
4797 let page_spec: DynamicNodeSpec = DynamicNodeSpec::column().child(
4798 DynamicNodeSpec::card(format!("Runtime-Injected Page /promo-live (v{next_v})"))
4799 .child(DynamicNodeSpec::badge("Zero Recompile Route".to_string()))
4800 .child(DynamicNodeSpec::text(
4801 "This entire route was injected dynamically at runtime via signed JSON manifest."
4802 .to_string(),
4803 ))
4804 .child(back_btn),
4805 );
4806 let mut upd: DynamicPageUpdate = DynamicPageUpdate::new(
4807 ROUTE_PROMO_LIVE.to_string(),
4808 "Flash Promo (OTA)".to_string(),
4809 next_v,
4810 page_spec,
4811 );
4812 upd.sign();
4813 if let Ok(json) = upd.to_json()
4814 && hub_inject.apply_page_json(&json).is_ok()
4815 {
4816 let _: bool = route_sig.set_if_changed(ROUTE_PROMO_LIVE.to_string());
4817 }
4818 }
4819 }
4820 }
4821 page_slot {
4822 route: ROUTE_DYNAMIC_PANEL
4823 column {
4824 width: Length::Percent(100.0)
4825 padding: Edges::all(SPACE_MD)
4826 background: p.get_muted()
4827 border: (g.get_border_width(), p.get_border())
4828 radius: g.get_radius_md()
4829 text {
4830 font_size: 13.0
4831 color: p.get_foreground()
4832 "Compiled Fallback Page Panel (v0) — click Hot-Update Page or Apply Atomic Bundle."
4833 }
4834 }
4835 }
4836 text {
4837 font_size: 12.0
4838 color: p.get_muted_foreground()
4839 { move || {
4840 let _: u64 = banner_rev.get();
4841 let _: u64 = metrics_rev.get();
4842 let _: u64 = panel_rev.get();
4843 let tel: DynamicTelemetry = tel_sig.get();
4844 format!(
4845 "Versions: banner=v{} metrics=v{} panel=v{} | Applied: comp={} page={} rollbacks={} rejected={} | Last Action: {}",
4846 hub_for_status.component_version(SLOT_PROMO_BANNER),
4847 hub_for_status.component_version(SLOT_METRICS_WIDGET),
4848 hub_for_status.page_version(ROUTE_DYNAMIC_PANEL),
4849 tel.get_components_applied(),
4850 tel.get_pages_applied(),
4851 tel.get_rollbacks(),
4852 tel.get_rejected(),
4853 action_log.get(),
4854 )
4855 } }
4856 }
4857 }
4858 }
4859 }
4860 }
4861}
4862
4863pub fn mount_media_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
4874 state.ensure_media_loaded();
4875 let p: ThemePalette = tokens.get_palette();
4876 let link_log: Signal<String> = state.get_media_html_link_log();
4877 let link_log_cb: Signal<String> = link_log;
4878 let photo_card: NodeId = view! {
4879 EuvImage {
4880 asset: ImageAsset::sample_photo("Hero Raster Photo (PNG/BMP/WebP)")
4881 tokens: tokens
4882 height: 148.0
4883 }
4884 };
4885 let svg_card: NodeId = view! {
4886 EuvSvgView {
4887 document: SvgDocument::sample_svg()
4888 label: "Vector SVG Badge".to_string()
4889 tokens: tokens
4890 }
4891 };
4892 let gif_card: NodeId = view! {
4893 EuvGifPlayer {
4894 state: state.get_media_gif()
4895 tokens: tokens
4896 }
4897 };
4898 let live_card: NodeId = view! {
4899 EuvLivePhoto {
4900 state: state.get_media_live()
4901 tokens: tokens
4902 }
4903 };
4904 let video_card: NodeId = view! {
4905 EuvVideoPlayer {
4906 state: state.get_media_video()
4907 tokens: tokens
4908 }
4909 };
4910 let audio_card: NodeId = view! {
4911 EuvAudioPlayer {
4912 state: state.get_media_audio()
4913 tokens: tokens
4914 }
4915 };
4916 let pdf_card: NodeId = view! {
4917 EuvPdfViewer {
4918 state: state.get_media_pdf()
4919 tokens: tokens
4920 }
4921 };
4922 let html_card: NodeId = view! {
4923 EuvHtmlView {
4924 document: HtmlDocument::sample_html()
4925 tokens: tokens
4926 on_link: move |href: String| {
4927 let _: bool = link_log_cb.set_if_changed(format!("Opened native link: {href}"));
4928 }
4929 }
4930 };
4931 view! {
4932 EuvPage {
4933 title: "Full Cross-Platform Media Studio".to_string()
4934 subtitle: "Pure-Rust aspect-preserving Image, SVG, animated GIF, LIVE Photo, Video, WAV Audio waveform, multi-page PDF, and sanitized zero-JS HTML5.".to_string()
4935 tokens: tokens
4936 { mount_bento_pair(photo_card, svg_card) }
4937 { mount_bento_pair(gif_card, live_card) }
4938 { mount_bento_pair(video_card, audio_card) }
4939 { mount_bento_pair(pdf_card, html_card) }
4940 text {
4941 font_size: 12.5
4942 color: p.get_muted_foreground()
4943 { move || link_log.get() }
4944 }
4945 }
4946 }
4947}
4948
4949fn mount_bento_pair(left: NodeId, right: NodeId) -> NodeId {
4960 let bp_sig: Signal<Breakpoint> = use_breakpoint();
4961 view! {
4962 grid {
4963 bind_style: move || {
4964 let cols: u16 = if bp_sig.get() == Breakpoint::Expanded { 2 } else { 1 };
4965 Style::default()
4966 .grid(cols)
4967 .width(Length::Percent(100.0))
4968 .gap(SPACE_MD)
4969 }
4970 { left }
4971 { right }
4972 }
4973 }
4974}