Skip to content

Commit 75702bf

Browse files
committed
Add onboarding screen and update navigation flow for first-time users
1 parent ecd65e0 commit 75702bf

File tree

6 files changed

+61
-16
lines changed

6 files changed

+61
-16
lines changed

App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { Dimensions, SafeAreaView, useColorScheme } from 'react-native'
5555
import { GestureHandlerRootView } from 'react-native-gesture-handler'
5656
import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated'
5757
import './global.css'
58+
import Onboarding from '@screens/Onboarding'
5859

5960
function App(): React.JSX.Element {
6061
const scheme = useColorScheme()
@@ -156,6 +157,7 @@ export type RootStackParamList = {
156157
FCFS: undefined
157158
SJF: undefined
158159
Chart: ChartParamList
160+
Onboarding: undefined
159161
}
160162

161163
const Stack = createStackNavigator<RootStackParamList>()
@@ -252,6 +254,7 @@ function Navigation() {
252254
<Stack.Screen name='FCFS' component={FCFS} options={GestureEnabled} />
253255
<Stack.Screen name='SJF' component={SJF} options={GestureEnabled} />
254256
<Stack.Screen name='Chart' component={Chart} options={IOS_BOTTOM_STYLE} />
257+
<Stack.Screen name='Onboarding' component={Onboarding} options={NO_ANIMATION}/>
255258
</Stack.Navigator>
256259
</>
257260
)

src/screens/Onboarding.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import Animations from '@assets/animations/animations'
2+
import Btn from '@components/Button'
3+
import { Lottie } from '@components/Lottie'
4+
import { PaddingBottom, PaddingTop } from '@components/SafePadding'
5+
import { W } from '@utils/dimensions'
6+
import { Bold, F, SemiBold } from '@utils/fonts'
7+
import S from '@utils/storage'
8+
import { NavProp } from '@utils/types'
9+
import { View } from 'react-native'
10+
11+
export default function Onboarding({ navigation }: NavProp) {
12+
function handlePress() {
13+
S.set('isOpenedApp', 'true')
14+
navigation.reset({ index: 0, routes: [{ name: 'Login' }] })
15+
}
16+
return (
17+
<View className='gap-5-center flex-1 items-center justify-between'>
18+
<PaddingTop />
19+
<View className='flex-1 items-center justify-between px-8'>
20+
<View />
21+
<View>
22+
<Lottie source={Animations.welcome} style={{ width: W * 0.65, height: W * 0.65, marginTop: -50 }} />
23+
<View className='px-4'>
24+
<Bold className='text mt-16 text-center text-4xl'>Welcome to Tech Triangle</Bold>
25+
<SemiBold className='text mt-8 text-center opacity-80' style={F.F12}>
26+
Organize your life and work with our tools. Get started now! Click the button below to start using our
27+
tools.
28+
</SemiBold>
29+
</View>
30+
</View>
31+
<Btn title='Get Started' onPress={handlePress} />
32+
</View>
33+
<View className='h-5'></View>
34+
<PaddingBottom />
35+
</View>
36+
)
37+
}

src/screens/auth/Login.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default function Login({ navigation }: NavProp) {
6565
},
6666
onError: (error) => {
6767
console.log(error)
68-
alert('Error', 'An error occurred')
68+
alert('Error', error.message || 'An unexpected error occurred')
6969
},
7070
})
7171

@@ -83,7 +83,7 @@ export default function Login({ navigation }: NavProp) {
8383
<View className='pb-5'>
8484
<PaddingTop />
8585
<View className='px-5 py-5 pb-8'>
86-
<Bold className='pb-3 text-3xl text-black dark:text-white'>Welcome to Tech Triangle</Bold>
86+
<Bold className='pb-3 text-3xl text-black dark:text-white'>Login to Tech Triangle</Bold>
8787
<Lottie source={Animations['welcome']} style={{ width: W * 0.6, height: W * 0.6 }} />
8888
</View>
8989
<Gap12>
@@ -95,6 +95,8 @@ export default function Login({ navigation }: NavProp) {
9595
value={username}
9696
onChangeText={setUsername}
9797
/>
98+
</SettGroup>
99+
<SettGroup title='Enter your password'>
98100
<Input
99101
value={password}
100102
autoComplete='password'
@@ -106,13 +108,8 @@ export default function Login({ navigation }: NavProp) {
106108
/>
107109
</SettGroup>
108110
<SettText>
109-
Enter your email or username to login to your account. If you don't have an account, you can create one by
110-
clicking the button below.
111-
</SettText>
112-
113-
<SettText>
114-
Enter your password to login to your account. If you forgot your password, you can reset it by clicking the
115-
button below.
111+
Enter your email or username to login to your account. If you don't have an account, you can create one. Or
112+
if you forgot your password, you can reset it.
116113
</SettText>
117114
</Gap12>
118115

src/screens/splash/Splash.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import authStore from '@/zustand/authStore'
22
import { navigationStore } from '@/zustand/navigationStore'
3+
import S from '@utils/storage'
34
import type { NavProp } from '@utils/types'
45
import { useEffect } from 'react'
5-
import { Text, View } from 'react-native'
6+
import { View } from 'react-native'
67

78
export default function Splash({ navigation }: NavProp) {
89
const { token } = authStore()
@@ -13,13 +14,14 @@ export default function Splash({ navigation }: NavProp) {
1314
}, [navigation, setNavigation])
1415

1516
useEffect(() => {
17+
const isOpenedApp = S.getBoolean('isOpenedApp')
18+
if (!isOpenedApp) {
19+
navigation.replace('Onboarding')
20+
return
21+
}
1622
if (!token) navigation.replace('Login')
1723
else navigation.replace('Home')
1824
}, [navigation, token])
1925

20-
return (
21-
<View className='flex-1 items-center justify-center'>
22-
<Text className='text-center'>Splash</Text>
23-
</View>
24-
)
26+
return <View className='flex-1 items-center justify-center'></View>
2527
}

src/utils/fonts.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const F = StyleSheet.create({
7979
},
8080
F12: {
8181
fontSize: 12,
82+
lineHeight: 18,
8283
},
8384
F12_5: {
8485
fontSize: 12.5,

src/utils/storage.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ type CoordinateNotesStorage = Store<typeof CoordinateNotesStorage>
146146
type UserProfileStorage = Store<typeof UserProfileStorage>
147147
type AppLockStorage = Store<typeof AppLockStorage>
148148
type UserStorage = Store<typeof UserStorage>
149-
type misc = 'misc'
149+
type misc = 'misc' | 'isOpenedApp'
150150
export type StorageKeys =
151151
| WeatherStorage
152152
| DeveloperStorage
@@ -178,6 +178,10 @@ function getParsed<T>(key: StorageKeys) {
178178
return JSON.parse(ls.getString(key) || 'null') as T
179179
}
180180

181+
function getBoolean(key: StorageKeys) {
182+
return ls.getBoolean(key)
183+
}
184+
181185
function set(key: StorageKeys, value: string) {
182186
ls.set(key, value)
183187
}
@@ -190,6 +194,7 @@ const S = {
190194
getParsed,
191195
getMemoParsed: useMemoParsed,
192196
get,
197+
getBoolean,
193198
set,
194199
remove,
195200
ls,

0 commit comments

Comments
 (0)