MCPcopy Create free account
hub / github.com/Moosync/Moosync / ThemesPref

Function ThemesPref

src/components/prefs/components.rs:400–513  ·  view source on GitHub ↗
(
    #[prop()] key: String,
    #[prop()] title: K,
    #[prop()] tooltip: K1,
)

Source from the content-addressed store, hash-verified

398#[tracing::instrument(level = "debug", skip(key, title, tooltip))]
399#[component]
400pub fn ThemesPref<K, H, K1, H1>(
401 #[prop()] key: String,
402 #[prop()] title: K,
403 #[prop()] tooltip: K1,
404) -> impl IntoView
405where
406 K: Fn() -> H + Send + Sync + 'static,
407 H: IntoView + Copy + 'static,
408 K1: Fn() -> H1 + Send + Sync + 'static,
409 H1: IntoView + Copy + 'static,
410{
411 let all_themes: RwSignal<HashMap<String, ThemeDetails>> = RwSignal::new(Default::default());
412 let load_themes = move || {
413 spawn_local(async move {
414 let themes = load_all_themes().await.unwrap();
415 all_themes.set(themes);
416 })
417 };
418 load_themes();
419 let active_themes = RwSignal::new(vec![]);
420 let active_theme_id = RwSignal::new(String::new());
421 load_selective(key, active_theme_id);
422
423 let context_menu = create_context_menu(ThemesContextMenu {
424 id: None,
425 refresh_cb: Arc::new(Box::new(load_themes)),
426 });
427
428 let modal_store: RwSignal<ModalStore> = expect_context();
429 let render_themes = move || {
430 let mut views = vec![];
431 let active_theme_id = active_theme_id.get();
432 for (key, theme) in all_themes.get() {
433 let signal = RwSignal::new(key == active_theme_id);
434 active_themes.update(|at| at.push(signal));
435 let context_menu = context_menu.clone();
436 let key_clone = key.clone();
437 views.push(
438 view! {
439 <div class="col-xl-3 col-5 p-2">
440 <div
441 class="theme-component-container"
442 on:contextmenu=move |ev| {
443 ev.prevent_default();
444 let context_menu = context_menu.clone();
445 let mut data = context_menu.get_data();
446 data.id = Some(key_clone.clone());
447 drop(data);
448 context_menu.show(ev);
449 }
450 on:click=move |_| {
451 active_themes
452 .update(|at| {
453 for s in at.iter() {
454 s.set(false);
455 }
456 signal.set(true);
457 });

Callers

nothing calls this directly

Calls 5

load_selectiveFunction · 0.85
create_context_menuFunction · 0.85
setMethod · 0.80
getMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected