Add a basic framework for applying styles
This commit is contained in:
parent
558b32ae28
commit
a62702acdc
|
@ -2,12 +2,17 @@ use iced::Container;
|
||||||
use iced::Row;
|
use iced::Row;
|
||||||
use iced::Element;
|
use iced::Element;
|
||||||
use iced::Sandbox;
|
use iced::Sandbox;
|
||||||
|
use iced::Length;
|
||||||
|
|
||||||
mod lyrics;
|
mod lyrics;
|
||||||
|
mod styles;
|
||||||
|
|
||||||
|
use styles::Theme;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct DelyriumApp {
|
pub struct DelyriumApp {
|
||||||
lyrics_component: lyrics::Lyrics,
|
lyrics_component: lyrics::Lyrics,
|
||||||
|
theme: Theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -24,6 +29,7 @@ impl Sandbox for DelyriumApp {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
DelyriumApp {
|
DelyriumApp {
|
||||||
lyrics_component: lyrics::Lyrics::new(),
|
lyrics_component: lyrics::Lyrics::new(),
|
||||||
|
theme: Theme::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +46,8 @@ impl Sandbox for DelyriumApp {
|
||||||
Row::new()
|
Row::new()
|
||||||
.push(self.lyrics_component.view())
|
.push(self.lyrics_component.view())
|
||||||
)
|
)
|
||||||
|
.style(self.theme)
|
||||||
|
.height(Length::Fill)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
use iced::Background;
|
||||||
|
use iced::Color;
|
||||||
|
use iced::widget::container;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
pub struct Theme {
|
||||||
|
pub base_color: Color,
|
||||||
|
pub text_color: Color,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Theme {
|
||||||
|
fn default() -> Self {
|
||||||
|
Theme {
|
||||||
|
base_color: Color {r: 236. / 255., g: 63. / 255., b: 53. / 255., a: 1.},
|
||||||
|
text_color: Color {r: 1., g: 1., b: 1., a: 1.},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl container::StyleSheet for Theme {
|
||||||
|
fn style(&self) -> container::Style {
|
||||||
|
container::Style {
|
||||||
|
text_color: Some(self.text_color),
|
||||||
|
background: Some(Background::Color(self.base_color)),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,5 +5,5 @@ mod palette;
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
app::DelyriumApp::run(Settings::default());
|
app::DelyriumApp::run(Settings::default()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue