theme_selector.rs

 1use std::marker::PhantomData;
 2
 3use crate::prelude::*;
 4use crate::{OrderMethod, Palette, PaletteItem};
 5
 6#[derive(Element)]
 7pub struct ThemeSelector<S: 'static + Send + Sync + Clone> {
 8    state_type: PhantomData<S>,
 9    scroll_state: ScrollState,
10}
11
12impl<S: 'static + Send + Sync + Clone> ThemeSelector<S> {
13    pub fn new() -> Self {
14        Self {
15            state_type: PhantomData,
16            scroll_state: ScrollState::default(),
17        }
18    }
19
20    fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
21        div().child(
22            Palette::new(self.scroll_state.clone())
23                .items(vec![
24                    PaletteItem::new("One Dark"),
25                    PaletteItem::new("Rosé Pine"),
26                    PaletteItem::new("Rosé Pine Moon"),
27                    PaletteItem::new("Sandcastle"),
28                    PaletteItem::new("Solarized Dark"),
29                    PaletteItem::new("Summercamp"),
30                    PaletteItem::new("Atelier Cave Light"),
31                    PaletteItem::new("Atelier Dune Light"),
32                    PaletteItem::new("Atelier Estuary Light"),
33                    PaletteItem::new("Atelier Forest Light"),
34                    PaletteItem::new("Atelier Heath Light"),
35                ])
36                .placeholder("Select Theme...")
37                .empty_string("No matches")
38                .default_order(OrderMethod::Ascending),
39        )
40    }
41}