use iced::widget::pick_list;
use iced::{Element, Length};
use crate::message::Message;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ThemeChoice {
pub index: usize,
pub name: &'static str,
}
impl std::fmt::Display for ThemeChoice {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.name)
}
}
pub fn all_themes() -> Vec<ThemeChoice> {
gitkraft_core::THEME_NAMES
.iter()
.enumerate()
.map(|(i, name)| ThemeChoice { index: i, name })
.collect()
}
pub fn theme_selector(current_theme_index: usize) -> Element<'static, Message> {
let choices = all_themes();
let selected = choices.get(current_theme_index).cloned();
pick_list(choices, selected, |choice| {
Message::ThemeChanged(choice.index)
})
.placeholder("Select theme")
.text_size(13.0)
.width(Length::Fixed(180.0))
.into()
}