Initial work commit. Includes welcome and license stages prototypes.

This commit is contained in:
2026-04-16 00:29:43 +02:00
parent f98966a83a
commit 825ea5225b
115 changed files with 6521 additions and 0 deletions
+120
View File
@@ -0,0 +1,120 @@
use iced::widget;
use iced::Alignment;
use std::collections::{HashMap};
use iced::{Element, Task, Theme};
use crate::stage::{StageAction, KiraConfig};
use crate::stages::license;
use crate::stages::welcome;
use crate::stages::welcome::WelcomeStage;
rust_i18n::i18n!("src/locales", fallback = "en");
mod stage;
mod stages;
enum Views {
Start,
Welcome(welcome::WelcomeStage),
License(license::LicenseStage),
}
enum Message {
Welcome(welcome::Message),
License(license::Message)
}
struct KiraState {
current_view: Views,
toml_config: toml::Table,
config: KiraConfig,
}
impl KiraState {
fn new(toml_config: toml::Table) -> Self {
Self {
current_view: Views::Start,
toml_config: toml_config,
config: KiraConfig { config_trail: Vec::new() }
}
}
}
fn view(k_state: &KiraState) -> Element<'_, Message> {
match &k_state.current_view {
Views::Start => Element::new(widget::space()) ,
Views::Welcome(wellcome_stage) => wellcome_stage.view().map(Message::Welcome),
Views::License(license_stage) => license_stage.view().map(Message::License),
}
}
fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
match message {
Message::Welcome(wlc_msg) => {
if let Views::Welcome(wlc_view) = &mut k_state.current_view {
let action = wlc_view.update(wlc_msg);
if let StageAction::Next(welcome_res) = action {
k_state.config.config_trail.push(welcome_res);
k_state.current_view = Views::License(license::LicenseStage{});
}
}
Task::none()
},
Message::License(license_message) => {
if let Views::License(license_view) = &mut k_state.current_view {
let action = license_view.update(license_message);
match action {
StageAction::Next(license_res) => {
k_state.config.config_trail.push(license_res);
iced::exit()
},
StageAction::Abort(_) => iced::exit(),
StageAction::Back => iced::exit(),
StageAction::None => Task::none()
}
}
else {
Task::none()
}
}
}
}
// pub fn main_interface() -> iced::Result {
// iced::run(WellcomeStage::update, WellcomeStage::view)
// }
pub fn main() -> iced::Result {
let app_init = || {
let mut k_state = KiraState::new(toml::Table::new());
k_state.current_view = Views::Welcome(WelcomeStage::new());
k_state
};
iced::application(app_init, update, view)
.centered()
.run()
}
// fn main() {
// println!("Hello, world!");
// println!("{}", t!("wellcome.text"));
// // Initialize the state
// let _res = main_interface();
// }