deLyrium/src/app/mod.rs

54 lines
844 B
Rust
Raw Normal View History

2021-12-30 22:32:52 +00:00
use iced::Container;
use iced::Row;
use iced::Element;
use iced::Sandbox;
use iced::Length;
2021-12-30 22:32:52 +00:00
mod lyrics;
mod styles;
use styles::Theme;
2021-12-30 22:32:52 +00:00
#[derive(Clone, Debug)]
pub struct DelyriumApp {
lyrics_component: lyrics::Lyrics,
theme: Theme,
2021-12-30 22:32:52 +00:00
}
#[derive(Clone, Debug)]
pub enum Message {
LyricChanged {
line_no: usize,
new_value: String,
},
}
impl Sandbox for DelyriumApp {
type Message = Message;
fn new() -> Self {
DelyriumApp {
lyrics_component: lyrics::Lyrics::new(),
theme: Theme::default(),
2021-12-30 22:32:52 +00:00
}
}
fn title(&self) -> String {
String::from("Delyrium")
}
fn update(&mut self, message: Message) {
self.lyrics_component.update(&message);
}
fn view(&mut self) -> Element<Message> {
Container::new(
Row::new()
.push(self.lyrics_component.view())
)
.style(self.theme)
.height(Length::Fill)
2021-12-30 22:32:52 +00:00
.into()
}
}