mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Handle check for updates in setup activity
This commit is contained in:
@@ -238,6 +238,10 @@ impl SetupActivity {
|
||||
// Move left
|
||||
config_cli.set_show_hidden_files(true);
|
||||
}
|
||||
UserInterfaceInputField::CheckForUpdates => {
|
||||
// move left
|
||||
config_cli.set_check_for_updates(true);
|
||||
}
|
||||
_ => { /* Not a tab field */ }
|
||||
}
|
||||
}
|
||||
@@ -275,6 +279,10 @@ impl SetupActivity {
|
||||
// Move right
|
||||
config_cli.set_show_hidden_files(false);
|
||||
}
|
||||
UserInterfaceInputField::CheckForUpdates => {
|
||||
// move right
|
||||
config_cli.set_check_for_updates(false);
|
||||
}
|
||||
_ => { /* Not a tab field */ }
|
||||
}
|
||||
}
|
||||
@@ -284,6 +292,9 @@ impl SetupActivity {
|
||||
self.tab = SetupTab::UserInterface(match field {
|
||||
UserInterfaceInputField::FileFmt => UserInterfaceInputField::GroupDirs,
|
||||
UserInterfaceInputField::GroupDirs => {
|
||||
UserInterfaceInputField::CheckForUpdates
|
||||
}
|
||||
UserInterfaceInputField::CheckForUpdates => {
|
||||
UserInterfaceInputField::ShowHiddenFiles
|
||||
}
|
||||
UserInterfaceInputField::ShowHiddenFiles => {
|
||||
@@ -305,6 +316,9 @@ impl SetupActivity {
|
||||
UserInterfaceInputField::ShowHiddenFiles
|
||||
}
|
||||
UserInterfaceInputField::ShowHiddenFiles => {
|
||||
UserInterfaceInputField::CheckForUpdates
|
||||
}
|
||||
UserInterfaceInputField::CheckForUpdates => {
|
||||
UserInterfaceInputField::GroupDirs
|
||||
}
|
||||
UserInterfaceInputField::GroupDirs => UserInterfaceInputField::FileFmt,
|
||||
@@ -354,7 +368,8 @@ impl SetupActivity {
|
||||
}
|
||||
UserInterfaceInputField::FileFmt => {
|
||||
// Push char to current file fmt
|
||||
let mut file_fmt = config_cli.get_file_fmt().unwrap_or_default();
|
||||
let mut file_fmt =
|
||||
config_cli.get_file_fmt().unwrap_or_default();
|
||||
file_fmt.push(ch);
|
||||
// update value
|
||||
config_cli.set_file_fmt(file_fmt);
|
||||
|
||||
@@ -90,6 +90,7 @@ impl SetupActivity {
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(1),
|
||||
]
|
||||
.as_ref(),
|
||||
@@ -105,12 +106,15 @@ impl SetupActivity {
|
||||
if let Some(tab) = self.draw_hidden_files_tab() {
|
||||
f.render_widget(tab, ui_cfg_chunks[2]);
|
||||
}
|
||||
if let Some(tab) = self.draw_default_group_dirs_tab() {
|
||||
if let Some(tab) = self.draw_check_for_updates_tab() {
|
||||
f.render_widget(tab, ui_cfg_chunks[3]);
|
||||
}
|
||||
if let Some(tab) = self.draw_file_fmt_input() {
|
||||
if let Some(tab) = self.draw_default_group_dirs_tab() {
|
||||
f.render_widget(tab, ui_cfg_chunks[4]);
|
||||
}
|
||||
if let Some(tab) = self.draw_file_fmt_input() {
|
||||
f.render_widget(tab, ui_cfg_chunks[5]);
|
||||
}
|
||||
// Set cursor
|
||||
if let Some(cli) = &self.config_cli {
|
||||
match form_field {
|
||||
@@ -317,9 +321,9 @@ impl SetupActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/// ### draw_default_protocol_tab
|
||||
/// ### draw_hidden_files_tab
|
||||
///
|
||||
/// Draw default protocol input tab
|
||||
/// Draw default hidden files tab
|
||||
fn draw_hidden_files_tab(&self) -> Option<Tabs> {
|
||||
// Check if config client is some
|
||||
match &self.config_cli {
|
||||
@@ -358,6 +362,47 @@ impl SetupActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/// ### draw_check_for_updates_tab
|
||||
///
|
||||
/// Draw check for updates tab
|
||||
fn draw_check_for_updates_tab(&self) -> Option<Tabs> {
|
||||
// Check if config client is some
|
||||
match &self.config_cli {
|
||||
Some(cli) => {
|
||||
let choices: Vec<Spans> = vec![Spans::from("Yes"), Spans::from("No")];
|
||||
let index: usize = match cli.get_check_for_updates() {
|
||||
true => 0,
|
||||
false => 1,
|
||||
};
|
||||
let (bg, fg, block_fg): (Color, Color, Color) = match &self.tab {
|
||||
SetupTab::UserInterface(field) => match field {
|
||||
UserInterfaceInputField::CheckForUpdates => {
|
||||
(Color::LightYellow, Color::Black, Color::LightYellow)
|
||||
}
|
||||
_ => (Color::Reset, Color::LightYellow, Color::Reset),
|
||||
},
|
||||
_ => (Color::Reset, Color::Reset, Color::Reset),
|
||||
};
|
||||
Some(
|
||||
Tabs::new(choices)
|
||||
.block(
|
||||
Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.style(Style::default().fg(block_fg))
|
||||
.title("Check for updates?"),
|
||||
)
|
||||
.select(index)
|
||||
.style(Style::default())
|
||||
.highlight_style(
|
||||
Style::default().add_modifier(Modifier::BOLD).fg(fg).bg(bg),
|
||||
),
|
||||
)
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// ### draw_default_group_dirs_tab
|
||||
///
|
||||
/// Draw group dirs input tab
|
||||
|
||||
@@ -54,6 +54,7 @@ enum UserInterfaceInputField {
|
||||
DefaultProtocol,
|
||||
TextEditor,
|
||||
ShowHiddenFiles,
|
||||
CheckForUpdates,
|
||||
GroupDirs,
|
||||
FileFmt,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user