Skip to content

Commit

Permalink
Simplify panel navigation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
svareille committed Sep 15, 2022
1 parent bd13e6a commit fe8ce91
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ enum DecrKeyType {
Pass,
}

#[derive(Clone)]
enum Panel {
#[allow(dead_code)]
DataDisplay,
Expand Down Expand Up @@ -181,34 +182,20 @@ impl<'a> App<'a> {
pub fn next_panel(&mut self) {
self.current_panel = match &self.current_panel {
Panel::ProfileTab => Panel::HelpButton,
Panel::Onlykey => Panel::ProfileTab,
Panel::SelectDecrKeyType => Panel::SelectDecrKeyType,
Panel::EnterDecrPass => Panel::EnterDecrPass,
Panel::DataDisplay => Panel::DataDisplay,
Panel::HelpButton => match self.current_profile {0 | 1 => Panel::Onlykey, 2 => Panel::General, _ => Panel::ProfileTab},
Panel::HelpPopup => Panel::HelpPopup,
Panel::StatusBar => Panel::StatusBar,
Panel::SelectDecrEccKeyType => Panel::SelectDecrEccKeyType,
Panel::EnterECCKey(t) => Panel::EnterECCKey(t.clone()),
Panel::EnterRsaKey => Panel::EnterRsaKey,
Panel::Onlykey => Panel::ProfileTab,
Panel::General => Panel::ProfileTab,
other => other.clone(),
};
}

pub fn previous_panel(&mut self) {
self.current_panel = match &self.current_panel {
Panel::ProfileTab => match self.current_profile {0 | 1 => Panel::Onlykey, 2 => Panel::General, _ => Panel::ProfileTab},
Panel::Onlykey => Panel::HelpButton,
Panel::SelectDecrKeyType => Panel::SelectDecrKeyType,
Panel::EnterDecrPass => Panel::EnterDecrPass,
Panel::DataDisplay => Panel::DataDisplay,
Panel::HelpButton => Panel::ProfileTab,
Panel::HelpPopup => Panel::HelpPopup,
Panel::StatusBar => Panel::StatusBar,
Panel::SelectDecrEccKeyType => Panel::SelectDecrEccKeyType,
Panel::EnterECCKey(t) => Panel::EnterECCKey(t.clone()),
Panel::General => Panel::HelpButton,
Panel::EnterRsaKey => Panel::EnterRsaKey,
Panel::HelpButton => Panel::ProfileTab,
other => other.clone(),
};
}

Expand Down

0 comments on commit fe8ce91

Please sign in to comment.