mirror of
https://github.com/anultravioletaurora/Jellify.git
synced 2025-12-30 18:30:47 -06:00
* OfflineMode * Template addition and Fixes * More Changes * More Changes * smol updates to provider run yarn format * update internet connection watcher colors and verbiage remove react native file access dependency * Offline changes * UI tweaks for offline indicator * get jest to pass --------- Co-authored-by: Ritesh Shukla <ritesh.shukla2@129net231.unica.it> Co-authored-by: Ritesh Shukla <ritesh.shukla2@M-LD4JMWLW26.local> Co-authored-by: Ritesh Shukla <75062358+riteshshukla04@users.noreply.github.com>
86 lines
2.8 KiB
TypeScript
86 lines
2.8 KiB
TypeScript
import './gesture-handler'
|
|
import React, { useState } from 'react'
|
|
import 'react-native-url-polyfill/auto'
|
|
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
|
|
import Jellify from './components/jellify'
|
|
import { TamaguiProvider, Theme } from 'tamagui'
|
|
import { useColorScheme } from 'react-native'
|
|
import jellifyConfig from './tamagui.config'
|
|
import { clientPersister } from './constants/storage'
|
|
import { queryClient } from './constants/query-client'
|
|
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
|
import TrackPlayer, { IOSCategory, IOSCategoryOptions } from 'react-native-track-player'
|
|
import { CAPABILITIES } from './player/constants'
|
|
import { createWorkletRuntime } from 'react-native-reanimated'
|
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
import { NavigationContainer } from '@react-navigation/native'
|
|
import { JellifyDarkTheme, JellifyLightTheme } from './components/theme'
|
|
import { requestStoragePermission } from './helpers/permisson-helpers'
|
|
|
|
export const backgroundRuntime = createWorkletRuntime('background')
|
|
|
|
export default function App(): React.JSX.Element {
|
|
const [playerIsReady, setPlayerIsReady] = useState<boolean>(false)
|
|
const isDarkMode = useColorScheme() === 'dark'
|
|
|
|
TrackPlayer.setupPlayer({
|
|
autoHandleInterruptions: true,
|
|
iosCategory: IOSCategory.Playback,
|
|
iosCategoryOptions: [IOSCategoryOptions.AllowAirPlay, IOSCategoryOptions.AllowBluetooth],
|
|
})
|
|
.then(() =>
|
|
TrackPlayer.updateOptions({
|
|
progressUpdateEventInterval: 1,
|
|
capabilities: CAPABILITIES,
|
|
notificationCapabilities: CAPABILITIES,
|
|
compactCapabilities: CAPABILITIES,
|
|
// ratingType: RatingType.Heart,
|
|
// likeOptions: {
|
|
// isActive: false,
|
|
// title: "Favorite"
|
|
// },
|
|
// dislikeOptions: {
|
|
// isActive: true,
|
|
// title: "Unfavorite"
|
|
// }
|
|
}),
|
|
)
|
|
.finally(() => {
|
|
setPlayerIsReady(true)
|
|
requestStoragePermission()
|
|
})
|
|
const getActiveTrack = async () => {
|
|
const track = await TrackPlayer.getActiveTrack()
|
|
console.log('playerIsReady', track)
|
|
}
|
|
getActiveTrack()
|
|
|
|
return (
|
|
<SafeAreaProvider>
|
|
<NavigationContainer theme={isDarkMode ? JellifyDarkTheme : JellifyLightTheme}>
|
|
<PersistQueryClientProvider
|
|
client={queryClient}
|
|
persistOptions={{
|
|
persister: clientPersister,
|
|
|
|
/**
|
|
* Infinity, since data can remain the
|
|
* same forever on the server
|
|
*/
|
|
maxAge: Infinity,
|
|
buster: '0.10.99',
|
|
}}
|
|
>
|
|
<GestureHandlerRootView>
|
|
<TamaguiProvider config={jellifyConfig}>
|
|
<Theme name={isDarkMode ? 'dark' : 'light'}>
|
|
{playerIsReady && <Jellify />}
|
|
</Theme>
|
|
</TamaguiProvider>
|
|
</GestureHandlerRootView>
|
|
</PersistQueryClientProvider>
|
|
</NavigationContainer>
|
|
</SafeAreaProvider>
|
|
)
|
|
}
|