Small fixes and cleanups.

This commit is contained in:
2026-05-01 23:32:25 +02:00
parent bc46f042dc
commit b8c2630d3e
8 changed files with 46 additions and 41 deletions
+5
View File
@@ -1,3 +1,8 @@
# kira-installer # kira-installer
Universal GNU Linux installer. Universal GNU Linux installer.
It supposed to be simple, self contained, and reqire only minimal base system.
In order to test you need to have kira_config.toml in the same directory as executable file.
In order to make debug biuld just run ```cargo build```
+13 -13
View File
@@ -19,13 +19,13 @@
Modify it to your liking. Modify it to your liking.
*/ */
use iced::widget::container; use iced::{Color, Theme, color};
use iced::{Border, Color, Theme, color, Background};
// Function returns theme to be used by installer // Function returns theme to be used by installer
pub fn main_theme() -> Theme { pub fn main_theme() -> Theme {
let mut pl = Theme::Dracula.palette(); let mut pl = Theme::Dracula.palette();
pl.primary = color!(0xFFD700); pl.primary = color!(0xFFD700);
return Theme::custom("Kira Theme", pl); return Theme::custom("Kira Theme", pl);
} }
@@ -38,18 +38,18 @@ pub fn change_lightnes(c: &Color, factor: f32) -> Color {
res res
} }
pub fn text_with_border(_theme: &Theme) -> container::Style { // pub fn text_with_border(_theme: &Theme) -> container::Style {
container::Style { // container::Style {
border: Border { // border: Border {
color: Color::from_rgb8(120, 98, 10), // color: Color::from_rgb8(120, 98, 10),
width: 2.0, // width: 2.0,
radius: 7.into(), // radius: 7.into(),
}, // },
background: Some(Background::Color(change_lightnes(&_theme.palette().background, 0.3))), // background: Some(Background::Color(change_lightnes(&_theme.palette().background, 0.3))),
..container::Style::default() // ..container::Style::default()
} // }
} // }
pub fn get_spiner_bytes() -> Vec<u8>{ pub fn get_spiner_bytes() -> Vec<u8>{
return include_bytes!("media/spiner.apng").to_vec(); return include_bytes!("media/spiner.apng").to_vec();
+19 -9
View File
@@ -32,9 +32,9 @@ use crate::stages::welcome;
use crate::stages::welcome::WelcomeStage; use crate::stages::welcome::WelcomeStage;
rust_i18n::i18n!("src/locales", fallback = "en"); rust_i18n::i18n!("src/locales", fallback = "en");
mod kira_theming;
mod stage; mod stage;
mod stages; mod stages;
mod theme;
enum Views { enum Views {
Start, Start,
@@ -126,14 +126,19 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
}, },
Message::Welcome(wlc_msg) => { Message::Welcome(wlc_msg) => {
if let Views::Welcome(wlc_view) = &mut k_state.current_view { if let Views::Welcome(wlc_view) = &mut k_state.current_view {
let action = wlc_view.update(wlc_msg); match wlc_view.update(wlc_msg) {
if let StageAction::Next(welcome_res) = action { StageAction::Next(welcome_res) => {
k_state.config.config_trail.push(welcome_res); k_state.config.config_trail.push(welcome_res);
k_state.current_view = Views::License(license::LicenseStage {}); k_state.current_view = Views::License(license::LicenseStage {});
}
}
Task::none() Task::none()
} }
StageAction::Abort => iced::exit(),
_ => Task::none(),
}
} else {
Task::none()
}
}
Message::License(license_message) => { Message::License(license_message) => {
if let Views::License(license_view) = &mut k_state.current_view { if let Views::License(license_view) = &mut k_state.current_view {
let action = license_view.update(license_message); let action = license_view.update(license_message);
@@ -144,8 +149,12 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
Views::Network(network::NetworkStage::new(&k_state.toml_config)); Views::Network(network::NetworkStage::new(&k_state.toml_config));
Task::done(Message::Network(network::Message::CheckNetwork)) Task::done(Message::Network(network::Message::CheckNetwork))
} }
StageAction::Abort(_) => iced::exit(), StageAction::Abort => iced::exit(),
StageAction::Back => iced::exit(), StageAction::Back => {
k_state.current_view = Views::Welcome(WelcomeStage::new());
k_state.config.config_trail.pop();
Task::none()
}
StageAction::None => Task::none(), StageAction::None => Task::none(),
} }
} else { } else {
@@ -166,6 +175,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
} }
StageAction::Back => { StageAction::Back => {
k_state.current_view = Views::License(license::LicenseStage {}); k_state.current_view = Views::License(license::LicenseStage {});
k_state.config.config_trail.pop();
Task::none() Task::none()
} }
_ => Task::none(), _ => Task::none(),
@@ -183,7 +193,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
k_state.config.config_trail.push(tz_res); k_state.config.config_trail.push(tz_res);
iced::exit() iced::exit()
} }
StageAction::Abort(_) => iced::exit(), StageAction::Abort => iced::exit(),
StageAction::Back => { StageAction::Back => {
k_state.config.config_trail.pop(); k_state.config.config_trail.pop();
k_state.current_view = k_state.current_view =
@@ -218,7 +228,7 @@ pub fn main() -> ExitCode {
..Default::default() ..Default::default()
}) })
.centered() .centered()
.theme(theme::main_theme()) .theme(kira_theming::main_theme())
.run(); .run();
match iced_result { match iced_result {
+1 -1
View File
@@ -45,7 +45,7 @@ pub enum StageAction {
Back, Back,
None, None,
Next(StageResult), Next(StageResult),
Abort(StageResult), Abort,
} }
+1 -6
View File
@@ -62,12 +62,7 @@ impl LicenseStage {
match message { match message {
Message::Accept => stage::StageAction::Next(Self::accepted()), Message::Accept => stage::StageAction::Next(Self::accepted()),
Message::Back => stage::StageAction::Back, Message::Back => stage::StageAction::Back,
Message::Decline => stage::StageAction::Abort(StageResult { Message::Decline => stage::StageAction::Abort,
name: "license".into(),
config: None,
resuts: None,
error: Some("Declined.".to_string()),
}),
} }
} }
+1 -1
View File
@@ -111,7 +111,7 @@ impl NetworkStage {
} }
let spinner_frames = let spinner_frames =
apng::Frames::from_bytes(crate::theme::get_spiner_bytes()).unwrap(); apng::Frames::from_bytes(crate::kira_theming::get_spiner_bytes()).unwrap();
Self { Self {
internet_active: false, internet_active: false,
+1 -1
View File
@@ -22,7 +22,7 @@ fn unselected_button_style(theme: &Theme, status: button::Status) -> button::Sty
..button::primary(theme, status) ..button::primary(theme, status)
}, },
button::Status::Active => button::Style { button::Status::Active => button::Style {
background: Some(iced::Background::Color(crate::theme::change_lightnes( background: Some(iced::Background::Color(crate::kira_theming::change_lightnes(
&theme.palette().primary, &theme.palette().primary,
-0.1, -0.1,
))), ))),
+3 -8
View File
@@ -20,7 +20,7 @@
*/ */
use crate::{stage::{ConfigValue, StageAction, StageResult}, theme}; use crate::{stage::{ConfigValue, StageAction, StageResult}, kira_theming};
use iced::{Alignment, widget}; use iced::{Alignment, widget};
use rust_i18n::t; use rust_i18n::t;
use std::collections::HashMap; use std::collections::HashMap;
@@ -111,12 +111,7 @@ impl WelcomeStage {
self.locale = Some(loc); self.locale = Some(loc);
StageAction::None StageAction::None
} }
Message::Exit => StageAction::Abort(StageResult { Message::Exit => StageAction::Abort,
name: "welcome".to_string(),
config: None,
resuts: None,
error: None,
}),
Message::Next => StageAction::Next(self.gen_result()), Message::Next => StageAction::Next(self.gen_result()),
} }
} }
@@ -127,7 +122,7 @@ impl WelcomeStage {
// Embed the image bytes into the executable // Embed the image bytes into the executable
let welcom_logo_handle = let welcom_logo_handle =
widget::image::Handle::from_bytes(theme::get_logo_bytes()); widget::image::Handle::from_bytes(kira_theming::get_logo_bytes());
widget::column![ widget::column![
widget::container( widget::container(