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

55 lines
2.0 KiB
TypeScript
Raw Normal View History

import React, { useEffect } from 'react';
2020-06-17 14:58:04 +02:00
import { Provider } from 'react-redux';
import TrackPlayer, { Capability } 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';
import DownloadManager from './DownloadManager';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
// import ErrorReportingAlert from 'utility/ErrorReportingAlert';
2020-06-16 17:51:51 +02:00
export default function App(): JSX.Element {
const colorScheme = useColorScheme();
// const colorScheme = 'dark';
2021-02-13 12:14:57 +01:00
const theme = themes[colorScheme || 'light'];
2020-06-16 17:51:51 +02:00
useEffect(() => {
async function setupTrackPlayer() {
await TrackPlayer.setupPlayer();
await TrackPlayer.updateOptions({
capabilities: [
Capability.Play,
Capability.Pause,
Capability.SkipToNext,
Capability.SkipToPrevious,
Capability.Stop,
Capability.SeekTo,
],
stopWithApp: true
});
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}>
<GestureHandlerRootView style={{ flex: 1 }}>
<Routes />
<DownloadManager />
</GestureHandlerRootView>
2021-02-13 12:14:57 +01:00
</NavigationContainer>
</ColorSchemeContext.Provider>
</PersistGate>
</Provider>
);
2020-06-16 17:51:51 +02:00
}