diff --git a/toolbox/ratchet/src/main.rs b/toolbox/ratchet/src/main.rs index 897935a..6b0ff42 100644 --- a/toolbox/ratchet/src/main.rs +++ b/toolbox/ratchet/src/main.rs @@ -271,7 +271,7 @@ impl MainAppState { wizard_screen.view(self) } CurrentTopLevelScreen::Configurator(configurator_screen) => { - debug!("Showing: Instance Configurator"); + debug!("Showing: Configurator"); configurator_screen.view(self) } } diff --git a/toolbox/ratchet/src/screens/configurator/apps/detail.rs b/toolbox/ratchet/src/screens/configurator/apps/detail.rs new file mode 100644 index 0000000..7ff11d2 --- /dev/null +++ b/toolbox/ratchet/src/screens/configurator/apps/detail.rs @@ -0,0 +1,76 @@ +use anyhow::Context; +use iced::{ + Element, + alignment, + widget::{ + button, + horizontal_space, + row, + text, + }, +}; +use iced_fonts::{ + REQUIRED_FONT, + required::{ + RequiredIcons, + icon_to_string, + }, +}; + +use crate::{ + Message, + screens::configurator::{ + ConfiguratorScreen, + ConfiguratorTab, + }, +}; + +pub fn app_detail_tab( + configurator_screen: &ConfiguratorScreen, + content: &mut Vec>, + repo_id: &String, + app_id: &String, + prev_screen: &Box, +) { + let repo = configurator_screen + .repos + .get(repo_id) + .with_context(|| { + format!( + "ConfiguratorScreen::update() should've ensured that repo: \"{}\" existed in the repo cache", + repo_id + ) + }) + .unwrap(); + + let app = repo + .apps + .get(app_id) + .with_context(|| { + format!( + "ConfiguratorScreen::update() should've ensured that app: \"{}\" existed in the repo cache", + app_id + ) + }) + .unwrap(); + + content.push( + row(vec![ + button(row(vec![ + text(icon_to_string(RequiredIcons::CaretLeftFill)) + .font(REQUIRED_FONT) + .width(iced::Length::Shrink) + .align_y(alignment::Vertical::Center) + .into(), + text("Back").into(), + ])) + .on_press(Message::SetConfiguratorTab(*prev_screen.clone())) + .into(), + horizontal_space().into(), + button("Settings").into(), + ]) + .into(), + ); + + content.push(text(app.name.clone()).size(24).into()); +} diff --git a/toolbox/ratchet/src/screens/configurator/apps/mod.rs b/toolbox/ratchet/src/screens/configurator/apps/mod.rs new file mode 100644 index 0000000..d2cff6d --- /dev/null +++ b/toolbox/ratchet/src/screens/configurator/apps/mod.rs @@ -0,0 +1,84 @@ +pub mod detail; + +use carbon_steel::repos::App; +use iced::{ + Element, + widget::{ + button, + column, + horizontal_space, + row, + text, + }, +}; +use log::debug; +use std::collections::HashMap; + +use crate::{ + Message, + screens::configurator::{ + ConfiguratorScreen, + ConfiguratorTab, + }, +}; + +pub fn apps_tab(configurator_screen: &ConfiguratorScreen, content: &mut Vec>) { + debug!("Apps Tab"); + + content.push(text("Apps").size(24).into()); + + let mut apps = HashMap::new(); + + for (repo_id, repo_config) in configurator_screen.repos.clone().iter() { + for (app_id, app_config) in repo_config.apps.clone().iter() { + apps.insert((repo_id.clone(), app_id.clone()), app_config.clone()); + } + } + + content.push( + column( + as Clone>::clone(&apps) + .into_iter() + .map(|(ids, app_config)| { + let (repo_id, app_id) = ids; + let repos = &configurator_screen.repos.clone(); + let repo_name = repos.get(&repo_id).unwrap().name.clone(); + + debug!( + "Found \"{}\", with config: {:?}", + app_id.clone(), + app_config.clone() + ); + + // TODO: App badges + let badges = vec![]; + + button( + row(vec![ + column(vec![ + column(vec![ + text(app_config.name).size(18).into(), + text(repo_name.clone()).size(14).into(), + ]) + .into(), + row(badges).spacing(3).into(), + ]) + .spacing(3) + .into(), + horizontal_space().into(), + ]) + .spacing(3), + ) + // TODO: Repo management sub_screen + .on_press(Message::SetConfiguratorTab(ConfiguratorTab::AppDetail( + repo_id.clone(), + app_id.clone(), + Box::new(ConfiguratorTab::Apps), + ))) + .into() + }) + .collect::>>(), + ) + .into(), + ); +} diff --git a/toolbox/ratchet/src/screens/configurator/gestures/mod.rs b/toolbox/ratchet/src/screens/configurator/gestures/mod.rs new file mode 100644 index 0000000..316c2e6 --- /dev/null +++ b/toolbox/ratchet/src/screens/configurator/gestures/mod.rs @@ -0,0 +1,20 @@ +use carbon_steel::repos::GesturePack; +use iced::{ + Element, + widget::text, +}; +use log::debug; + +use crate::{ + Message, + screens::configurator::ConfiguratorScreen, +}; + +pub fn gestures_tab( + _configurator_screen: &ConfiguratorScreen, + content: &mut Vec>, +) { + debug!("Gestures Tab"); + + content.push(text("Gestures").into()); +} diff --git a/toolbox/ratchet/src/screens/configurator/mod.rs b/toolbox/ratchet/src/screens/configurator/mod.rs index edc03f5..34e458b 100644 --- a/toolbox/ratchet/src/screens/configurator/mod.rs +++ b/toolbox/ratchet/src/screens/configurator/mod.rs @@ -1,6 +1,10 @@ -use std::collections::HashMap; +pub mod apps; +pub mod gestures; +pub mod modules; +pub mod overview; +pub mod repos; +pub mod sidebar; -use anyhow::Context; use carbon_steel::repos::{ App, GesturePack, @@ -13,41 +17,43 @@ use iced::{ Padding, Task, Theme, - alignment, border::Radius, widget::{ - button, column, container, - horizontal_space, row, scrollable, - text, - vertical_space, - }, -}; -use iced_aw::badge; -use iced_fonts::{ - REQUIRED_FONT, - required::{ - RequiredIcons, - icon_to_string, }, }; -use log::{ - debug, - error, -}; +use log::error; +use std::collections::HashMap; use crate::{ Message, - screens::MoveToScreen, + screens::{ + ConfiguratorFocus, + MoveToScreen, + configurator::{ + apps::{ + apps_tab, + detail::app_detail_tab, + }, + gestures::gestures_tab, + modules::modules_tab, + overview::overview_tab, + repos::{ + detail::repo_detail_tab, + repos_tab, + }, + sidebar::gen_sidebar, + }, + }, util::menu::gen_menu_bar, }; #[derive(Debug, Clone)] pub struct ConfiguratorScreen { - pub instance_id: String, + pub instance_id: Option, pub repos: HashMap, pub tab: ConfiguratorTab, pub current_repo: Option, @@ -59,10 +65,13 @@ pub enum ConfiguratorTab { #[default] Overview, Modules, + // TODO: ModuleDetail(String), Gestures, + // TODO: GestureDetail(String), Apps, + AppDetail(String, String, Box), Repos, - RepoDetail(String), + RepoDetail(String, Box), } #[derive(Debug, Clone, Default)] @@ -74,7 +83,7 @@ pub enum Action { } impl ConfiguratorScreen { - pub fn new(id: String) -> (Self, Task) { + pub fn new(id: ConfiguratorFocus) -> (Self, Task) { let mut repos = HashMap::new(); let mut gesture_packs = HashMap::new(); @@ -116,236 +125,42 @@ impl ConfiguratorScreen { ); ( - ConfiguratorScreen { - instance_id: id, - // TODO: load repos from connection - repos, - tab: Default::default(), - current_repo: None, - }, + (match id { + ConfiguratorFocus::Instance(instance_id) => ConfiguratorScreen { + instance_id: Some(instance_id), + // TODO: load repos from connection instead of hardcoding them, obviously. + repos, + tab: Default::default(), + current_repo: None, + }, + ConfiguratorFocus::Repo(repo_id) => ConfiguratorScreen { + instance_id: None, + // TODO: load repos from connection instead of hardcoding them, obviously. + repos, + tab: Default::default(), + current_repo: Some(repo_id), + }, + }), Task::none(), ) } pub fn view(&self, _state: &crate::MainAppState) -> iced::Element { let mut elements: Vec> = vec![]; - let sidebar = vec![ - column(vec![ - text("$ConnectionName").size(24).into(), - badge("Connected") - .style(iced_aw::style::badge::success) - .into(), - ]) - .spacing(12) - .padding(Padding { - top: 0.0, - bottom: 12.0, - left: 0.0, - right: 0.0, - }) - .into(), - button(row([ - text("Overview").into(), - horizontal_space().into(), - // TODO: Replace with actual icon - text(icon_to_string(RequiredIcons::CaretRightFill)) - .font(REQUIRED_FONT) - .width(iced::Length::Shrink) - .align_y(alignment::Vertical::Center) - .into(), - ])) - .on_press_maybe({ - if self.tab != ConfiguratorTab::Overview { - Some(Message::SetConfiguratorTab(ConfiguratorTab::Overview)) - } else { - None - } - }) - .width(iced::Length::Fill) - .into(), - button(row([ - text("Modules").into(), - horizontal_space().into(), - // TODO: Replace with actual icon - text(icon_to_string(RequiredIcons::CaretRightFill)) - .font(REQUIRED_FONT) - .width(iced::Length::Shrink) - .align_y(alignment::Vertical::Center) - .into(), - ])) - .on_press_maybe({ - if self.tab != ConfiguratorTab::Modules { - Some(Message::SetConfiguratorTab(ConfiguratorTab::Modules)) - } else { - None - } - }) - .width(iced::Length::Fill) - .into(), - button(row([ - text("Gestures").into(), - horizontal_space().into(), - // TODO: Replace with actual icon - text(icon_to_string(RequiredIcons::CaretRightFill)) - .font(REQUIRED_FONT) - .width(iced::Length::Shrink) - .align_y(alignment::Vertical::Center) - .into(), - ])) - .on_press_maybe({ - if self.tab != ConfiguratorTab::Gestures { - Some(Message::SetConfiguratorTab(ConfiguratorTab::Gestures)) - } else { - None - } - }) - .width(iced::Length::Fill) - .into(), - button(row([ - text("Apps").into(), - horizontal_space().into(), - // TODO: Replace with actual icon - text(icon_to_string(RequiredIcons::CaretRightFill)) - .font(REQUIRED_FONT) - .width(iced::Length::Shrink) - .align_y(alignment::Vertical::Center) - .into(), - ])) - .on_press_maybe({ - if self.tab != ConfiguratorTab::Apps { - Some(Message::SetConfiguratorTab(ConfiguratorTab::Apps)) - } else { - None - } - }) - .width(iced::Length::Fill) - .into(), - button(row([ - text("Repos").into(), - horizontal_space().into(), - // TODO: Replace with actual icon - text(icon_to_string(RequiredIcons::CaretRightFill)) - .font(REQUIRED_FONT) - .width(iced::Length::Shrink) - .align_y(alignment::Vertical::Center) - .into(), - ])) - .on_press_maybe({ - if self.tab != ConfiguratorTab::Repos { - Some(Message::SetConfiguratorTab(ConfiguratorTab::Repos)) - } else { - None - } - }) - .width(iced::Length::Fill) - .into(), - vertical_space().into(), - button(row([ - text("Instances").into(), - horizontal_space().into(), - // TODO: Replace with actual icon - text(icon_to_string(RequiredIcons::CaretRightFill)) - .font(REQUIRED_FONT) - .width(iced::Length::Shrink) - .align_y(alignment::Vertical::Center) - .into(), - ])) - .on_press(Message::MoveToScreen(MoveToScreen::Welcome)) - .width(iced::Length::Fill) - .into(), - ]; + let sidebar = gen_sidebar(&self); let mut content: Vec> = Vec::new(); match &self.tab { - ConfiguratorTab::Overview => { - debug!("Overview Tab"); - content.push(text("Overview").into()); - } - ConfiguratorTab::Modules => { - debug!("Modules Tab"); - content.push(text("Modules").into()); - } - ConfiguratorTab::Gestures => { - debug!("Gestures Tab"); - - content.push(text("Gestures").into()); - } - ConfiguratorTab::Apps => { - debug!("Apps Tab"); - content.push(text("Apps").into()); - } - ConfiguratorTab::Repos => { - debug!("All Repos Tab"); - - content.push(text("Repositories").size(24).into()); - - let repos = &self.repos.clone(); - - content.push( - column( - as Clone>::clone(&repos) - .into_iter() - .map(|(id, repo)| { - debug!("Found \"{}\", with config: {:?}", id.clone(), repo.clone()); - - let mut badges = vec![]; - - if !repo.modules.is_empty() { - badges.push(badge("Modules").into()); - } - - if !repo.gesture_packs.is_empty() { - badges.push(badge("Gesture Packs").into()); - } - - if !repo.apps.is_empty() { - badges.push(badge("Apps").into()); - } - - button( - row(vec![ - column(vec![ - column(vec![ - text(repo.name).size(18).into(), - text(repo.url).size(14).into(), - ]) - .into(), - row(badges).spacing(3).into(), - ]) - .spacing(3) - .into(), - horizontal_space().into(), - ]) - .spacing(3), - ) - // TODO: Repo management sub_screen - .on_press(Message::SetConfiguratorTab(ConfiguratorTab::RepoDetail( - id.clone(), - ))) - .into() - }) - .collect::>>(), - ) - .into(), - ); + ConfiguratorTab::Overview => overview_tab(self, &mut content), + ConfiguratorTab::Modules => modules_tab(self, &mut content), + ConfiguratorTab::Gestures => gestures_tab(self, &mut content), + ConfiguratorTab::Apps => apps_tab(self, &mut content), + ConfiguratorTab::Repos => repos_tab(self, &mut content), + ConfiguratorTab::RepoDetail(repo_id, prev_screen) => { + repo_detail_tab(self, &mut content, repo_id, prev_screen) } - ConfiguratorTab::RepoDetail(repo_id) => { - let repo = self.repos.get(repo_id).with_context(|| format!("ConfiguratorScreen::update() should've ensured that \"{}\" existed in the repo cache", repo_id)).unwrap(); - - content.push( - button(row(vec![ - text(icon_to_string(RequiredIcons::CaretLeftFill)) - .font(REQUIRED_FONT) - .width(iced::Length::Shrink) - .align_y(alignment::Vertical::Center) - .into(), - text("Back to All Repos").into(), - ])) - .on_press(Message::SetConfiguratorTab(ConfiguratorTab::Repos)) - .into(), - ); - - content.push(text(repo.name.clone()).size(24).into()); + ConfiguratorTab::AppDetail(repo_id, app_id, prev_screen) => { + app_detail_tab(self, &mut content, repo_id, app_id, prev_screen) } } @@ -406,7 +221,7 @@ impl ConfiguratorScreen { }, Message::SetWizardStep(_wizard_step) => Action::None, Message::SetConfiguratorTab(tab) => match tab { - ConfiguratorTab::RepoDetail(ref repo_id) => match self.repos.get(repo_id) { + ConfiguratorTab::RepoDetail(ref repo_id, _) => match self.repos.get(repo_id) { Some(_) => { self.tab = tab.clone(); Action::None @@ -417,6 +232,26 @@ impl ConfiguratorScreen { Action::SetTab(ConfiguratorTab::Repos) } }, + ConfiguratorTab::AppDetail(ref repo_id, ref app_id, _) => match self.repos.get(repo_id) { + Some(repo) => { + match repo.apps.get(app_id) { + Some(_) => { + self.tab = tab.clone(); + Action::None + } + None => { + error!("Found repo, but the referenced app does not exist!"); + // TODO: show pop-up! + Action::SetTab(ConfiguratorTab::Repos) + } + } + } + None => { + error!("Repo ID set, but it does not exist!"); + // TODO: show pop-up! + Action::SetTab(ConfiguratorTab::Repos) + } + }, _ => { self.tab = tab; Action::None diff --git a/toolbox/ratchet/src/screens/configurator/modules/mod.rs b/toolbox/ratchet/src/screens/configurator/modules/mod.rs new file mode 100644 index 0000000..f3803cc --- /dev/null +++ b/toolbox/ratchet/src/screens/configurator/modules/mod.rs @@ -0,0 +1,17 @@ +use carbon_steel::repos::Module; +use iced::{ + Element, + widget::text, +}; +use log::debug; + +use crate::{ + Message, + screens::configurator::ConfiguratorScreen, +}; + +pub fn modules_tab(_configurator_screen: &ConfiguratorScreen, content: &mut Vec>) { + debug!("Modules Tab"); + + content.push(text("Modules").into()); +} diff --git a/toolbox/ratchet/src/screens/configurator/overview/mod.rs b/toolbox/ratchet/src/screens/configurator/overview/mod.rs new file mode 100644 index 0000000..f8f00bd --- /dev/null +++ b/toolbox/ratchet/src/screens/configurator/overview/mod.rs @@ -0,0 +1,19 @@ +use iced::{ + Element, + widget::text, +}; +use log::debug; + +use crate::{ + Message, + screens::configurator::ConfiguratorScreen, +}; + +pub fn overview_tab( + _configurator_screen: &ConfiguratorScreen, + content: &mut Vec>, +) { + debug!("Overview Tab"); + + content.push(text("Overview").into()); +} diff --git a/toolbox/ratchet/src/screens/configurator/repos/detail.rs b/toolbox/ratchet/src/screens/configurator/repos/detail.rs new file mode 100644 index 0000000..047ebe1 --- /dev/null +++ b/toolbox/ratchet/src/screens/configurator/repos/detail.rs @@ -0,0 +1,108 @@ +use anyhow::Context; +use iced::{ + Element, + alignment, + widget::{ + button, + column, + horizontal_space, + row, + text, + }, +}; +use iced_fonts::{ + REQUIRED_FONT, + required::{ + RequiredIcons, + icon_to_string, + }, +}; + +use crate::{ + Message, + screens::configurator::{ + ConfiguratorScreen, + ConfiguratorTab, + }, +}; + +pub fn repo_detail_tab( + configurator_screen: &ConfiguratorScreen, + content: &mut Vec>, + repo_id: &String, + prev_screen: &Box, +) { + let repo_config = configurator_screen + .repos + .get(repo_id) + .with_context(|| { + format!( + "ConfiguratorScreen::update() should've ensured that \"{}\" existed in the repo cache", + repo_id + ) + }) + .unwrap(); + + content.push( + row(vec![ + button(row(vec![ + text(icon_to_string(RequiredIcons::CaretLeftFill)) + .font(REQUIRED_FONT) + .width(iced::Length::Shrink) + .align_y(alignment::Vertical::Center) + .into(), + text("Back").into(), + ])) + .on_press(Message::SetConfiguratorTab(*prev_screen.clone())) + .into(), + horizontal_space().into(), + button("Settings").into(), + ]) + .into(), + ); + + content.push(text(repo_config.name.clone()).size(24).into()); + + if !repo_config.modules.is_empty() { + let mut section = vec![text("Modules").size(20).into()]; + + for (_module_id, module_config) in repo_config.modules.iter() { + // TODO: Go to module detail tab + section.push(button(column(vec![text(module_config.name.clone()).into()])).into()); + } + + content.push(column(section).spacing(6).into()); + } + + if !repo_config.gesture_packs.is_empty() { + let mut section = vec![text("Gesture Packs").size(20).into()]; + + for (_pack_id, pack_config) in repo_config.gesture_packs.iter() { + // TODO: Go to gesture pack detail tab + section.push(button(column(vec![text(pack_config.name.clone()).into()])).into()); + } + + content.push(column(section).spacing(6).into()); + } + + if !repo_config.apps.is_empty() { + let mut section = vec![text("Apps").size(20).into()]; + + for (app_id, app_config) in repo_config.apps.iter() { + section.push( + button(column(vec![text(app_config.name.clone()).into()])) + .on_press(Message::SetConfiguratorTab(ConfiguratorTab::AppDetail( + repo_id.clone(), + app_id.clone(), + Box::new(ConfiguratorTab::RepoDetail( + repo_id.clone(), + prev_screen.clone(), + )), + ))) + .into(), + ); + } + + content.push(column(section).spacing(6).into()); + } +} diff --git a/toolbox/ratchet/src/screens/configurator/repos/mod.rs b/toolbox/ratchet/src/screens/configurator/repos/mod.rs new file mode 100644 index 0000000..e139c0c --- /dev/null +++ b/toolbox/ratchet/src/screens/configurator/repos/mod.rs @@ -0,0 +1,86 @@ +pub mod detail; + +use std::collections::HashMap; + +use carbon_steel::repos::Repo; +use iced::{ + Element, + widget::{ + button, + column, + horizontal_space, + row, + text, + }, +}; +use iced_aw::badge; +use log::debug; + +use crate::{ + Message, + screens::configurator::{ + ConfiguratorScreen, + ConfiguratorTab, + }, +}; + +pub fn repos_tab(configurator_screen: &ConfiguratorScreen, content: &mut Vec>) { + debug!("All Repos Tab"); + + content.push(text("Repositories").size(24).into()); + + let repos = &configurator_screen.repos.clone(); + + content.push( + column( + as Clone>::clone(&repos) + .into_iter() + .map(|(id, repo_config)| { + debug!( + "Found \"{}\", with config: {:?}", + id.clone(), + repo_config.clone() + ); + + let mut badges = vec![]; + + if !repo_config.modules.is_empty() { + badges.push(badge("Modules").into()); + } + + if !repo_config.gesture_packs.is_empty() { + badges.push(badge("Gesture Packs").into()); + } + + if !repo_config.apps.is_empty() { + badges.push(badge("Apps").into()); + } + + button( + row(vec![ + column(vec![ + column(vec![ + text(repo_config.name).size(18).into(), + text(repo_config.url).size(14).into(), + ]) + .into(), + row(badges).spacing(3).into(), + ]) + .spacing(3) + .into(), + horizontal_space().into(), + ]) + .spacing(3), + ) + // TODO: Repo management sub_screen + .on_press(Message::SetConfiguratorTab(ConfiguratorTab::RepoDetail( + id.clone(), + Box::new(ConfiguratorTab::Repos), + ))) + .into() + }) + .collect::>>(), + ) + .into(), + ); +} diff --git a/toolbox/ratchet/src/screens/configurator/sidebar.rs b/toolbox/ratchet/src/screens/configurator/sidebar.rs new file mode 100644 index 0000000..28322b5 --- /dev/null +++ b/toolbox/ratchet/src/screens/configurator/sidebar.rs @@ -0,0 +1,161 @@ +use iced::{ + Element, + Padding, + alignment, + widget::{ + button, + column, + horizontal_space, + row, + text, + vertical_space, + }, +}; +use iced_aw::badge; +use iced_fonts::{ + REQUIRED_FONT, + required::{ + RequiredIcons, + icon_to_string, + }, +}; + +use crate::{ + Message, + screens::{ + MoveToScreen, + configurator::{ + ConfiguratorScreen, + ConfiguratorTab, + }, + }, +}; + +// TODO: Add button to sidebar when a main repo is set, then toggle sidebar mode between repo and instance focuses +pub fn gen_sidebar(configurator_screen: &ConfiguratorScreen) -> Vec> { + vec![ + column(vec![ + text("$ConnectionName").size(24).into(), + badge("Connected") + .style(iced_aw::style::badge::success) + .into(), + ]) + .spacing(12) + .padding(Padding { + top: 0.0, + bottom: 12.0, + left: 0.0, + right: 0.0, + }) + .into(), + button(row([ + text("Overview").into(), + horizontal_space().into(), + // TODO: Replace with actual icon + text(icon_to_string(RequiredIcons::CaretRightFill)) + .font(REQUIRED_FONT) + .width(iced::Length::Shrink) + .align_y(alignment::Vertical::Center) + .into(), + ])) + .on_press_maybe({ + if configurator_screen.tab != ConfiguratorTab::Overview { + Some(Message::SetConfiguratorTab(ConfiguratorTab::Overview)) + } else { + None + } + }) + .width(iced::Length::Fill) + .into(), + button(row([ + text("Modules").into(), + horizontal_space().into(), + // TODO: Replace with actual icon + text(icon_to_string(RequiredIcons::CaretRightFill)) + .font(REQUIRED_FONT) + .width(iced::Length::Shrink) + .align_y(alignment::Vertical::Center) + .into(), + ])) + .on_press_maybe({ + if configurator_screen.tab != ConfiguratorTab::Modules { + Some(Message::SetConfiguratorTab(ConfiguratorTab::Modules)) + } else { + None + } + }) + .width(iced::Length::Fill) + .into(), + button(row([ + text("Gestures").into(), + horizontal_space().into(), + // TODO: Replace with actual icon + text(icon_to_string(RequiredIcons::CaretRightFill)) + .font(REQUIRED_FONT) + .width(iced::Length::Shrink) + .align_y(alignment::Vertical::Center) + .into(), + ])) + .on_press_maybe({ + if configurator_screen.tab != ConfiguratorTab::Gestures { + Some(Message::SetConfiguratorTab(ConfiguratorTab::Gestures)) + } else { + None + } + }) + .width(iced::Length::Fill) + .into(), + button(row([ + text("Apps").into(), + horizontal_space().into(), + // TODO: Replace with actual icon + text(icon_to_string(RequiredIcons::CaretRightFill)) + .font(REQUIRED_FONT) + .width(iced::Length::Shrink) + .align_y(alignment::Vertical::Center) + .into(), + ])) + .on_press_maybe({ + if configurator_screen.tab != ConfiguratorTab::Apps { + Some(Message::SetConfiguratorTab(ConfiguratorTab::Apps)) + } else { + None + } + }) + .width(iced::Length::Fill) + .into(), + button(row([ + text("Repos").into(), + horizontal_space().into(), + // TODO: Replace with actual icon + text(icon_to_string(RequiredIcons::CaretRightFill)) + .font(REQUIRED_FONT) + .width(iced::Length::Shrink) + .align_y(alignment::Vertical::Center) + .into(), + ])) + .on_press_maybe({ + if configurator_screen.tab != ConfiguratorTab::Repos { + Some(Message::SetConfiguratorTab(ConfiguratorTab::Repos)) + } else { + None + } + }) + .width(iced::Length::Fill) + .into(), + vertical_space().into(), + button(row([ + text("Instances").into(), + horizontal_space().into(), + // TODO: Replace with actual icon + text(icon_to_string(RequiredIcons::CaretRightFill)) + .font(REQUIRED_FONT) + .width(iced::Length::Shrink) + .align_y(alignment::Vertical::Center) + .into(), + ])) + .on_press(Message::MoveToScreen(MoveToScreen::Welcome)) + .width(iced::Length::Fill) + .into(), + ] +} diff --git a/toolbox/ratchet/src/screens/mod.rs b/toolbox/ratchet/src/screens/mod.rs index 16e9bb0..f06164f 100644 --- a/toolbox/ratchet/src/screens/mod.rs +++ b/toolbox/ratchet/src/screens/mod.rs @@ -28,5 +28,11 @@ impl Default for CurrentTopLevelScreen { pub enum MoveToScreen { Welcome, Wizard(WizardStep), - Configurator(String), + Configurator(ConfiguratorFocus), +} + +#[derive(Debug, Clone)] +pub enum ConfiguratorFocus { + Instance(String), + Repo(String), } diff --git a/toolbox/ratchet/src/screens/welcome/mod.rs b/toolbox/ratchet/src/screens/welcome/mod.rs index 718e5db..aa93178 100644 --- a/toolbox/ratchet/src/screens/welcome/mod.rs +++ b/toolbox/ratchet/src/screens/welcome/mod.rs @@ -13,6 +13,7 @@ use std::collections::HashMap; use crate::{ screens::{ + ConfiguratorFocus, MoveToScreen, wizard::WizardStep, }, @@ -69,7 +70,7 @@ impl WelcomeScreen { button("Connection") .on_press(crate::Message::MoveToScreen( - super::MoveToScreen::Configurator(id.clone()), + super::MoveToScreen::Configurator(ConfiguratorFocus::Instance(id)), )) .into() }) @@ -97,6 +98,19 @@ impl WelcomeScreen { .into(), ); + // TODO: Fix this. + elements.push( + row(vec![ + text("Or manage a repo").into(), + button("TEST REPO") + .on_press(crate::Message::MoveToScreen(MoveToScreen::Configurator( + ConfiguratorFocus::Repo("com.reboot-codes.clover.CORE".to_string()), + ))) + .into(), + ]) + .into(), + ); + column(vec![ gen_menu_bar(), column(elements).padding(12).spacing(12).into(),