62 lines
1.0 KiB
Rust
62 lines
1.0 KiB
Rust
use iced::Container;
|
|
use iced::Row;
|
|
use iced::Element;
|
|
use iced::Sandbox;
|
|
use iced::Length;
|
|
|
|
mod lyrics;
|
|
mod styles;
|
|
|
|
use styles::Theme;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct DelyriumApp {
|
|
lyrics_component: lyrics::Lyrics,
|
|
theme: Theme,
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub enum Message {
|
|
LyricChanged {
|
|
line_no: usize,
|
|
new_value: String,
|
|
},
|
|
LineAdvanced(usize),
|
|
}
|
|
|
|
impl Sandbox for DelyriumApp {
|
|
type Message = Message;
|
|
|
|
fn new() -> Self {
|
|
DelyriumApp {
|
|
lyrics_component: lyrics::Lyrics::new(),
|
|
theme: Theme::default(),
|
|
}
|
|
}
|
|
|
|
fn title(&self) -> String {
|
|
String::from("Delyrium")
|
|
}
|
|
|
|
fn update(&mut self, message: Message) {
|
|
match message {
|
|
Message::LyricChanged { line_no, new_value } => {
|
|
self.lyrics_component.update_line(new_value, line_no);
|
|
},
|
|
Message::LineAdvanced(current_line) => {
|
|
self.lyrics_component.advance_line(current_line);
|
|
}
|
|
}
|
|
}
|
|
|
|
fn view(&mut self) -> Element<Message> {
|
|
Container::new(
|
|
Row::new()
|
|
.push(self.lyrics_component.view())
|
|
)
|
|
.style(self.theme)
|
|
.height(Length::Fill)
|
|
.into()
|
|
}
|
|
}
|