mirror of
https://github.com/Jellify-Music/App.git
synced 2026-05-02 00:19:32 -05:00
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { useColorScheme } from "react-native";
|
|
import { Colors } from "react-native/Libraries/NewAppScreen";
|
|
import { setupPlayer } from "react-native-track-player/lib/src/trackPlayer";
|
|
import _ from "lodash";
|
|
import { JellyfinApiClientProvider, useApiClientContext } from "./jellyfin-api-provider";
|
|
import React, { } from "react";
|
|
import { DarkTheme, DefaultTheme, NavigationContainer } from "@react-navigation/native";
|
|
import Navigation from "./navigation";
|
|
import Login from "./Login/component";
|
|
import { JellyfinAuthenticationProvider } from "./Login/provider";
|
|
|
|
export default function Jellify(): React.JSX.Element {
|
|
|
|
const isDarkMode = useColorScheme() === 'dark';
|
|
|
|
setupPlayer();
|
|
|
|
// Attempt to create API instance, if it fails we aren't authenticated yet
|
|
const backgroundStyle = {
|
|
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
|
|
};
|
|
|
|
return (
|
|
<JellyfinApiClientProvider>
|
|
{conditionalHomeRender()}
|
|
</JellyfinApiClientProvider>
|
|
);
|
|
}
|
|
|
|
function conditionalHomeRender(): React.JSX.Element {
|
|
|
|
const isDarkMode = useColorScheme() === 'dark';
|
|
|
|
// If library ID hasn't been set, we haven't completed the auth flow
|
|
const { apiClient } = useApiClientContext();
|
|
|
|
return (
|
|
<NavigationContainer theme={isDarkMode ? DarkTheme : DefaultTheme}>
|
|
{ !_.isUndefined(apiClient) ? (
|
|
<Navigation />
|
|
) : (
|
|
<JellyfinAuthenticationProvider>
|
|
<Login />
|
|
</JellyfinAuthenticationProvider>
|
|
)}
|
|
</NavigationContainer>
|
|
);
|
|
} |