Add manual input elements to the app an ui #216

Merged
wojtek merged 17 commits from 188---add-option-for-manual-input-during-fetch into main 2024-09-15 15:20:11 +02:00
2 changed files with 22 additions and 71 deletions
Showing only changes of commit e8db0e98d5 - Show all commits

View File

@ -29,10 +29,9 @@ impl IAppInput for AppInputMode {
} }
fn cancel(mut self) -> Self::APP { fn cancel(mut self) -> Self::APP {
match &mut self.app { if let AppState::Match(state) = &mut self.app {
AppState::Match(state) => state.submit_input(self.input), state.submit_input(self.input)
_ => {} };
}
self.app self.app
} }
} }

View File

@ -8,24 +8,15 @@ use musichoard::collection::{album::AlbumMeta, artist::ArtistMeta, Collection};
use crate::tui::lib::interface::musicbrainz::Match; use crate::tui::lib::interface::musicbrainz::Match;
pub enum AppState< pub enum AppState<B, I, R, S, F, M, E, C> {
BrowseState, Browse(B),
InfoState, Info(I),
ReloadState, Reload(R),
SearchState, Search(S),
FetchState, Fetch(F),
MatchState, Match(M),
ErrorState, Error(E),
CriticalState, Critical(C),
> {
Browse(BrowseState),
Info(InfoState),
Reload(ReloadState),
Search(SearchState),
Fetch(FetchState),
Match(MatchState),
Error(ErrorState),
Critical(CriticalState),
} }
pub enum AppMode<BrowseMode, InputMode> { pub enum AppMode<BrowseMode, InputMode> {
@ -33,6 +24,13 @@ pub enum AppMode<BrowseMode, InputMode> {
Input(InputMode), Input(InputMode),
} }
macro_rules! IAppState {
() => {
AppState<Self::BrowseState, Self::InfoState, Self::ReloadState, Self::SearchState,
Self::FetchState, Self::MatchState, Self::ErrorState, Self::CriticalState>
};
}
pub trait IApp { pub trait IApp {
type BrowseState: IAppBase<APP = Self> + IAppInteractBrowse<APP = Self>; type BrowseState: IAppBase<APP = Self> + IAppInteractBrowse<APP = Self>;
type InfoState: IAppBase<APP = Self> + IAppInteractInfo<APP = Self>; type InfoState: IAppBase<APP = Self> + IAppInteractInfo<APP = Self>;
@ -49,36 +47,10 @@ pub trait IApp {
fn is_running(&self) -> bool; fn is_running(&self) -> bool;
fn force_quit(self) -> Self; fn force_quit(self) -> Self;
#[allow(clippy::type_complexity)] fn state(self) -> IAppState!();
fn state(
self,
) -> AppState<
Self::BrowseState,
Self::InfoState,
Self::ReloadState,
Self::SearchState,
Self::FetchState,
Self::MatchState,
Self::ErrorState,
Self::CriticalState,
>;
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
fn mode( fn mode(self) -> AppMode<IAppState!(), Self::InputMode>;
self,
) -> AppMode<
AppState<
Self::BrowseState,
Self::InfoState,
Self::ReloadState,
Self::SearchState,
Self::FetchState,
Self::MatchState,
Self::ErrorState,
Self::CriticalState,
>,
Self::InputMode,
>;
} }
pub trait IAppBase { pub trait IAppBase {
@ -239,27 +211,7 @@ pub struct MatchStatePublic<'app> {
pub type AppPublicState<'app> = pub type AppPublicState<'app> =
AppState<(), (), (), &'app str, (), MatchStatePublic<'app>, &'app str, &'app str>; AppState<(), (), (), &'app str, (), MatchStatePublic<'app>, &'app str, &'app str>;
impl< impl<B, I, R, S, F, M, E, C> AppState<B, I, R, S, F, M, E, C> {
BrowseState,
InfoState,
ReloadState,
SearchState,
FetchState,
MatchState,
ErrorState,
CriticalState,
>
AppState<
BrowseState,
InfoState,
ReloadState,
SearchState,
FetchState,
MatchState,
ErrorState,
CriticalState,
>
{
pub fn is_search(&self) -> bool { pub fn is_search(&self) -> bool {
matches!(self, AppState::Search(_)) matches!(self, AppState::Search(_))
} }