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