fix onboarding on web

This commit is contained in:
Ansh Nanda 2023-08-29 12:16:26 -07:00
parent 742440c22d
commit bf37913701
11 changed files with 235 additions and 113 deletions

View file

@ -21,6 +21,7 @@ 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
@ -31,7 +32,7 @@ const POLL_FREQ = 30e3 // 30sec
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
export const HomeScreen = withAuthRequired(
observer(({navigation}: Props) => {
observer(({}: Props) => {
const store = useStores()
const pagerRef = React.useRef<PagerRef>(null)
const [selectedPage, setSelectedPage] = React.useState(0)
@ -39,12 +40,7 @@ export const HomeScreen = withAuthRequired(
const [requestedCustomFeeds, setRequestedCustomFeeds] = React.useState<
string[]
>([])
React.useEffect(() => {
if (store.onboarding.isActive) {
navigation.navigate('Welcome')
}
}, [store.onboarding.isActive, navigation])
useOnboarding()
React.useEffect(() => {
const {pinned} = store.me.savedFeeds

View file

@ -0,0 +1,20 @@
import React from 'react'
import {NativeStackScreenProps} from '@react-navigation/native-stack'
import {HomeTabNavigatorParams} from 'lib/routes/types'
import {useStores} from 'state/index'
import {observer} from 'mobx-react-lite'
import {RecommendedFeeds} from 'view/com/auth/onboarding/RecommendedFeeds'
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'RecommendedFeeds'>
export const RecommendedFeedsScreen = observer(({navigation}: Props) => {
const store = useStores()
const next = () => {
const nextScreenName = store.onboarding.next('RecommendedFeeds')
if (nextScreenName) {
navigation.navigate(nextScreenName)
}
}
return <RecommendedFeeds next={next} />
})

View file

@ -0,0 +1,32 @@
import React from 'react'
import {NativeStackScreenProps} from '@react-navigation/native-stack'
import {HomeTabNavigatorParams} from 'lib/routes/types'
import {useStores} from 'state/index'
import {observer} from 'mobx-react-lite'
import {Welcome} from 'view/com/auth/onboarding/Welcome'
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Welcome'>
export const WelcomeScreen = observer(({navigation}: Props) => {
const store = useStores()
// make sure bottom nav is hidden
React.useEffect(() => {
if (!store.shell.minimalShellMode) {
store.shell.setMinimalShellMode(true)
}
}, [store.shell.minimalShellMode, store])
const next = () => {
const nextScreenName = store.onboarding.next('Welcome')
if (nextScreenName) {
navigation.navigate(nextScreenName)
}
}
const skip = () => {
store.onboarding.skip()
navigation.navigate('Home')
}
return <Welcome next={next} skip={skip} />
})