I want to set a background color to my app and set some colors.
Right now, I have a module theme and widget to handle this:
use iced::{application, color};
#[derive(Debug, Clone, Copy, Default)]
pub struct Theme;
impl application::StyleSheet for Theme {
type Style = ();
fn appearance(&self, style: &Self::Style) -> application::Appearance {
application::Appearance {
background_color: color![0x45, 0x85, 0x88],
text_color: color![0x45, 0x85, 0x88],
}
}
}
// Always import widget types from this module since it
// uses our custom theme instead of the built-in iced::Theme.
// Otherwise you will get compilation errors since iced::Element
// expects use of iced::Theme by default.
pub mod widget {
#![allow(dead_code)]
use crate::theme::Theme;
pub type Renderer = iced::Renderer<Theme>;
pub type Element<'a, Message> = iced::Element<'a, Message, Renderer>;
pub type Container<'a, Message> = iced::widget::Container<'a, Message, Renderer>;
pub type Button<'a, Message> = iced::widget::Button<'a, Message, Renderer>;
pub type Column<'a, Message> = iced::widget::Column<'a, Message, Renderer>;
pub type Row<'a, Message> = iced::widget::Row<'a, Message, Renderer>;
}
But I get error, and I want to know if there is a better way to do this, because it's not very practical to rewrite all types, even those which don't have custom theme.