refactor: clarify content and tui ownership
This commit is contained in:
1 parent
078afe4b9d
commit
15d76c18a0
32 files changed
+893
-1144
No files matched your search
@@ -1,8 +1,8 @@
|
||||
// rendering for the modpack import wizard. same pattern as new_instance:
|
||||
// snapshot the state, pick the right step renderer, done.
|
||||
|
||||
use super::super::LoadState;
|
||||
use super::super::base::PopupFrame;
|
||||
use super::super::new_instance::LoadState;
|
||||
use super::state::{IMPORT_STATE, ImportStep, ImportWizardState};
|
||||
use crate::config::theme::THEME;
|
||||
use crate::tui::app::FocusedArea;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// (.mrpack, mmc/prism zips). remote packs go through version selection,
|
||||
// local files skip straight to the confirm step.
|
||||
|
||||
use super::super::new_instance::LoadState;
|
||||
use super::super::LoadState;
|
||||
use crate::instance::import::{ImportInput, ImportSummary, parse_import_input};
|
||||
use crate::net::modrinth::{self, VersionInfo};
|
||||
use crate::tui::widgets::instances;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub enum LoadState<T> {
|
||||
#[default]
|
||||
Idle,
|
||||
Loading,
|
||||
Loaded(T),
|
||||
Error(String),
|
||||
}
|
||||
@@ -5,8 +5,11 @@ pub mod base;
|
||||
pub mod confirm;
|
||||
pub mod error;
|
||||
pub mod import_modpack;
|
||||
mod load_state;
|
||||
pub mod new_instance;
|
||||
|
||||
pub use load_state::LoadState;
|
||||
|
||||
use ratatui::{
|
||||
Frame,
|
||||
layout::{Alignment, Constraint, Layout, Rect},
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
mod render;
|
||||
mod state;
|
||||
|
||||
pub use super::LoadState;
|
||||
pub(crate) use render::render_select_list;
|
||||
pub use render::{popup_rect, render};
|
||||
pub use state::{LoadState, WizardParams, WizardState, WizardStep, handle_key, take_result};
|
||||
pub use state::{WizardParams, WizardState, WizardStep, handle_key, take_result};
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn reset_for_test() {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// rendering for the new instance wizard. each step gets its own render fn
|
||||
// and the popup resizes itself based on which step is active.
|
||||
|
||||
use super::super::LoadState;
|
||||
use super::state::{
|
||||
LoadState, WIZARD_STATE, WizardState, WizardStep, clamp_loader_version_index,
|
||||
clamp_version_index, ensure_loader_versions_loaded, ensure_versions_loaded, visible_versions,
|
||||
WIZARD_STATE, WizardState, WizardStep, clamp_loader_version_index, clamp_version_index,
|
||||
ensure_loader_versions_loaded, ensure_versions_loaded, visible_versions,
|
||||
};
|
||||
use crate::config::theme::THEME;
|
||||
use crate::instance::models::ModLoader;
|
||||
|
||||
@@ -12,6 +12,8 @@ use std::sync::LazyLock;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tui_prompts::{FocusState, State as PromptState, TextState};
|
||||
|
||||
use super::super::LoadState;
|
||||
|
||||
pub(crate) static WIZARD_STATE: LazyLock<Arc<Mutex<WizardState>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(WizardState::default())));
|
||||
// populated on confirm, consumed by the main event loop to actually create the instance
|
||||
@@ -36,15 +38,6 @@ pub enum WizardStep {
|
||||
Confirm,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub enum LoadState<T> {
|
||||
#[default]
|
||||
Idle,
|
||||
Loading,
|
||||
Loaded(T),
|
||||
Error(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct WizardState {
|
||||
pub step: WizardStep,
|
||||
|
||||
Reference in new issue
Block a user