1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
| | // SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2025 Johannes Süllner <johannes.suellner@mailbox.org>
mod destination_device;
mod pages;
use iced::Element;
use iced::Size;
use iced::Subscription;
use iced::Task;
use pages::Event;
fn main() -> iced::Result {
iced::application(
SpectrumInstaller::new,
SpectrumInstaller::update,
SpectrumInstaller::view,
)
.subscription(SpectrumInstaller::subscription)
.font(iced_fonts::BOOTSTRAP_FONT_BYTES)
.title("Spectrum installer")
.window_size(Size::new(pages::WINDOW_WIDTH, pages::WINDOW_HEIGHT))
.resizable(false)
.run()
}
struct SpectrumInstaller {
current_page: Box<dyn pages::Page>,
}
impl SpectrumInstaller {
fn new() -> Self {
Self {
current_page: Box::new(pages::INITAL_PAGE),
}
}
fn update(&mut self, event: pages::Event) -> Task<Event> {
let (maybe_new_page, task) = self.current_page.update(event);
if let Some(new_page) = maybe_new_page {
self.current_page = new_page;
}
task
}
fn view(&self) -> Element<'_, pages::Event> {
self.current_page.view()
}
fn subscription(&self) -> Subscription<pages::Event> {
self.current_page.subscription()
}
}
|