diff --git a/README.md b/README.md index f855e04..0d2e6dd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ # kira-installer -Universal GNU Linux installer. \ No newline at end of file +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``` \ No newline at end of file diff --git a/src/theme.rs b/src/kira_theming.rs similarity index 76% rename from src/theme.rs rename to src/kira_theming.rs index 728160d..7d8cbe5 100644 --- a/src/theme.rs +++ b/src/kira_theming.rs @@ -19,13 +19,13 @@ Modify it to your liking. */ -use iced::widget::container; -use iced::{Border, Color, Theme, color, Background}; +use iced::{Color, Theme, color}; // Function returns theme to be used by installer pub fn main_theme() -> Theme { let mut pl = Theme::Dracula.palette(); pl.primary = color!(0xFFD700); + return Theme::custom("Kira Theme", pl); } @@ -38,18 +38,18 @@ pub fn change_lightnes(c: &Color, factor: f32) -> Color { res } -pub fn text_with_border(_theme: &Theme) -> container::Style { +// pub fn text_with_border(_theme: &Theme) -> container::Style { - container::Style { - border: Border { - color: Color::from_rgb8(120, 98, 10), - width: 2.0, - radius: 7.into(), - }, - background: Some(Background::Color(change_lightnes(&_theme.palette().background, 0.3))), - ..container::Style::default() - } -} +// container::Style { +// border: Border { +// color: Color::from_rgb8(120, 98, 10), +// width: 2.0, +// radius: 7.into(), +// }, +// background: Some(Background::Color(change_lightnes(&_theme.palette().background, 0.3))), +// ..container::Style::default() +// } +// } pub fn get_spiner_bytes() -> Vec{ return include_bytes!("media/spiner.apng").to_vec(); diff --git a/src/main.rs b/src/main.rs index b82ebc1..b5a100e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,9 +32,9 @@ use crate::stages::welcome; use crate::stages::welcome::WelcomeStage; rust_i18n::i18n!("src/locales", fallback = "en"); +mod kira_theming; mod stage; mod stages; -mod theme; enum Views { Start, @@ -126,13 +126,18 @@ fn update(k_state: &mut KiraState, message: Message) -> Task { }, 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 {}); + match wlc_view.update(wlc_msg) { + StageAction::Next(welcome_res) => { + k_state.config.config_trail.push(welcome_res); + k_state.current_view = Views::License(license::LicenseStage {}); + Task::none() + } + StageAction::Abort => iced::exit(), + _ => Task::none(), } + } else { + Task::none() } - Task::none() } Message::License(license_message) => { if let Views::License(license_view) = &mut k_state.current_view { @@ -144,8 +149,12 @@ fn update(k_state: &mut KiraState, message: Message) -> Task { Views::Network(network::NetworkStage::new(&k_state.toml_config)); Task::done(Message::Network(network::Message::CheckNetwork)) } - StageAction::Abort(_) => iced::exit(), - StageAction::Back => iced::exit(), + StageAction::Abort => iced::exit(), + StageAction::Back => { + k_state.current_view = Views::Welcome(WelcomeStage::new()); + k_state.config.config_trail.pop(); + Task::none() + } StageAction::None => Task::none(), } } else { @@ -166,6 +175,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task { } StageAction::Back => { k_state.current_view = Views::License(license::LicenseStage {}); + k_state.config.config_trail.pop(); Task::none() } _ => Task::none(), @@ -183,7 +193,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task { k_state.config.config_trail.push(tz_res); iced::exit() } - StageAction::Abort(_) => iced::exit(), + StageAction::Abort => iced::exit(), StageAction::Back => { k_state.config.config_trail.pop(); k_state.current_view = @@ -218,7 +228,7 @@ pub fn main() -> ExitCode { ..Default::default() }) .centered() - .theme(theme::main_theme()) + .theme(kira_theming::main_theme()) .run(); match iced_result { diff --git a/src/stage.rs b/src/stage.rs index 2ad8e9e..f8da219 100644 --- a/src/stage.rs +++ b/src/stage.rs @@ -45,7 +45,7 @@ pub enum StageAction { Back, None, Next(StageResult), - Abort(StageResult), + Abort, } diff --git a/src/stages/license/mod.rs b/src/stages/license/mod.rs index b9b469f..83a94da 100644 --- a/src/stages/license/mod.rs +++ b/src/stages/license/mod.rs @@ -62,12 +62,7 @@ impl LicenseStage { match message { Message::Accept => stage::StageAction::Next(Self::accepted()), Message::Back => stage::StageAction::Back, - Message::Decline => stage::StageAction::Abort(StageResult { - name: "license".into(), - config: None, - resuts: None, - error: Some("Declined.".to_string()), - }), + Message::Decline => stage::StageAction::Abort, } } diff --git a/src/stages/network/mod.rs b/src/stages/network/mod.rs index d463f39..2c18c75 100644 --- a/src/stages/network/mod.rs +++ b/src/stages/network/mod.rs @@ -111,7 +111,7 @@ impl NetworkStage { } 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 { internet_active: false, diff --git a/src/stages/timezone/scroll_list.rs b/src/stages/timezone/scroll_list.rs index 916acb3..4c268e3 100644 --- a/src/stages/timezone/scroll_list.rs +++ b/src/stages/timezone/scroll_list.rs @@ -22,7 +22,7 @@ fn unselected_button_style(theme: &Theme, status: button::Status) -> button::Sty ..button::primary(theme, status) }, 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, -0.1, ))), diff --git a/src/stages/welcome/mod.rs b/src/stages/welcome/mod.rs index c02625e..e0eb8a9 100644 --- a/src/stages/welcome/mod.rs +++ b/src/stages/welcome/mod.rs @@ -20,7 +20,7 @@ */ -use crate::{stage::{ConfigValue, StageAction, StageResult}, theme}; +use crate::{stage::{ConfigValue, StageAction, StageResult}, kira_theming}; use iced::{Alignment, widget}; use rust_i18n::t; use std::collections::HashMap; @@ -111,12 +111,7 @@ impl WelcomeStage { self.locale = Some(loc); StageAction::None } - Message::Exit => StageAction::Abort(StageResult { - name: "welcome".to_string(), - config: None, - resuts: None, - error: None, - }), + Message::Exit => StageAction::Abort, Message::Next => StageAction::Next(self.gen_result()), } } @@ -127,7 +122,7 @@ impl WelcomeStage { // Embed the image bytes into the executable 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::container(