Refactor footer text
This commit is contained in:
parent
a77bf0c9c6
commit
e029e02cc2
3 changed files with 20 additions and 19 deletions
|
|
@ -28,6 +28,7 @@ pub enum Action {
|
||||||
Select(Option<usize>, Option<usize>), // indicies for (source, dest) etc
|
Select(Option<usize>, Option<usize>), // indicies for (source, dest) etc
|
||||||
SelectRight(Option<usize>, Option<usize>), // indicies for right info pane
|
SelectRight(Option<usize>, Option<usize>), // indicies for right info pane
|
||||||
UpdateDiskList(Vec<Disk>),
|
UpdateDiskList(Vec<Disk>),
|
||||||
|
UpdateFooter(String),
|
||||||
UpdateLeft(String, Vec<String>, Vec<String>, bool), // (title, labels, items, select_one)
|
UpdateLeft(String, Vec<String>, Vec<String>, bool), // (title, labels, items, select_one)
|
||||||
UpdateRight(Vec<Vec<DVLine>>, usize, Vec<Vec<DVLine>>), // (labels, start_index, items) - items before start are always shown
|
UpdateRight(Vec<Vec<DVLine>>, usize, Vec<Vec<DVLine>>), // (labels, start_index, items) - items before start are always shown
|
||||||
// Screens
|
// Screens
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,8 @@ impl App {
|
||||||
}
|
}
|
||||||
Action::SetMode(new_mode) => {
|
Action::SetMode(new_mode) => {
|
||||||
self.set_mode(new_mode)?;
|
self.set_mode(new_mode)?;
|
||||||
|
self.action_tx
|
||||||
|
.send(Action::UpdateFooter(build_footer_string(self.cur_mode)))?;
|
||||||
let (title, labels, items, select_one) = build_left_items(self, self.cur_mode);
|
let (title, labels, items, select_one) = build_left_items(self, self.cur_mode);
|
||||||
self.action_tx
|
self.action_tx
|
||||||
.send(Action::UpdateLeft(title, labels, items, select_one))?;
|
.send(Action::UpdateLeft(title, labels, items, select_one))?;
|
||||||
|
|
@ -550,6 +552,20 @@ fn get_chunks(r: Rect) -> Vec<Rect> {
|
||||||
chunks
|
chunks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_footer_string(cur_mode: Mode) -> String {
|
||||||
|
match cur_mode {
|
||||||
|
Mode::ScanDisks | Mode::PreClone | Mode::Clone | Mode::PostClone => {
|
||||||
|
String::from("(q) to quit")
|
||||||
|
}
|
||||||
|
Mode::SelectParts => String::from("(Enter) to select / (s) to start over / (q) to quit"),
|
||||||
|
Mode::SelectDisks => String::from(
|
||||||
|
"(Enter) to select / / (i) to install driver / (r) to rescan / (q) to quit",
|
||||||
|
),
|
||||||
|
Mode::SelectTableType => String::from("(Enter) to select / (b) to go back / (q) to quit"),
|
||||||
|
Mode::Confirm => String::from("(Enter) to confirm / (b) to go back / (q) to quit"),
|
||||||
|
Mode::Done | Mode::Failed | Mode::InstallDrivers => String::from("(Enter) or (q) to quit"),
|
||||||
|
}
|
||||||
|
}
|
||||||
fn build_left_items(app: &App, cur_mode: Mode) -> (String, Vec<String>, Vec<String>, bool) {
|
fn build_left_items(app: &App, cur_mode: Mode) -> (String, Vec<String>, Vec<String>, bool) {
|
||||||
let title: String;
|
let title: String;
|
||||||
let mut items = Vec::new();
|
let mut items = Vec::new();
|
||||||
|
|
|
||||||
|
|
@ -51,25 +51,9 @@ impl Component for Footer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||||
if let Action::SetMode(new_mode) = action {
|
match action {
|
||||||
self.text = match new_mode {
|
Action::UpdateFooter(text) => self.text = text,
|
||||||
Mode::ScanDisks | Mode::PreClone | Mode::Clone | Mode::PostClone => {
|
_ => {}
|
||||||
String::from("(q) to quit")
|
|
||||||
}
|
|
||||||
Mode::SelectParts => {
|
|
||||||
String::from("(Enter) to select / (s) to start over / (q) to quit")
|
|
||||||
}
|
|
||||||
Mode::SelectDisks => String::from(
|
|
||||||
"(Enter) to select / / (i) to install driver / (r) to rescan / (q) to quit",
|
|
||||||
),
|
|
||||||
Mode::SelectTableType => {
|
|
||||||
String::from("(Enter) to select / (b) to go back / (q) to quit")
|
|
||||||
}
|
|
||||||
Mode::Confirm => String::from("(Enter) to confirm / (b) to go back / (q) to quit"),
|
|
||||||
Mode::Done | Mode::Failed | Mode::InstallDrivers => {
|
|
||||||
String::from("(Enter) or (q) to quit")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue