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