-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b13b1ff
commit 119ce5f
Showing
70 changed files
with
5,487 additions
and
1,747 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
src/apps/experimental/components/library/LibraryContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import React, { FC, useState } from 'react'; | ||
|
||
import Box from '@mui/material/Box'; | ||
import { LibrarySettingsProvider } from 'hooks/useLibrarySettings'; | ||
import LibraryHeader from './LibraryHeader'; | ||
import LibraryView from './LibraryView'; | ||
import SuggestionsView from './SuggestionsView'; | ||
import UpComingView from './UpComingView'; | ||
|
||
import { LibraryViewSelectOptions } from 'types/library'; | ||
import Page from 'components/Page'; | ||
|
||
type CollectionType = string | null | undefined; | ||
|
||
const getLibraryViewMenuOptions = ( | ||
collectionType: CollectionType | ||
) => { | ||
const viewSelectOptions: LibraryViewSelectOptions[] = []; | ||
if (collectionType === 'movies') { | ||
viewSelectOptions.push( | ||
{ title: 'Movies', value: 'movies' }, | ||
{ title: 'Trailers', value: 'trailers' }, | ||
{ title: 'Collections', value: 'collections' }, | ||
{ title: 'Genres', value: 'genres' }, | ||
{ title: 'Studios', value: 'studios' }, | ||
{ title: 'Suggestions', value: 'suggestions' } | ||
); | ||
} | ||
|
||
if (collectionType === 'tvshows') { | ||
viewSelectOptions.push( | ||
{ title: 'Series', value: 'series' }, | ||
{ title: 'Episodes', value: 'episodes' }, | ||
{ title: 'Genres', value: 'genres' }, | ||
{ title: 'Studios', value: 'studios' }, | ||
{ title: 'Upcoming', value: 'upcoming' }, | ||
{ title: 'Suggestions', value: 'suggestions' } | ||
); | ||
} | ||
|
||
if (collectionType === 'music') { | ||
viewSelectOptions.push( | ||
{ title: 'Albums', value: 'albums' }, | ||
{ title: 'AlbumArtists', value: 'albumArtists' }, | ||
{ title: 'Artists', value: 'artists' }, | ||
{ title: 'Playlist', value: 'playlist' }, | ||
{ title: 'Genres', value: 'genres' }, | ||
{ title: 'Songs', value: 'songs' }, | ||
{ title: 'Suggestions', value: 'suggestions' } | ||
); | ||
} | ||
|
||
if (collectionType === 'books') { | ||
viewSelectOptions.push({ title: 'Books', value: 'books' }); | ||
} | ||
|
||
if (collectionType === 'homevideos') { | ||
viewSelectOptions.push( | ||
{ title: 'Photos', value: 'photos' }, | ||
{ title: 'Videos', value: 'videos' } | ||
); | ||
} | ||
|
||
return viewSelectOptions; | ||
}; | ||
|
||
const getBackDropType = (collectionType: CollectionType) => { | ||
if (collectionType === 'movies') { | ||
return 'movie'; | ||
} | ||
|
||
if (collectionType === 'tvshows') { | ||
return 'series'; | ||
} | ||
|
||
if (collectionType === 'music') { | ||
return 'musicartist'; | ||
} | ||
|
||
if (collectionType === 'books') { | ||
return 'book'; | ||
} | ||
|
||
if (collectionType === 'homevideos') { | ||
return 'video, photo'; | ||
} | ||
|
||
return ''; | ||
}; | ||
|
||
const getViewComponent = (viewType: string, collectionType: string | null | undefined, parentId: string | null | undefined) => { | ||
let component; | ||
|
||
switch (viewType) { | ||
case 'suggestions': | ||
component = <SuggestionsView collectionType={collectionType} parentId={parentId} />; | ||
break; | ||
|
||
case 'upcoming': | ||
component = <UpComingView parentId={parentId} />; | ||
break; | ||
|
||
default: | ||
component = <LibraryView viewType={viewType} collectionType={collectionType} parentId={parentId} />; | ||
break; | ||
} | ||
|
||
return component; | ||
}; | ||
|
||
interface LibraryContentProps { | ||
defaultView: string | ||
collectionType: CollectionType; | ||
parentId: string | null; | ||
} | ||
|
||
const LibraryContent: FC<LibraryContentProps> = ({ defaultView, parentId, collectionType }) => { | ||
const viewSelectOptions = getLibraryViewMenuOptions(collectionType); | ||
const [ viewType, setViewType] = useState<string>(defaultView ?? viewSelectOptions[0].value); | ||
|
||
return ( | ||
<Page | ||
id='libraryPage' | ||
className='mainAnimatedPage libraryPage backdropPage' | ||
backDropType={getBackDropType(collectionType)} | ||
> | ||
<LibrarySettingsProvider | ||
viewType={viewType} | ||
parentId={parentId} | ||
> | ||
<Box> | ||
<LibraryHeader | ||
viewSelectOptions={viewSelectOptions} | ||
viewType={viewType} | ||
setViewType={setViewType} | ||
collectionType={collectionType} | ||
parentId={parentId} | ||
/> | ||
|
||
{getViewComponent(viewType, collectionType, parentId)} | ||
|
||
</Box> | ||
</LibrarySettingsProvider> | ||
</Page> | ||
); | ||
}; | ||
|
||
export default LibraryContent; |
Oops, something went wrong.