diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 333cf680..10b40da9 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -2,10 +2,8 @@ import React from 'react'; import { DarkTheme, NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; -import * as Application from 'expo-application'; -import { parse, SemVer } from 'semver'; +import { SemVer } from 'semver'; -import { useAppSelector } from '../redux/hooks'; import AppInfoHeader from '../src/components/Headers/AppInfoHeader'; import GameHeader from '../src/components/Headers/GameHeader'; import HomeHeader from '../src/components/Headers/HomeHeader'; @@ -18,13 +16,12 @@ import SettingsScreen from '../src/screens/SettingsScreen'; import EditPlayerHeader from './components/Headers/EditPlayerHeader'; import ShareHeader from './components/Headers/ShareHeader'; -import { getOnboardingSemVer } from './components/Onboarding/Onboarding'; -import logger from './Logger'; import EditPlayerScreen from './screens/EditPlayerScreen'; import ShareScreen from './screens/ShareScreen'; export type OnboardingScreenParamList = { onboarding: boolean; + version: SemVer; }; export type RootStackParamList = { @@ -54,28 +51,9 @@ const MyTheme = { }; export const Navigation = () => { - const onboardedStr = useAppSelector(state => state.settings.onboarded); - const onboardedSemVer = parse(onboardedStr); - const appVersion = new SemVer(Application.nativeApplicationVersion || '0.0.0'); - - logger.info(`App Version: ${appVersion}`); - logger.info(`Onboarded Version: ${onboardedSemVer}`); - - const onboarded = getOnboardingSemVer(onboardedSemVer) === undefined; - return ( - - {!onboarded && - - } + { }, }} /> - { - return ; - }, - }} - /> { }, })} /> - + { + return ; + }, }} /> diff --git a/src/components/AppInfo/RotatingIcon.tsx b/src/components/AppInfo/RotatingIcon.tsx index fcda61af..06768a0a 100644 --- a/src/components/AppInfo/RotatingIcon.tsx +++ b/src/components/AppInfo/RotatingIcon.tsx @@ -5,7 +5,6 @@ import { Image } from 'expo-image'; import { TouchableWithoutFeedback } from 'react-native'; import Animated, { Easing, - PinwheelIn, useAnimatedStyle, useSharedValue, withTiming @@ -28,7 +27,7 @@ const RotatingIcon: React.FunctionComponent = ({ }) => { await analytics().logEvent('app_icon'); }}> - + ; @@ -15,19 +15,21 @@ interface Props { const AppInfoHeader: React.FunctionComponent = ({ navigation }: Props) => { return ( - } - headerCenter={Settings} - /> + + { + navigation.goBack(); + }}> + Done + + ); }; -const styles = StyleSheet.create({ - title: { - color: 'white', - fontSize: 20, - fontVariant: ['tabular-nums'], - }, -}); - export default AppInfoHeader; diff --git a/src/components/Headers/CustomHeader.tsx b/src/components/Headers/CustomHeader.tsx index 50da4f4c..a4453967 100644 --- a/src/components/Headers/CustomHeader.tsx +++ b/src/components/Headers/CustomHeader.tsx @@ -8,7 +8,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'; interface Props { navigation: NativeStackNavigationProp; - headerLeft: React.ReactNode; + headerLeft?: React.ReactNode; headerCenter: React.ReactNode; headerRight?: React.ReactNode; animated?: boolean; diff --git a/src/components/Onboarding/Onboarding.test.ts b/src/components/Onboarding/Onboarding.test.ts index a1ac768b..df4fd7ff 100644 --- a/src/components/Onboarding/Onboarding.test.ts +++ b/src/components/Onboarding/Onboarding.test.ts @@ -1,28 +1,28 @@ import { SemVer } from 'semver'; -import { getOnboardingSemVer } from './Onboarding'; +import { getPendingOnboardingSemVer } from './Onboarding'; describe('onboarding', () => { it('should return the default if onboarded to 0.0.0', () => { - const applicableVersion = getOnboardingSemVer(new SemVer('0.0.0')); + const applicableVersion = getPendingOnboardingSemVer(new SemVer('0.0.0')); expect(applicableVersion).toBe('2.2.2'); }); it('should return the default if null', () => { - const applicableVersion = getOnboardingSemVer(null); + const applicableVersion = getPendingOnboardingSemVer(null); expect(applicableVersion).toBe('2.2.2'); }); it('should return the latest applicable screens', () => { - const applicableVersion = getOnboardingSemVer(new SemVer('2.4.0')); + const applicableVersion = getPendingOnboardingSemVer(new SemVer('2.4.0')); expect(applicableVersion).toBe('2.5.0'); }); it('should not return if caught up', () => { - const applicableVersion = getOnboardingSemVer(new SemVer('2.6.0')); + const applicableVersion = getPendingOnboardingSemVer(new SemVer('2.6.0')); expect(applicableVersion).toBeUndefined(); }); diff --git a/src/components/Onboarding/Onboarding.ts b/src/components/Onboarding/Onboarding.ts index 75e09f02..167963e5 100644 --- a/src/components/Onboarding/Onboarding.ts +++ b/src/components/Onboarding/Onboarding.ts @@ -116,7 +116,7 @@ const finalScreen: OnboardingScreenItem[] = [{ backgroundColor: '#8ca2b8', }]; -export const getOnboardingSemVer = (onboardedSemVer: SemVer | null): string | undefined => { +export const getPendingOnboardingSemVer = (onboardedSemVer: SemVer | null): string | undefined => { const keys = Object.keys(onboardingScreens) .sort((a, b) => compare(new SemVer(a), new SemVer(b))); @@ -134,7 +134,7 @@ export const getOnboardingSemVer = (onboardedSemVer: SemVer | null): string | un }; export const getOnboardingScreens = (onboardedSemVer: SemVer): OnboardingScreenItem[] => { - const applicableVersion = getOnboardingSemVer(onboardedSemVer); + const applicableVersion = getPendingOnboardingSemVer(onboardedSemVer); if (!applicableVersion) { return finalScreen; diff --git a/src/components/Onboarding/OnboardingPage.tsx b/src/components/Onboarding/OnboardingPage.tsx new file mode 100644 index 00000000..b0d91e22 --- /dev/null +++ b/src/components/Onboarding/OnboardingPage.tsx @@ -0,0 +1,144 @@ +import React from 'react'; + +import { + ImageURISource, + Animated as RNAnimated, + StyleSheet, + Text, + View +} from 'react-native'; +import { Button } from 'react-native-elements'; +import Animated from 'react-native-reanimated'; +import Video from 'react-native-video'; + +import { OnboardingScreenItem } from './Onboarding'; + +interface Props { + active?: boolean; + closeOnboarding: () => void; + index: number; + isLast: boolean; + item: OnboardingScreenItem; + width: number; +} + +const OnboardingPage: React.FC = React.memo(({ + active = false, + closeOnboarding, + isLast, + item, + width, +}) => { + let media; + switch (item.media.type) { + case 'image': + media = ( + + ); + break; + case 'video': + media = ( + + + ); + break; + } + + return ( + + + {item.title} + + + + {media} + + + + + {item.description} + + + {isLast && +