we compiled for now

This commit is contained in:
filipriec
2025-04-14 14:28:36 +02:00
parent f2a63476b3
commit d154ba6b89
2 changed files with 31 additions and 4 deletions

View File

@@ -93,7 +93,7 @@ pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_
register_state.set_current_field(last_field_index);
}
} else {
app_state.focused_button_index = app_state.general.selected_item.saturating_sub(1);
app_state.focused_button_index = app_state.focused_button_index.saturating_sub(1);
}
} else if app_state.ui.show_intro {
app_state.ui.intro_state.previous_option();
@@ -121,7 +121,7 @@ pub fn next_option(app_state: &mut AppState) { // Remove option_count parameter
} else {
// Get option count from state instead of parameter
let option_count = app_state.profile_tree.profiles.len();
app_state.general.current_option = (app_state.general.current_option + 1) % option_count;
app_state.focused_button_index = (app_state.focused_button_index + 1) % option_count;
}
}
@@ -130,10 +130,10 @@ pub fn previous_option(app_state: &mut AppState) {
app_state.ui.intro_state.previous_option();
} else {
let option_count = app_state.profile_tree.profiles.len();
app_state.general.current_option = if app_state.general.current_option == 0 {
app_state.focused_button_index = if app_state.focused_button_index == 0 {
option_count.saturating_sub(1)
} else {
app_state.general.current_option - 1
app_state.focused_button_index - 1
};
}
}

View File

@@ -34,5 +34,32 @@ impl AdminState {
self.list_state.select(new_selection);
}
}
/// Selects the next profile in the list, wrapping around.
pub fn next(&mut self) {
if self.profiles.is_empty() {
self.list_state.select(None);
return;
}
let i = match self.list_state.selected() {
Some(i) => if i >= self.profiles.len() - 1 { 0 } else { i + 1 },
None => 0,
};
self.list_state.select(Some(i));
}
/// Selects the previous profile in the list, wrapping around.
pub fn previous(&mut self) {
if self.profiles.is_empty() {
self.list_state.select(None);
return;
}
let i = match self.list_state.selected() {
Some(i) => if i == 0 { self.profiles.len() - 1 } else { i - 1 },
None => self.profiles.len() - 1,
};
self.list_state.select(Some(i));
}
}