diff options
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/com/auth/Onboarding.tsx | 40 | ||||
-rw-r--r-- | src/view/com/auth/withAuthRequired.tsx | 4 | ||||
-rw-r--r-- | src/view/com/modals/Modal.web.tsx | 9 | ||||
-rw-r--r-- | src/view/com/modals/OnboardingModal.tsx | 40 | ||||
-rw-r--r-- | src/view/screens/Home.tsx | 2 |
5 files changed, 45 insertions, 50 deletions
diff --git a/src/view/com/auth/Onboarding.tsx b/src/view/com/auth/Onboarding.tsx new file mode 100644 index 000000000..f43d5d93a --- /dev/null +++ b/src/view/com/auth/Onboarding.tsx @@ -0,0 +1,40 @@ +import React from 'react' +import {SafeAreaView} from 'react-native' +import {observer} from 'mobx-react-lite' +import {ErrorBoundary} from 'view/com/util/ErrorBoundary' +import {s} from 'lib/styles' +import {usePalette} from 'lib/hooks/usePalette' +import {useStores} from 'state/index' +import {useAnalytics} from 'lib/analytics/analytics' +import {CenteredView} from '../util/Views' +import {Welcome} from './onboarding/Welcome' +import {RecommendedFeeds} from './onboarding/RecommendedFeeds' + +export const Onboarding = observer(() => { + const pal = usePalette('default') + const store = useStores() + const {screen} = useAnalytics() + + React.useEffect(() => { + screen('Onboarding') + store.shell.setMinimalShellMode(true) + }, [store, screen]) + + const next = () => store.onboarding.next() + const skip = () => store.onboarding.skip() + + return ( + <CenteredView style={[s.hContentRegion, pal.view]}> + <SafeAreaView testID="noSessionView" style={s.hContentRegion}> + <ErrorBoundary> + {store.onboarding.step === 'Welcome' && ( + <Welcome skip={skip} next={next} /> + )} + {store.onboarding.step === 'RecommendedFeeds' && ( + <RecommendedFeeds next={next} /> + )} + </ErrorBoundary> + </SafeAreaView> + </CenteredView> + ) +}) diff --git a/src/view/com/auth/withAuthRequired.tsx b/src/view/com/auth/withAuthRequired.tsx index 8e57669be..c81c2d5df 100644 --- a/src/view/com/auth/withAuthRequired.tsx +++ b/src/view/com/auth/withAuthRequired.tsx @@ -9,6 +9,7 @@ import {observer} from 'mobx-react-lite' import {useStores} from 'state/index' import {CenteredView} from '../util/Views' import {LoggedOut} from './LoggedOut' +import {Onboarding} from './Onboarding' import {Text} from '../util/text/Text' import {usePalette} from 'lib/hooks/usePalette' import {STATUS_PAGE_URL} from 'lib/constants' @@ -24,6 +25,9 @@ export const withAuthRequired = <P extends object>( if (!store.session.hasSession) { return <LoggedOut /> } + if (store.onboarding.isActive) { + return <Onboarding /> + } return <Component {...props} /> }) diff --git a/src/view/com/modals/Modal.web.tsx b/src/view/com/modals/Modal.web.tsx index 20da99e81..3aeddeb6b 100644 --- a/src/view/com/modals/Modal.web.tsx +++ b/src/view/com/modals/Modal.web.tsx @@ -27,7 +27,6 @@ import * as ContentFilteringSettingsModal from './ContentFilteringSettings' import * as ContentLanguagesSettingsModal from './lang-settings/ContentLanguagesSettings' import * as PostLanguagesSettingsModal from './lang-settings/PostLanguagesSettings' import * as ModerationDetailsModal from './ModerationDetails' -import * as OnboardingModal from './OnboardingModal' import * as PreferencesHomeFeed from './PreferencesHomeFeed' export const ModalsContainer = observer(function ModalsContainer() { @@ -55,11 +54,7 @@ function Modal({modal}: {modal: ModalIface}) { } const onPressMask = () => { - if ( - modal.name === 'crop-image' || - modal.name === 'edit-image' || - modal.name === 'onboarding' - ) { + if (modal.name === 'crop-image' || modal.name === 'edit-image') { return // dont close on mask presses during crop } store.shell.closeModal() @@ -114,8 +109,6 @@ function Modal({modal}: {modal: ModalIface}) { element = <PreferencesHomeFeed.Component /> } else if (modal.name === 'moderation-details') { element = <ModerationDetailsModal.Component {...modal} /> - } else if (modal.name === 'onboarding') { - element = <OnboardingModal.Component /> } else { return null } diff --git a/src/view/com/modals/OnboardingModal.tsx b/src/view/com/modals/OnboardingModal.tsx deleted file mode 100644 index 3862736cf..000000000 --- a/src/view/com/modals/OnboardingModal.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react' -import {StyleSheet, View} from 'react-native' -import {useStores} from 'state/index' - -import {usePalette} from 'lib/hooks/usePalette' -import {isDesktopWeb} from 'platform/detection' -import {Welcome} from '../auth/onboarding/Welcome' -import {observer} from 'mobx-react-lite' -import {RecommendedFeeds} from '../auth/onboarding/RecommendedFeeds' - -export const snapPoints = ['90%'] - -export const Component = observer(({}: {}) => { - const pal = usePalette('default') - const store = useStores() - - const next = () => { - const nextScreenName = store.onboarding.next() - if (nextScreenName === 'Home') { - store.shell.closeModal() - } - } - - return ( - <View style={[styles.container, pal.view]} testID="onboardingModal"> - {store.onboarding.step === 'Welcome' ? <Welcome next={next} /> : null} - {store.onboarding.step === 'RecommendedFeeds' ? ( - <RecommendedFeeds next={next} /> - ) : null} - </View> - ) -}) - -const styles = StyleSheet.create({ - container: { - flex: 1, - paddingBottom: isDesktopWeb ? 0 : 50, - maxHeight: '750px', - }, -}) diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 4397200e4..7262756d3 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -21,7 +21,6 @@ import {useOnMainScroll} from 'lib/hooks/useOnMainScroll' import {useAnalytics} from 'lib/analytics/analytics' import {ComposeIcon2} from 'lib/icons' import {isDesktopWeb, isMobileWebMediaQuery, isWeb} from 'platform/detection' -import {useOnboarding} from 'lib/hooks/useOnboarding' const HEADER_OFFSET_MOBILE = 78 const HEADER_OFFSET_DESKTOP = 50 @@ -40,7 +39,6 @@ export const HomeScreen = withAuthRequired( const [requestedCustomFeeds, setRequestedCustomFeeds] = React.useState< string[] >([]) - useOnboarding() React.useEffect(() => { const {pinned} = store.me.savedFeeds |