koibumi 0.0.10

An experimental Bitmessage client
use iced::{widget::button, Background, Color, Vector};

pub enum StartButton {
    Start,
    Stop,
    Abort,
}

impl button::StyleSheet for StartButton {
    type Style = iced::Theme;

    fn active(&self, _style: &Self::Style) -> button::Appearance {
        button::Appearance {
            background: Some(Background::Color(match self {
                Self::Start => Color::from_rgb(0.11, 0.42, 0.87),
                Self::Stop => Color::from_rgb(0.8, 0.2, 0.2),
                Self::Abort => Color::from_rgb(0.5, 0.5, 0.5),
            })),
            border_radius: 8.0.into(),
            shadow_offset: Vector::new(1.0, 1.0),
            text_color: Color::WHITE,
            ..button::Appearance::default()
        }
    }
}

pub struct TabButton {
    selected: bool,
}

impl TabButton {
    pub fn new(selected: bool) -> Self {
        Self { selected }
    }
}

impl button::StyleSheet for TabButton {
    type Style = iced::Theme;

    fn active(&self, _style: &Self::Style) -> button::Appearance {
        if self.selected {
            button::Appearance {
                background: Some(Background::Color(Color::from_rgb(0.2, 0.2, 0.7))),
                border_radius: 4.0.into(),
                text_color: Color::WHITE,
                ..button::Appearance::default()
            }
        } else {
            button::Appearance::default()
        }
    }
}

pub enum MessageEntryButton {
    Unread,
    Read,
    Selected,
}

impl button::StyleSheet for MessageEntryButton {
    type Style = iced::Theme;

    fn active(&self, _style: &Self::Style) -> button::Appearance {
        match self {
            Self::Unread => button::Appearance {
                background: Some(Background::Color(Color::from_rgb(1.0, 1.0, 0.0))),
                ..button::Appearance::default()
            },
            Self::Read => button::Appearance::default(),
            Self::Selected => button::Appearance {
                background: Some(Background::Color(Color::from_rgb(0.0, 0.75, 0.0))),
                text_color: Color::WHITE,
                ..button::Appearance::default()
            },
        }
    }
}

pub enum SendButton {
    Enabled,
    Disabled,
}

impl button::StyleSheet for SendButton {
    type Style = iced::Theme;

    fn active(&self, _style: &Self::Style) -> button::Appearance {
        button::Appearance {
            background: Some(Background::Color(match self {
                Self::Enabled => Color::from_rgb(0.9, 0.5, 0.3),
                Self::Disabled => Color::from_rgb(0.5, 0.5, 0.5),
            })),
            border_radius: 8.0.into(),
            shadow_offset: Vector::new(1.0, 1.0),
            text_color: Color::WHITE,
            ..button::Appearance::default()
        }
    }
}

pub enum AddressButton {
    Normal,
    Selected,
}

impl button::StyleSheet for AddressButton {
    type Style = iced::Theme;

    fn active(&self, _style: &Self::Style) -> button::Appearance {
        match self {
            Self::Normal => button::Appearance::default(),
            Self::Selected => button::Appearance {
                background: Some(Background::Color(Color::from_rgb(0.0, 0.75, 0.0))),
                text_color: Color::WHITE,
                ..button::Appearance::default()
            },
        }
    }
}