diff options
| author | pml68 <contact@pml68.dev> | 2025-04-08 01:13:38 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-04-15 23:48:59 +0200 |
| commit | c6a76e63604b16b9a14d5de6bd0ea91eea7f9bf2 (patch) | |
| tree | a61216e02b04382df8f0a3219f6910e5828a5066 /src | |
| parent | fix: custom theme Default changing between calls, missing `apply_options`s (diff) | |
| download | iced-builder-c6a76e63604b16b9a14d5de6bd0ea91eea7f9bf2.tar.gz | |
feat(material_theme): implement Catalog for iced_dialog (`dialog` feature)
Diffstat (limited to '')
| -rw-r--r-- | src/main.rs | 17 | ||||
| -rw-r--r-- | src/panes/element_list.rs | 11 |
2 files changed, 13 insertions, 15 deletions
diff --git a/src/main.rs b/src/main.rs index 6ab4da9..3895dbc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,8 +31,7 @@ use iced_dialog::dialog::Dialog; use panes::{code_view, designer_view, element_list}; use tokio::runtime; use types::{ - Action, DesignerPane, DialogAction, DialogButtons, ElementName, Message, - Project, + Action, DesignerPane, DialogAction, DialogButtons, Message, Project, }; fn main() -> Result<(), Box<dyn std::error::Error>> { @@ -79,7 +78,6 @@ struct App { dialog_content: String, dialog_buttons: DialogButtons, dialog_action: DialogAction, - element_list: &'static [ElementName], editor_content: text_editor::Content, } @@ -132,7 +130,6 @@ impl App { dialog_content: String::new(), dialog_buttons: DialogButtons::None, dialog_action: DialogAction::None, - element_list: ElementName::ALL, editor_content: text_editor::Content::new(), }, task, @@ -408,9 +405,7 @@ impl App { code_view::view(&self.editor_content, is_focused) } }, - Panes::ElementList => { - element_list::view(self.element_list, is_focused) - } + Panes::ElementList => element_list::view(is_focused), } }, ) @@ -438,7 +433,13 @@ impl App { DialogButtons::OkCancel => vec![ok_button(), cancel_button()], }, ) - .title(self.dialog_title); + .title(self.dialog_title) + .container_style(|theme| container::Style { + background: Some( + theme.extended_palette().background.strong.color.into(), + ), + ..Default::default() + }); Animation::new(&self.theme, content) .on_update(Message::SwitchTheme) diff --git a/src/panes/element_list.rs b/src/panes/element_list.rs index 10eea66..594c203 100644 --- a/src/panes/element_list.rs +++ b/src/panes/element_list.rs @@ -5,13 +5,13 @@ use iced_drop::droppable; use super::style; use crate::types::{ElementName, Message}; -fn items_list_view(items: &[ElementName]) -> Element<'_, Message> { +fn items_list_view<'a>() -> Element<'a, Message> { let mut column = Column::new() .spacing(20) .align_x(Alignment::Center) .width(Length::Fill); - for item in items { + for item in ElementName::ALL { column = column.push( droppable(text(item.clone().to_string())).on_drop(|point, rect| { Message::DropNewElement(item.clone(), point, rect) @@ -25,11 +25,8 @@ fn items_list_view(items: &[ElementName]) -> Element<'_, Message> { .into() } -pub fn view( - element_list: &[ElementName], - is_focused: bool, -) -> pane_grid::Content<'_, Message> { - let items_list = items_list_view(element_list); +pub fn view<'a>(is_focused: bool) -> pane_grid::Content<'a, Message> { + let items_list = items_list_view(); let content = column![items_list] .align_x(Alignment::Center) .height(Length::Fill) |
