pub(crate) mod serial;
use crate::{ Border, Color, Theme };
use iced_native::{
widget::{
container::{
Appearance, StyleSheet
},
},
};
#[derive(Clone, Copy, Debug)]
pub struct Container {
pub color: Color,
pub border: Border,
}
impl Container {
pub(crate) fn create(serial: &serial::Container, theme: &Theme) -> Result<Self, ()> {
let color = match theme.color.get(&serial.color) {
Some(color) => *color,
_ => return Err(()),
};
let border = match theme.border.get(&serial.border) {
Some(border) => *border,
_ => return Err(()),
};
Ok( Container { color, border } )
}
}
impl StyleSheet for Container {
type Style = iced::Theme;
fn appearance(&self, _: &Self::Style) -> Appearance {
Appearance {
text_color: None,
background: Some( self.color.into() ),
border_radius: self.border.radius,
border_width: self.border.width,
border_color: self.border.color.into(),
}
}
}