Small fixes and cleanups.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
# kira-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```
|
||||
@@ -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<u8>{
|
||||
return include_bytes!("media/spiner.apng").to_vec();
|
||||
+19
-9
@@ -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,14 +126,19 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<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 {
|
||||
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()
|
||||
}
|
||||
}
|
||||
Message::License(license_message) => {
|
||||
if let Views::License(license_view) = &mut k_state.current_view {
|
||||
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));
|
||||
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<Message> {
|
||||
}
|
||||
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<Message> {
|
||||
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 {
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ pub enum StageAction {
|
||||
Back,
|
||||
None,
|
||||
Next(StageResult),
|
||||
Abort(StageResult),
|
||||
Abort,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
))),
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user