Skip to content

Commit 46516fb

Browse files
author
Guillermo Machado
committed
feat: move www screen to tw, use component Link instead of navigation.push and add translations
1 parent 2cf2dea commit 46516fb

File tree

8 files changed

+57
-57
lines changed

8 files changed

+57
-57
lines changed

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ VAR_NUMBER=
33
VAR_BOOL=
44
SECRET_KEY=
55
WEBSITE_URL=
6-
TERMS_AND_CONDITIONS_URL=
6+
TERMS_OF_SERVICE_URL=

env.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const clientEnvSchema = z.object({
138138
API_URL: z.string(),
139139
VAR_NUMBER: z.number(),
140140
VAR_BOOL: z.boolean(),
141-
TERMS_AND_CONDITIONS_URL: z.string(),
141+
TERMS_OF_SERVICE_URL: z.string(),
142142
WEBSITE_URL: z.string(),
143143
});
144144

@@ -165,7 +165,7 @@ const _clientEnv = {
165165
VAR_NUMBER: parseNumber(process.env.VAR_NUMBER),
166166
VAR_BOOL: parseBoolean(process.env.VAR_BOOL),
167167
WEBSITE_URL: parseString(process.env.WEBSITE_URL),
168-
TERMS_AND_CONDITIONS_URL: parseString(process.env.TERMS_AND_CONDITIONS_URL),
168+
TERMS_OF_SERVICE_URL: parseString(process.env.TERMS_OF_SERVICE_URL),
169169
};
170170

171171
/**

src/app/(app)/settings.tsx

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Env } from '@env';
2-
import { router } from 'expo-router';
2+
import { Link } from 'expo-router';
33
import { useColorScheme } from 'nativewind';
44
import React from 'react';
55

@@ -32,25 +32,33 @@ export default function Settings() {
3232
</ItemsContainer>
3333

3434
<ItemsContainer title="settings.links">
35-
<Item
36-
text="settings.terms"
37-
onPress={() => {
38-
const url = encodeURIComponent(Env.TERMS_AND_CONDITIONS_URL);
39-
const title = encodeURIComponent('Terms & Conditions');
40-
41-
router.push(`/www?url=${url}&title=${title}`);
35+
<Link
36+
asChild
37+
href={{
38+
pathname: '/www',
39+
params: {
40+
url: Env.TERMS_OF_SERVICE_URL,
41+
title: translate('settings.terms'),
42+
},
4243
}}
43-
/>
44-
<Item
45-
text="settings.website"
46-
icon={<Website color={iconColor} />}
47-
onPress={() => {
48-
const url = encodeURIComponent(Env.WEBSITE_URL);
49-
const title = encodeURIComponent('Website');
50-
51-
router.push(`/www?url=${url}&title=${title}`);
44+
>
45+
<Item text="settings.terms" />
46+
</Link>
47+
<Link
48+
asChild
49+
href={{
50+
pathname: '/www',
51+
params: {
52+
url: Env.WEBSITE_URL,
53+
title: translate('settings.website'),
54+
},
5255
}}
53-
/>
56+
>
57+
<Item
58+
text="settings.website"
59+
icon={<Website color={iconColor} />}
60+
/>
61+
</Link>
5462
</ItemsContainer>
5563

5664
<ItemsContainer title="settings.about">

src/app/onboarding.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
import { useRouter } from 'expo-router';
22

33
import { Cover } from '@/components/cover';
4+
import { translate } from '@/core';
45
import { useIsFirstTime } from '@/core/hooks';
56
import { Button, FocusAwareStatusBar, SafeAreaView, Text, View } from '@/ui';
7+
68
export default function Onboarding() {
79
const [, setIsFirstTime] = useIsFirstTime();
810
const router = useRouter();
11+
912
return (
10-
<View className="flex h-full items-center justify-center">
13+
<View className="flex h-full items-center justify-center">
1114
<FocusAwareStatusBar />
1215
<View className="w-full flex-1">
1316
<Cover />
1417
</View>
15-
<View className="justify-end ">
18+
<View className="justify-end">
1619
<Text className="my-3 text-center text-5xl font-bold">
17-
React Native Template
20+
{translate('onboarding.title')}
1821
</Text>
1922
<Text className="mb-2 text-center text-lg text-gray-600">
20-
The right way to build your mobile app
23+
{translate('onboarding.subtitle')}
2124
</Text>
2225

2326
<Text className="my-1 pt-6 text-left text-lg">
24-
🚀 Production-ready{' '}
27+
{translate('onboarding.features.production_ready')}
2528
</Text>
2629
<Text className="my-1 text-left text-lg">
27-
🥷 Developer experience + Productivity
30+
{translate('onboarding.features.developer_experience')}
2831
</Text>
2932
<Text className="my-1 text-left text-lg">
30-
🧩 Minimal code and dependencies
33+
{translate('onboarding.features.minimal_code')}
3134
</Text>
3235
<Text className="my-1 text-left text-lg">
33-
💪 well maintained third-party libraries
36+
{translate('onboarding.features.well_maintained_libraries')}
3437
</Text>
3538
</View>
3639
<SafeAreaView className="mt-6">
3740
<Button
38-
label="Let's Get Started"
41+
label={translate('onboarding.button_label')}
3942
onPress={() => {
4043
setIsFirstTime(false);
4144
router.replace('/sign-in');

src/app/sign-in.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useRouter } from 'expo-router';
2+
import React from 'react';
23
import { showMessage } from 'react-native-flash-message';
34

45
import { useLogin } from '@/api/auth/use-login';

src/app/www.tsx

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useLocalSearchParams, useNavigation, useRouter } from 'expo-router';
22
import React, { useEffect } from 'react';
3-
import { StyleSheet, View } from 'react-native';
3+
import { View } from 'react-native';
44
import { WebView } from 'react-native-webview';
55

66
import { Text } from '@/ui';
@@ -20,39 +20,19 @@ export default function WWW() {
2020

2121
if (!url || typeof url !== 'string') {
2222
return (
23-
<View style={styles.errorContainer}>
24-
<Text style={styles.errorText}>Invalid URL</Text>
23+
<View className="flex-1 items-center justify-center bg-white">
24+
<Text className="text-lg text-red-500">Invalid URL</Text>
2525
</View>
2626
);
2727
}
2828

2929
return (
30-
<View style={styles.container}>
30+
<View className="flex-1 bg-white">
3131
<WebView
3232
source={{ uri: url }}
33-
style={styles.webview}
33+
className="flex-1"
3434
onError={() => router.back()}
3535
/>
3636
</View>
3737
);
3838
}
39-
40-
const styles = StyleSheet.create({
41-
container: {
42-
flex: 1,
43-
backgroundColor: 'white',
44-
},
45-
webview: {
46-
flex: 1,
47-
},
48-
errorContainer: {
49-
flex: 1,
50-
justifyContent: 'center',
51-
alignItems: 'center',
52-
backgroundColor: 'white',
53-
},
54-
errorText: {
55-
color: 'red',
56-
fontSize: 16,
57-
},
58-
});

src/core/i18n/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('getLanguage', () => {
3838

3939
describe('translate', () => {
4040
it('should return translated string', () => {
41-
const key: TxKeyPath = 'onboarding.message';
41+
const key: TxKeyPath = 'onboarding.title';
4242
const options = { lang: 'en' };
4343
const translatedString = translate(key, options);
4444
expect(translatedString).toBe('Welcome to rootstrap app site');

src/translations/en.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
"title": "Forgot your password?"
1717
},
1818
"onboarding": {
19-
"message": "Welcome to rootstrap app site"
19+
"button_label": "Let's Get Started",
20+
"features": {
21+
"developer_experience": "🥷 Developer experience + Productivity",
22+
"minimal_code": "🧩 Minimal code and dependencies",
23+
"production_ready": "🚀 Production-ready",
24+
"well_maintained_libraries": "💪 Well maintained third-party libraries"
25+
},
26+
"subtitle": "The right way to build your mobile app",
27+
"title": "React Native Template"
2028
},
2129
"settings": {
2230
"about": "About",

0 commit comments

Comments
 (0)