Working on activity refactoring

This commit is contained in:
veeso
2021-03-09 21:52:11 +01:00
parent b2aaf5c57f
commit 5980bc1fcb
2 changed files with 95 additions and 3 deletions

View File

@@ -25,9 +25,10 @@
// Sub modules
mod bookmarks;
mod callbacks;
mod input;
mod layout;
mod callbacks; // REMOVE
mod input; // REMOVE
mod layout; // REMOVE
mod update;
// Dependencies
extern crate crossterm;
@@ -40,6 +41,7 @@ use crate::filetransfer::FileTransferProtocol;
use crate::system::bookmarks_client::BookmarksClient;
use crate::system::config_client::ConfigClient;
use crate::system::environment;
use crate::ui::layout::view::View;
use crate::utils::git;
// Includes
@@ -51,6 +53,22 @@ use tui::style::Color;
// Types
type DialogCallback = fn(&mut AuthActivity);
// -- components
const COMPONENT_TEXT_HEADER: &str = "TEXT_HEADER";
const COMPONENT_TEXT_FOOTER: &str = "TEXT_FOOTER";
const COMPONENT_TEXT_HELP: &str = "TEXT_HELP";
const COMPONENT_TEXT_ERROR: &str = "TEXT_ERROR";
const COMPONENT_INPUT_ADDR: &str = "INPUT_ADDRESS";
const COMPONENT_INPUT_PORT: &str = "INPUT_PORT";
const COMPONENT_INPUT_USERNAME: &str = "INPUT_USERNAME";
const COMPONENT_INPUT_PASSWORD: &str = "INPUT_PASSWORD";
const COMPONENT_INPUT_BOOKMARK_NAME: &str = "INPUT_BOOKMARK_NAME";
const COMPONENT_RADIO_PROTOCOL: &str = "RADIO_PROTOCOL";
const COMPONENT_RADIO_BOOKMARK_DEL: &str = "RADIO_DELETE_BOOKMARK";
const COMPONENT_RADIO_BOOKMARK_SAVE_PWD: &str = "RADIO_SAVE_PASSWORD";
const COMPONENT_BOOKMARKS_LIST: &str = "BOOKMARKS_LIST";
const COMPONENT_RECENTS_LIST: &str = "RECENTS_LIST";
/// ### InputField
///
/// InputField describes the current input field to edit
@@ -106,6 +124,7 @@ pub struct AuthActivity {
pub quit: bool, // Becomes true if user has pressed esc
pub setup: bool, // Becomes true if user has requested setup
context: Option<Context>,
view: View,
bookmarks_client: Option<BookmarksClient>,
config_client: Option<ConfigClient>,
selected_field: InputField, // Selected field in AuthCredentials Form
@@ -144,6 +163,7 @@ impl AuthActivity {
quit: false,
setup: false,
context: None,
view: View::init(),
bookmarks_client: None,
config_client: None,
selected_field: InputField::Address,