summaryrefslogtreecommitdiff
path: root/src/options.rs
blob: 5a3e1fbe618f024e868eea8b24964998e4e3a29e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::collections::BTreeMap;

use iced::Padding;
#[allow(unused_imports)]
use iced::widget::{Button, Column, Container, Image, Row, Svg, Text};

use crate::values::ValueFromStr;

pub trait ApplyOptions {
    fn apply_options(self, options: BTreeMap<String, Option<String>>) -> Self;
}

impl<Message> ApplyOptions for Button<'_, Message> {
    fn apply_options(self, options: BTreeMap<String, Option<String>>) -> Self {
        let mut button = self;

        if let Some(padding) = options.get("padding").expect("padding key") {
            let padding: Padding = Padding::value_from_str(padding).unwrap();
            button = button.padding(padding);
        }

        button
    }
}