use std::collections::BTreeMap; #[allow(unused_imports)] use iced::widget::{Button, Column, Container, Image, Row, Svg, Text}; use iced::{Padding, Rotation}; use crate::values::Value; pub trait ApplyOptions { fn apply_options(self, options: BTreeMap>) -> Self; } impl ApplyOptions for Button<'_, Message> { fn apply_options(self, options: BTreeMap>) -> Self { let mut button = self; if let Some(padding) = options.get("padding").expect("padding key") { let padding = Padding::from_str(padding).unwrap(); button = button.padding(padding); } button } } impl ApplyOptions for Column<'_, Message> { fn apply_options(self, options: BTreeMap>) -> Self { let mut column = self; if let Some(padding) = options.get("padding").expect("padding key") { let padding = Padding::from_str(padding).unwrap(); column = column.padding(padding); } column } } impl ApplyOptions for Row<'_, Message> { fn apply_options(self, options: BTreeMap>) -> Self { let mut row = self; if let Some(padding) = options.get("padding").expect("padding key") { let padding = Padding::from_str(padding).unwrap(); row = row.padding(padding); } row } } impl ApplyOptions for Image { fn apply_options(self, options: BTreeMap>) -> Self { let mut image = self; if let Some(rotation) = options.get("rotation").expect("rotation key") { let rotation = Rotation::from_str(rotation).unwrap(); image = image.rotation(rotation); } image } } impl ApplyOptions for Svg<'_> { fn apply_options(self, options: BTreeMap>) -> Self { let mut svg = self; if let Some(rotation) = options.get("rotation").expect("rotation key") { let rotation = Rotation::from_str(rotation).unwrap(); svg = svg.rotation(rotation); } svg } }