use crate::battery::ChargerState;
use crate::battery::StateOfCharge;
use crate::styled::Styled;
use crate::time::Time;
#[derive(Default)]
pub struct Watchface {
pub time: Option<Time>,
pub charger: Option<ChargerState>,
pub battery: Option<StateOfCharge>,
}
impl Watchface {
pub fn build() -> WatchfaceBuilder {
WatchfaceBuilder::default()
}
pub fn into_styled<T>(self, style: T) -> Styled<Watchface, T> {
Styled::new(self, style)
}
}
#[derive(Default)]
pub struct WatchfaceBuilder {
watchface: Watchface,
}
impl WatchfaceBuilder {
pub fn with_time<T: Into<Time>>(mut self, time: T) -> Self {
self.watchface.time = Some(time.into());
self
}
pub fn with_charger<T: Into<ChargerState>>(mut self, charger: T) -> Self {
self.watchface.charger = Some(charger.into());
self
}
pub fn with_battery<T: Into<StateOfCharge>>(mut self, battery: T) -> Self {
self.watchface.battery = Some(battery.into());
self
}
pub fn finish(self) -> Watchface {
self.watchface
}
pub fn into_styled<T>(self, style: T) -> Styled<Watchface, T> {
self.watchface.into_styled(style)
}
}