Skip to content

Commit

Permalink
Merge pull request #103 from nazar-pc/welcome-screen
Browse files Browse the repository at this point in the history
Add welcome screen
  • Loading branch information
nazar-pc authored Jan 31, 2024
2 parents 14b0a55 + d47ac91 commit 0356989
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "space-acres"
description = "Space Acres is an opinionated unofficial GUI application for farming on Subspace Network"
license = "0BSD"
version = "0.0.23"
version = "0.0.24"
authors = ["Nazar Mokrynskyi <[email protected]>"]
repository = "https://github.com/nazar-pc/space-acres"
edition = "2021"
Expand Down Expand Up @@ -39,6 +39,7 @@ dark-light = "1.0.0"
dirs = "5.0.1"
duct = "0.13.6"
event-listener-primitives = "2.0.1"
indoc = "2.0.4"
file-rotate = "0.7.5"
frame-system = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
fs4 = "0.7.0"
Expand Down
17 changes: 17 additions & 0 deletions src/frontend/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub enum ConfigurationInput {
Delete(DynamicIndex),
Reconfigure(RawConfig),
Start,
Back,
Cancel,
Save,
Ignore,
Expand All @@ -42,6 +43,7 @@ pub enum ConfigurationInput {
pub enum ConfigurationOutput {
StartWithNewConfig(RawConfig),
ConfigUpdate(RawConfig),
Back,
Close,
}

Expand Down Expand Up @@ -384,6 +386,16 @@ impl Component for ConfigurationView {
} else {
gtk::Box {
set_halign: gtk::Align::End,
set_spacing: 10,

gtk::Button {
connect_clicked => ConfigurationInput::Back,

gtk::Label {
set_label: "Back",
set_margin_all: 10,
},
},

gtk::Button {
add_css_class: "suggested-action",
Expand Down Expand Up @@ -538,6 +550,11 @@ impl ConfigurationView {
debug!("Failed to send ConfigurationOutput::StartWithNewConfig");
}
}
ConfigurationInput::Back => {
if sender.output(ConfigurationOutput::Back).is_err() {
debug!("Failed to send ConfigurationOutput::Back");
}
}
ConfigurationInput::Cancel => {
if sender.output(ConfigurationOutput::Close).is_err() {
debug!("Failed to send ConfigurationOutput::Close");
Expand Down
53 changes: 51 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ enum AppInput {
Configuration(ConfigurationOutput),
OpenReconfiguration,
ShowAboutDialog,
InitialConfiguration,
Restart,
}

enum View {
Welcome,
Loading,
Configuration,
Reconfiguration,
Expand All @@ -100,6 +102,7 @@ enum View {
impl View {
fn title(&self) -> &'static str {
match self {
Self::Welcome => "Welcome",
Self::Loading => "Loading",
Self::Configuration => "Configuration",
Self::Reconfiguration => "Reconfiguration",
Expand Down Expand Up @@ -236,6 +239,46 @@ impl AsyncComponent for App {

#[transition = "SlideLeftRight"]
match &model.current_view {
View::Welcome => gtk::Box {
set_margin_all: 10,
set_orientation: gtk::Orientation::Vertical,
set_spacing: 20,

gtk::Image {
set_height_request: 256,
set_from_pixbuf: Some(
&gtk::gdk_pixbuf::Pixbuf::from_read(ABOUT_IMAGE)
.expect("Statically correct image; qed")
),
},

gtk::Label {
set_label: indoc::indoc! {"
Space Acres is an opinionated unofficial GUI application for farming on Subspace Network.
Before continuing you need 3 things:
✔ Wallet address where you'll receive rewards (use Subwallet, polkadot{.js} extension or any other wallet compatible with Substrate chain)
✔ 100G of space on a good quality SSD to store node data
✔ any SSDs (or multiple) with as much space as you can afford for farming purposes, this is what will generate rewards"
},
set_wrap: true,
},

gtk::Box {
set_halign: gtk::Align::End,


gtk::Button {
add_css_class: "suggested-action",
connect_clicked => AppInput::InitialConfiguration,

gtk::Label {
set_label: "Continue",
set_margin_all: 10,
},
},
},
},
View::Loading => model.loading_view.widget().clone(),
View::Configuration | View::Reconfiguration => model.configuration_view.widget().clone(),
View::Running=> model.running_view.widget().clone(),
Expand Down Expand Up @@ -442,6 +485,9 @@ impl AsyncComponent for App {
self.menu_popover.hide();
self.about_dialog.show();
}
AppInput::InitialConfiguration => {
self.current_view = View::Configuration;
}
AppInput::Restart => {
self.exit_status_code
.store(AppStatusCode::Restart, Ordering::Release);
Expand All @@ -461,8 +507,7 @@ impl App {
self.loading_view.emit(LoadingInput::BackendLoading(step));
}
BackendNotification::NotConfigured => {
// TODO: Welcome screen first
self.current_view = View::Configuration;
self.current_view = View::Welcome;
}
BackendNotification::ConfigurationIsInvalid { error, .. } => {
self.status_bar_notification =
Expand Down Expand Up @@ -545,6 +590,10 @@ impl App {
View::Error(anyhow::anyhow!("Failed to send config to backend: {error}"));
}
}
ConfigurationOutput::Back => {
// Back to welcome screen
self.current_view = View::Welcome;
}
ConfigurationOutput::Close => {
// Configuration view is closed when application is already running, switch to corresponding screen
self.current_view = View::Running;
Expand Down

0 comments on commit 0356989

Please sign in to comment.