Add manual input elements to the app an ui #216
@ -29,10 +29,9 @@ impl IAppInput for AppInputMode {
|
||||
}
|
||||
|
||||
fn cancel(mut self) -> Self::APP {
|
||||
match &mut self.app {
|
||||
AppState::Match(state) => state.submit_input(self.input),
|
||||
_ => {}
|
||||
}
|
||||
if let AppState::Match(state) = &mut self.app {
|
||||
state.submit_input(self.input)
|
||||
};
|
||||
self.app
|
||||
}
|
||||
}
|
||||
|
@ -8,24 +8,15 @@ use musichoard::collection::{album::AlbumMeta, artist::ArtistMeta, Collection};
|
||||
|
||||
use crate::tui::lib::interface::musicbrainz::Match;
|
||||
|
||||
pub enum AppState<
|
||||
BrowseState,
|
||||
InfoState,
|
||||
ReloadState,
|
||||
SearchState,
|
||||
FetchState,
|
||||
MatchState,
|
||||
ErrorState,
|
||||
CriticalState,
|
||||
> {
|
||||
Browse(BrowseState),
|
||||
Info(InfoState),
|
||||
Reload(ReloadState),
|
||||
Search(SearchState),
|
||||
Fetch(FetchState),
|
||||
Match(MatchState),
|
||||
Error(ErrorState),
|
||||
Critical(CriticalState),
|
||||
pub enum AppState<B, I, R, S, F, M, E, C> {
|
||||
Browse(B),
|
||||
Info(I),
|
||||
Reload(R),
|
||||
Search(S),
|
||||
Fetch(F),
|
||||
Match(M),
|
||||
Error(E),
|
||||
Critical(C),
|
||||
}
|
||||
|
||||
pub enum AppMode<BrowseMode, InputMode> {
|
||||
@ -33,6 +24,13 @@ pub enum AppMode<BrowseMode, 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 {
|
||||
type BrowseState: IAppBase<APP = Self> + IAppInteractBrowse<APP = Self>;
|
||||
type InfoState: IAppBase<APP = Self> + IAppInteractInfo<APP = Self>;
|
||||
@ -49,36 +47,10 @@ pub trait IApp {
|
||||
fn is_running(&self) -> bool;
|
||||
fn force_quit(self) -> Self;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn state(
|
||||
self,
|
||||
) -> AppState<
|
||||
Self::BrowseState,
|
||||
Self::InfoState,
|
||||
Self::ReloadState,
|
||||
Self::SearchState,
|
||||
Self::FetchState,
|
||||
Self::MatchState,
|
||||
Self::ErrorState,
|
||||
Self::CriticalState,
|
||||
>;
|
||||
fn state(self) -> IAppState!();
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn mode(
|
||||
self,
|
||||
) -> AppMode<
|
||||
AppState<
|
||||
Self::BrowseState,
|
||||
Self::InfoState,
|
||||
Self::ReloadState,
|
||||
Self::SearchState,
|
||||
Self::FetchState,
|
||||
Self::MatchState,
|
||||
Self::ErrorState,
|
||||
Self::CriticalState,
|
||||
>,
|
||||
Self::InputMode,
|
||||
>;
|
||||
fn mode(self) -> AppMode<IAppState!(), Self::InputMode>;
|
||||
}
|
||||
|
||||
pub trait IAppBase {
|
||||
@ -239,27 +211,7 @@ pub struct MatchStatePublic<'app> {
|
||||
pub type AppPublicState<'app> =
|
||||
AppState<(), (), (), &'app str, (), MatchStatePublic<'app>, &'app str, &'app str>;
|
||||
|
||||
impl<
|
||||
BrowseState,
|
||||
InfoState,
|
||||
ReloadState,
|
||||
SearchState,
|
||||
FetchState,
|
||||
MatchState,
|
||||
ErrorState,
|
||||
CriticalState,
|
||||
>
|
||||
AppState<
|
||||
BrowseState,
|
||||
InfoState,
|
||||
ReloadState,
|
||||
SearchState,
|
||||
FetchState,
|
||||
MatchState,
|
||||
ErrorState,
|
||||
CriticalState,
|
||||
>
|
||||
{
|
||||
impl<B, I, R, S, F, M, E, C> AppState<B, I, R, S, F, M, E, C> {
|
||||
pub fn is_search(&self) -> bool {
|
||||
matches!(self, AppState::Search(_))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user