Files
jellyfin-audio-player/src/components/App.tsx

48 lines
1.7 KiB
TypeScript
Raw Normal View History

import React, { useEffect } from 'react';
2020-06-17 14:58:04 +02:00
import { Provider } from 'react-redux';
2020-06-16 17:51:51 +02:00
import TrackPlayer from 'react-native-track-player';
2020-06-17 14:58:04 +02:00
import { PersistGate } from 'redux-persist/integration/react';
2020-06-16 17:51:51 +02:00
import Routes from '../screens';
2020-06-21 10:30:41 +02:00
import store, { persistedStore } from 'store';
2020-07-26 14:45:32 +02:00
import {
NavigationContainer,
DefaultTheme,
DarkTheme,
} from '@react-navigation/native';
import { useColorScheme } from 'react-native';
2021-02-13 12:14:57 +01:00
import { ColorSchemeContext, themes } from './Colors';
2020-06-16 17:51:51 +02:00
export default function App(): JSX.Element {
const colorScheme = useColorScheme();
2021-02-13 12:14:57 +01:00
const theme = themes[colorScheme || 'light'];
// const theme = 'dark';
2020-06-16 17:51:51 +02:00
useEffect(() => {
async function setupTrackPlayer() {
await TrackPlayer.setupPlayer();
await TrackPlayer.updateOptions({
capabilities: [
TrackPlayer.CAPABILITY_PLAY,
TrackPlayer.CAPABILITY_PAUSE,
TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS,
TrackPlayer.CAPABILITY_STOP,
TrackPlayer.CAPABILITY_SEEK_TO,
]
});
2020-06-16 17:51:51 +02:00
}
setupTrackPlayer();
}, []);
2020-06-16 17:51:51 +02:00
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistedStore}>
2021-02-13 12:14:57 +01:00
<ColorSchemeContext.Provider value={theme}>
<NavigationContainer theme={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<Routes />
</NavigationContainer>
</ColorSchemeContext.Provider>
</PersistGate>
</Provider>
);
2020-06-16 17:51:51 +02:00
}