theme_selector.rs

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