From 21edbde95baf0cfbcd5adebc5dc098ad70703403 Mon Sep 17 00:00:00 2001 From: Martin Salles Date: Thu, 28 Dec 2023 12:14:16 +0100 Subject: [PATCH 1/2] Remove safe area context --- package.json | 1 - src/App.js | 75 +++++++++---------- src/screens/HomeScreen.js | 5 +- .../__snapshots__/HomeScreen.test.js.snap | 12 +-- yarn.lock | 5 -- 5 files changed, 40 insertions(+), 58 deletions(-) diff --git a/package.json b/package.json index d191573..d7fb0eb 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "react": "18.2.0", "react-native": "0.72.6", "react-native-elements": "^3.4.2", - "react-native-safe-area-context": "4.6.3", "react-native-screens": "~3.22.0", "react-native-toast-message": "^2.1.7" }, diff --git a/src/App.js b/src/App.js index 287d2cd..1379946 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,6 @@ import { ActivityIndicator } from 'react-native'; import { DefaultTheme, NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; -import { SafeAreaProvider } from 'react-native-safe-area-context'; import { ThemeProvider } from 'react-native-elements'; import Toast, { BaseToast } from 'react-native-toast-message'; @@ -40,43 +39,41 @@ const toastConfig = { export default function App() { return ( - - - } - > - - - - - - - - - - - - + + } + > + + + + + + + + + + + ); } diff --git a/src/screens/HomeScreen.js b/src/screens/HomeScreen.js index f2688c9..09bc2bd 100644 --- a/src/screens/HomeScreen.js +++ b/src/screens/HomeScreen.js @@ -3,7 +3,6 @@ import { StatusBar } from 'expo-status-bar'; import { StyleSheet, Text, View, Pressable, Image } from 'react-native'; import { Button } from 'react-native-elements'; import { MaterialCommunityIcons } from '@expo/vector-icons'; -import { SafeAreaView } from 'react-native-safe-area-context'; import theme from '../utils/theme.js'; import questions from '../../data/questions'; @@ -12,7 +11,7 @@ import I18n from '../utils/i18n'; export default (props) => { return ( - + @@ -45,7 +44,7 @@ export default (props) => { - + ); }; diff --git a/src/screens/__tests__/__snapshots__/HomeScreen.test.js.snap b/src/screens/__tests__/__snapshots__/HomeScreen.test.js.snap index 5dfc078..992480c 100644 --- a/src/screens/__tests__/__snapshots__/HomeScreen.test.js.snap +++ b/src/screens/__tests__/__snapshots__/HomeScreen.test.js.snap @@ -1,15 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` renders correctly 1`] = ` - renders correctly 1`] = ` - + `; diff --git a/yarn.lock b/yarn.lock index 033e59f..3df0c34 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7788,11 +7788,6 @@ react-native-ratings@8.0.4: dependencies: lodash "^4.17.15" -react-native-safe-area-context@4.6.3: - version "4.6.3" - resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.6.3.tgz#f06cfea05b1c4b018aa9758667a109f619c62b55" - integrity sha512-3CeZM9HFXkuqiU9HqhOQp1yxhXw6q99axPWrT+VJkITd67gnPSU03+U27Xk2/cr9XrLUnakM07kj7H0hdPnFiQ== - react-native-screens@~3.22.0: version "3.22.1" resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.22.1.tgz#b0eb0696dbf1f9a852061cc71c0f8cdb95ed8e53" From 4552725a84f5e4aa4da7628e1193b220dc40dab1 Mon Sep 17 00:00:00 2001 From: Martin Salles Date: Thu, 28 Dec 2023 13:29:48 +0100 Subject: [PATCH 2/2] Try to migrate to Expo router --- app.json | 4 +- babel.config.js | 1 + index.js | 5 +- package.json | 6 + .../__snapshots__/about.test.js.snap} | 0 .../__snapshots__/history.test.js.snap} | 0 .../__snapshots__/index.test.js.snap} | 43 +--- .../__snapshots__/options.test.js.snap} | 0 .../__snapshots__/quizz.test.js.snap} | 0 .../__snapshots__/rules.test.js.snap} | 0 .../__tests__/about.test.js} | 2 +- .../__tests__/history.test.js} | 2 +- .../__tests__/index.test.js} | 6 +- .../__tests__/options.test.js} | 2 +- .../__tests__/quizz.test.js} | 2 +- .../__tests__/rules.test.js} | 2 +- src/app/_layout.js | 46 ++++ src/{screens/AboutScreen.js => app/about.js} | 1 + .../HistoryScreen.js => app/history.js} | 0 src/{screens/HomeScreen.js => app/index.js} | 36 ++- .../OptionsScreen.js => app/options.js} | 18 +- src/{screens/QuizzScreen.js => app/quizz.js} | 10 +- src/{screens/RulesScreen.js => app/rules.js} | 9 +- src/components/Report.js | 21 +- yarn.lock | 240 ++++++++++++++++-- 25 files changed, 346 insertions(+), 110 deletions(-) rename src/{screens/__tests__/__snapshots__/AboutScreen.test.js.snap => app/__tests__/__snapshots__/about.test.js.snap} (100%) rename src/{screens/__tests__/__snapshots__/HistoryScreen.test.js.snap => app/__tests__/__snapshots__/history.test.js.snap} (100%) rename src/{screens/__tests__/__snapshots__/HomeScreen.test.js.snap => app/__tests__/__snapshots__/index.test.js.snap} (88%) rename src/{screens/__tests__/__snapshots__/OptionsScreen.test.js.snap => app/__tests__/__snapshots__/options.test.js.snap} (100%) rename src/{screens/__tests__/__snapshots__/QuizzScreen.test.js.snap => app/__tests__/__snapshots__/quizz.test.js.snap} (100%) rename src/{screens/__tests__/__snapshots__/RulesScreen.test.js.snap => app/__tests__/__snapshots__/rules.test.js.snap} (100%) rename src/{screens/__tests__/AboutScreen.test.js => app/__tests__/about.test.js} (85%) rename src/{screens/__tests__/HistoryScreen.test.js => app/__tests__/history.test.js} (87%) rename src/{screens/__tests__/HomeScreen.test.js => app/__tests__/index.test.js} (58%) rename src/{screens/__tests__/OptionsScreen.test.js => app/__tests__/options.test.js} (84%) rename src/{screens/__tests__/QuizzScreen.test.js => app/__tests__/quizz.test.js} (94%) rename src/{screens/__tests__/RulesScreen.test.js => app/__tests__/rules.test.js} (88%) create mode 100644 src/app/_layout.js rename src/{screens/AboutScreen.js => app/about.js} (99%) rename src/{screens/HistoryScreen.js => app/history.js} (100%) rename src/{screens/HomeScreen.js => app/index.js} (71%) rename src/{screens/OptionsScreen.js => app/options.js} (92%) rename src/{screens/QuizzScreen.js => app/quizz.js} (90%) rename src/{screens/RulesScreen.js => app/rules.js} (95%) diff --git a/app.json b/app.json index 8d85077..e69a936 100644 --- a/app.json +++ b/app.json @@ -3,6 +3,7 @@ "name": "Timeout Ultimate", "slug": "timeout-ultimate", "version": "5.0.1", + "scheme": "timeout-ultimate", "orientation": "portrait", "icon": "./assets/icon.png", "splash": { @@ -37,7 +38,8 @@ } }, "plugins": [ - "expo-localization" + "expo-localization", + "expo-router" ], "runtimeVersion": { "policy": "sdkVersion" diff --git a/babel.config.js b/babel.config.js index 9d89e13..e1cbf6f 100644 --- a/babel.config.js +++ b/babel.config.js @@ -2,5 +2,6 @@ module.exports = function (api) { api.cache(true); return { presets: ['babel-preset-expo'], + plugins: ['expo-router/babel'], }; }; diff --git a/index.js b/index.js index c1c862e..5b83418 100644 --- a/index.js +++ b/index.js @@ -1,4 +1 @@ -import { registerRootComponent } from 'expo'; -import App from './src/App'; - -registerRootComponent(App); +import 'expo-router/entry'; diff --git a/package.json b/package.json index d7fb0eb..19356f4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "timeout-ultimate", + "main": "expo-router/entry", "version": "1.0.0", "scripts": { "start": "expo start", @@ -17,8 +18,11 @@ "@react-navigation/native-stack": "^6.9.17", "expo": "^49.0.21", "expo-clipboard": "~4.3.1", + "expo-constants": "~14.4.2", + "expo-linking": "~5.0.2", "expo-localization": "~14.3.0", "expo-mail-composer": "~12.3.0", + "expo-router": "^2.0.0", "expo-splash-screen": "~0.20.5", "expo-status-bar": "~1.6.0", "expo-updates": "~0.18.17", @@ -28,6 +32,8 @@ "react": "18.2.0", "react-native": "0.72.6", "react-native-elements": "^3.4.2", + "react-native-gesture-handler": "~2.12.0", + "react-native-safe-area-context": "4.6.3", "react-native-screens": "~3.22.0", "react-native-toast-message": "^2.1.7" }, diff --git a/src/screens/__tests__/__snapshots__/AboutScreen.test.js.snap b/src/app/__tests__/__snapshots__/about.test.js.snap similarity index 100% rename from src/screens/__tests__/__snapshots__/AboutScreen.test.js.snap rename to src/app/__tests__/__snapshots__/about.test.js.snap diff --git a/src/screens/__tests__/__snapshots__/HistoryScreen.test.js.snap b/src/app/__tests__/__snapshots__/history.test.js.snap similarity index 100% rename from src/screens/__tests__/__snapshots__/HistoryScreen.test.js.snap rename to src/app/__tests__/__snapshots__/history.test.js.snap diff --git a/src/screens/__tests__/__snapshots__/HomeScreen.test.js.snap b/src/app/__tests__/__snapshots__/index.test.js.snap similarity index 88% rename from src/screens/__tests__/__snapshots__/HomeScreen.test.js.snap rename to src/app/__tests__/__snapshots__/index.test.js.snap index 992480c..d7a0541 100644 --- a/src/screens/__tests__/__snapshots__/HomeScreen.test.js.snap +++ b/src/app/__tests__/__snapshots__/index.test.js.snap @@ -91,7 +91,7 @@ exports[` renders correctly 1`] = ` } > renders correctly 1`] = ` } > renders correctly 1`] = ` } > renders correctly 1`] = ` } } > - - + `; diff --git a/src/screens/__tests__/__snapshots__/OptionsScreen.test.js.snap b/src/app/__tests__/__snapshots__/options.test.js.snap similarity index 100% rename from src/screens/__tests__/__snapshots__/OptionsScreen.test.js.snap rename to src/app/__tests__/__snapshots__/options.test.js.snap diff --git a/src/screens/__tests__/__snapshots__/QuizzScreen.test.js.snap b/src/app/__tests__/__snapshots__/quizz.test.js.snap similarity index 100% rename from src/screens/__tests__/__snapshots__/QuizzScreen.test.js.snap rename to src/app/__tests__/__snapshots__/quizz.test.js.snap diff --git a/src/screens/__tests__/__snapshots__/RulesScreen.test.js.snap b/src/app/__tests__/__snapshots__/rules.test.js.snap similarity index 100% rename from src/screens/__tests__/__snapshots__/RulesScreen.test.js.snap rename to src/app/__tests__/__snapshots__/rules.test.js.snap diff --git a/src/screens/__tests__/AboutScreen.test.js b/src/app/__tests__/about.test.js similarity index 85% rename from src/screens/__tests__/AboutScreen.test.js rename to src/app/__tests__/about.test.js index c08f2e5..a64252f 100644 --- a/src/screens/__tests__/AboutScreen.test.js +++ b/src/app/__tests__/about.test.js @@ -1,7 +1,7 @@ import React from 'react'; import { render } from '@testing-library/react-native'; -import AboutScreen from '../AboutScreen'; +import AboutScreen from '../about'; describe('', () => { it('renders correctly', () => { diff --git a/src/screens/__tests__/HistoryScreen.test.js b/src/app/__tests__/history.test.js similarity index 87% rename from src/screens/__tests__/HistoryScreen.test.js rename to src/app/__tests__/history.test.js index f3b6ee4..7d99df3 100644 --- a/src/screens/__tests__/HistoryScreen.test.js +++ b/src/app/__tests__/history.test.js @@ -1,7 +1,7 @@ import React from 'react'; import { render, waitFor } from '@testing-library/react-native'; -import HistoryScreen from '../HistoryScreen'; +import HistoryScreen from '../history'; describe('', () => { it('renders correctly', async () => { diff --git a/src/screens/__tests__/HomeScreen.test.js b/src/app/__tests__/index.test.js similarity index 58% rename from src/screens/__tests__/HomeScreen.test.js rename to src/app/__tests__/index.test.js index 80530ad..33b2759 100644 --- a/src/screens/__tests__/HomeScreen.test.js +++ b/src/app/__tests__/index.test.js @@ -1,11 +1,11 @@ import React from 'react'; import { render } from '@testing-library/react-native'; -import HomeScreen from '../HomeScreen'; +import IndexScreen from '../index'; -describe('', () => { +describe('', () => { it('renders correctly', () => { - const { toJSON } = render(); + const { toJSON } = render(); expect(toJSON()).toMatchSnapshot(); }); diff --git a/src/screens/__tests__/OptionsScreen.test.js b/src/app/__tests__/options.test.js similarity index 84% rename from src/screens/__tests__/OptionsScreen.test.js rename to src/app/__tests__/options.test.js index db711bd..f5da402 100644 --- a/src/screens/__tests__/OptionsScreen.test.js +++ b/src/app/__tests__/options.test.js @@ -1,7 +1,7 @@ import React from 'react'; import { render } from '@testing-library/react-native'; -import OptionsScreen from '../OptionsScreen'; +import OptionsScreen from '../options'; describe('', () => { it('renders correctly', () => { diff --git a/src/screens/__tests__/QuizzScreen.test.js b/src/app/__tests__/quizz.test.js similarity index 94% rename from src/screens/__tests__/QuizzScreen.test.js rename to src/app/__tests__/quizz.test.js index 4183eba..701f6f1 100644 --- a/src/screens/__tests__/QuizzScreen.test.js +++ b/src/app/__tests__/quizz.test.js @@ -3,7 +3,7 @@ import { render, fireEvent } from '@testing-library/react-native'; import { Levels, Categories } from '../../utils/config'; -import QuizzScreen from '../QuizzScreen'; +import QuizzScreen from '../quizz'; describe('', () => { it('renders correctly', async () => { diff --git a/src/screens/__tests__/RulesScreen.test.js b/src/app/__tests__/rules.test.js similarity index 88% rename from src/screens/__tests__/RulesScreen.test.js rename to src/app/__tests__/rules.test.js index a10d241..5561876 100644 --- a/src/screens/__tests__/RulesScreen.test.js +++ b/src/app/__tests__/rules.test.js @@ -1,7 +1,7 @@ import React from 'react'; import { render } from '@testing-library/react-native'; -import RulesScreen from '../RulesScreen'; +import RulesScreen from '../rules'; describe('', () => { it('renders correctly', () => { diff --git a/src/app/_layout.js b/src/app/_layout.js new file mode 100644 index 0000000..32cad70 --- /dev/null +++ b/src/app/_layout.js @@ -0,0 +1,46 @@ +import { Stack } from 'expo-router'; +import { ThemeProvider as ReactNavigationThemeProvider, DefaultTheme } from '@react-navigation/native'; +import Toast, { BaseToast } from 'react-native-toast-message'; +import { ThemeProvider as ElementsThemeProvider } from 'react-native-elements'; + +import I18n from '../utils/i18n'; +import theme from '../utils/theme.js'; + +const toastConfig = { + info: (props) => , +}; + +const reactNativeElementsTheme = { + colors: { + primary: theme.MAIN_COLOR, + }, +}; + +const reactNavigationTheme = { + ...DefaultTheme, + colors: { + ...DefaultTheme.colors, + background: theme.MAIN_COLOR_LIGHT, + primary: theme.MAIN_COLOR_LIGHT, + card: theme.MAIN_COLOR, + text: theme.MAIN_COLOR_LIGHT, + }, +}; + +export default function RootLayout() { + return ( + + + + + + + + + + + + + + ); +} diff --git a/src/screens/AboutScreen.js b/src/app/about.js similarity index 99% rename from src/screens/AboutScreen.js rename to src/app/about.js index c5cb31f..8ad1685 100644 --- a/src/screens/AboutScreen.js +++ b/src/app/about.js @@ -14,6 +14,7 @@ export default () => { subject: I18n.t('aboutScreen.mailSubject'), }).then(); }; + return ( {I18n.t('aboutScreen.aboutHeader')} diff --git a/src/screens/HistoryScreen.js b/src/app/history.js similarity index 100% rename from src/screens/HistoryScreen.js rename to src/app/history.js diff --git a/src/screens/HomeScreen.js b/src/app/index.js similarity index 71% rename from src/screens/HomeScreen.js rename to src/app/index.js index 09bc2bd..12dcd5b 100644 --- a/src/screens/HomeScreen.js +++ b/src/app/index.js @@ -1,6 +1,7 @@ import React from 'react'; +import { StyleSheet, Text, View, Image } from 'react-native'; import { StatusBar } from 'expo-status-bar'; -import { StyleSheet, Text, View, Pressable, Image } from 'react-native'; +import { Link } from 'expo-router'; import { Button } from 'react-native-elements'; import { MaterialCommunityIcons } from '@expo/vector-icons'; @@ -21,27 +22,24 @@ export default (props) => { {I18n.t('homeScreen.subtitle')} -