Skip to content

Commit

Permalink
[IOAPPFD0-132] Example app · Enable iOS/Android native navigation (#42)
Browse files Browse the repository at this point in the history
## Short description
This PR enables the native navigation in the example app. If you want to
discover more about the change and its implications, read the
description of the [PR
#4857](pagopa/io-app#4857)
([io-app](https://github.com/pagopa/io-app)) for reference.

## List of changes proposed in this pull request
- **[Example app]** Update `react-navigation` and related packages to
`6.x` version
- **[Main package]** Update `reanimated` and
`react-native-safe-area-context` to the last version
- Replace `StackNavigator` with the `NativeStackNavigator`
- Add native fullscreen modal (it seems different from the one available
in the `5.x`)
- Add native iOS search screen with custom color palette
- Add dark mode support to the example app
- Fix `AnimatedTick` rendering error after upgrade of `react-native-svg`

## How to test
Go to the `example` directory and run the app
  • Loading branch information
dmnplb authored Aug 4, 2023
1 parent b7f3e32 commit 29686c4
Show file tree
Hide file tree
Showing 17 changed files with 231 additions and 158 deletions.
8 changes: 0 additions & 8 deletions example/android/link-assets-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@
"path": "assets/fonts/ReadexPro/ReadexPro-Regular.ttf",
"sha1": "93e4080794b725f216a94b57ed62a51bc77bce91"
},
{
"path": "assets/fonts/io-icon-font/io-icon-font.ttf",
"sha1": "89f1dc6b2cf7006f20483dde41c99a8f66df1fbe"
},
{
"path": "assets/fonts/Ionicons/Ionicons.ttf",
"sha1": "991bb7fac9709cd58da37901770efd4703c542ed"
},
{
"path": "assets/fonts/RobotoMono/LICENSE.txt",
"sha1": "47b573e3824cd5e02a1a3ae99e2735b49e0256e4"
Expand Down
2 changes: 0 additions & 2 deletions example/ios/ExampleApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
<string>TitilliumWeb-SemiBold.ttf</string>
<string>TitilliumWeb-SemiBoldItalic.ttf</string>
<string>ReadexPro-Regular.ttf</string>
<string>io-icon-font.ttf</string>
<string>Ionicons.ttf</string>
<string>RobotoMono-Bold.ttf</string>
<string>RobotoMono-BoldItalic.ttf</string>
<string>RobotoMono-Light.ttf</string>
Expand Down
20 changes: 10 additions & 10 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- boost (1.76.0)
- BVLinearGradient (2.5.6):
- React
- BVLinearGradient (2.8.1):
- React-Core
- CocoaAsyncSocket (7.6.5)
- DoubleConversion (1.1.6)
- FBLazyVector (0.72.3)
Expand Down Expand Up @@ -489,11 +489,11 @@ PODS:
- React-jsi (= 0.72.3)
- React-logger (= 0.72.3)
- React-perflogger (= 0.72.3)
- RNGestureHandler (2.12.0):
- RNGestureHandler (2.12.1):
- React-Core
- RNReactNativeHapticFeedback (2.0.3):
- React-Core
- RNReanimated (3.3.0):
- RNReanimated (3.4.1):
- DoubleConversion
- FBLazyVector
- glog
Expand Down Expand Up @@ -522,7 +522,7 @@ PODS:
- React-RCTText
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.22.1):
- RNScreens (3.23.0):
- React-Core
- React-RCTImage
- RNSVG (13.10.0):
Expand Down Expand Up @@ -718,7 +718,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
BVLinearGradient: 421743791a59d259aec53f4c58793aad031da2ca
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 4cce221dd782d3ff7c4172167bba09d58af67ccb
Expand Down Expand Up @@ -769,15 +769,15 @@ SPEC CHECKSUMS:
React-runtimescheduler: 837c1bebd2f84572db17698cd702ceaf585b0d9a
React-utils: bcb57da67eec2711f8b353f6e3d33bd8e4b2efa3
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
RNGestureHandler: dec4645026e7401a0899f2846d864403478ff6a5
RNGestureHandler: c0d04458598fcb26052494ae23dda8f8f5162b13
RNReactNativeHapticFeedback: afa5bf2794aecbb2dba2525329253da0d66656df
RNReanimated: 9f7068e43b9358a46a688d94a5a3adb258139457
RNScreens: 50ffe2fa2342eabb2d0afbe19f7c1af286bc7fb3
RNReanimated: 53ca20eee770c41173703f5948cd8898aa08262c
RNScreens: 6a8a3c6b808aa48dca1780df7b73ea524f602c63
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 3682f715bd91b22067ed6990af779570157f6eb0

COCOAPODS: 1.11.3
COCOAPODS: 1.12.0
11 changes: 6 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
"dependencies": {
"@react-native/metro-config": "^0.72.9",
"@react-navigation/native": "^6.1.7",
"@react-navigation/stack": "5.14.9",
"@react-navigation/native-stack": "^6.9.13",
"@react-navigation/stack": "^6.3.17",
"babel-plugin-macros": "^3.1.0",
"fp-ts": "^2.16.0",
"i18n-js": "^4.3.0",
"io-ts": "^2.2.20",
"react": "^18.2.0",
"react-native": "0.72.3",
"react-native-gesture-handler": "^2.12.0",
"react-native-gesture-handler": "^2.12.1",
"react-native-haptic-feedback": "^2.0.3",
"react-native-linear-gradient": "2.5.6",
"react-native-reanimated": "^3.3.0",
"react-native-linear-gradient": "^2.8.1",
"react-native-reanimated": "^3.4.1",
"react-native-safe-area-context": "^4.7.1",
"react-native-screens": "^3.22.1",
"react-native-screens": "^3.23.0",
"react-native-svg": "^13.10.0",
"rn-placeholder": "^3.0.3"
},
Expand Down
2 changes: 0 additions & 2 deletions example/react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ module.exports = {
assets: [
"./assets/fonts/TitilliumWeb",
"./assets/fonts/ReadexPro",
"./assets/fonts/io-icon-font",
"./assets/fonts/Ionicons",
"./assets/fonts/RobotoMono"
]
};
53 changes: 47 additions & 6 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
import { IOStyles } from "@pagopa/io-app-design-system";
import { NavigationContainer } from "@react-navigation/native";
import {
DarkTheme,
DefaultTheme,
NavigationContainer
} from "@react-navigation/native";
import * as React from "react";
import {
IOStyles,
IOThemeContext,
IOThemeDark,
IOThemeLight,
IOThemes
} from "@pagopa/io-app-design-system";
import { useColorScheme } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import AppNavigator from "./navigation/navigator";

const IONavigationDarkTheme = {
...DarkTheme,
colors: {
...DarkTheme.colors,
background: IOThemeDark["appBackground-primary"],
card: IOThemeDark["appBackground-primary"]
}
};

const IONavigationLightTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: IOThemeLight["appBackground-primary"],
card: IOThemeLight["appBackground-primary"]
}
};

export default function App() {
const colorScheme = useColorScheme();

return (
<GestureHandlerRootView style={IOStyles.flex}>
<NavigationContainer>
<AppNavigator />
<IOThemeContext.Provider
value={colorScheme === "dark" ? IOThemes.dark : IOThemes.light}
>
<NavigationContainer
theme={
colorScheme === "dark"
? IONavigationDarkTheme
: IONavigationLightTheme
}
>
<GestureHandlerRootView style={IOStyles.flex}>
<AppNavigator />
</GestureHandlerRootView>
</NavigationContainer>
</GestureHandlerRootView>
</IOThemeContext.Provider>
);
}
46 changes: 13 additions & 33 deletions example/src/components/Screen.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
import { ContentWrapper, IOThemeContext } from "@pagopa/io-app-design-system";
import React, { useContext } from "react";
import { ContentWrapper } from "@pagopa/io-app-design-system";
import React from "react";
import { ScrollView, View } from "react-native";

type Props = {
children: React.ReactNode;
children: React.ReactNode;
};

export const Screen = ({
children,
}: Props) => {
const theme = useContext(IOThemeContext);
export const Screen = ({ children }: Props) => (
<ScrollView>
<ContentWrapper>{children}</ContentWrapper>
</ScrollView>
);

return (
<ScrollView
style={{
backgroundColor: theme["appBackground-primary"]
}}
>
<ContentWrapper>{children}</ContentWrapper>
</ScrollView>
);
};

export const NoMarginScreen = ({
children,
}: Props) => {
const theme = useContext(IOThemeContext);

return (
<ScrollView
style={{
backgroundColor: theme["appBackground-primary"]
}}
>
<View>{children}</View>
</ScrollView>
);
};
export const NoMarginScreen = ({ children }: Props) => (
<ScrollView>
<View>{children}</View>
</ScrollView>
);
31 changes: 25 additions & 6 deletions example/src/navigation/navigator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createStackNavigator } from "@react-navigation/stack";
import React from "react";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { Accordion } from "../pages/Accordion";
import { DSAdvice } from "../pages/Advice";
import { DSAlert } from "../pages/Alert";
Expand All @@ -14,21 +14,21 @@ import MainScreen from "../pages/MainScreen";
import { Pictograms } from "../pages/Pictograms";
import { Selection } from "../pages/Selection";
import { Typography } from "../pages/Typography";
import { Search } from "../pages/Search";
import { TabNavigationScreen } from "../pages/TabNavigation";
import { AppParamsList } from "./params";
import APP_ROUTES from "./routes";

const Stack = createStackNavigator<AppParamsList>();
const Stack = createNativeStackNavigator<AppParamsList>();

const AppNavigator = () => (
<Stack.Navigator
initialRouteName={APP_ROUTES.MAIN}
screenOptions={{
headerTitleStyle: {
fontFamily: "ReadexPro",
fontFamily: "Readex Pro",
fontSize: 14,
fontWeight: "normal",
fontStyle: "normal"
fontWeight: "normal"
},
headerTitleAlign: "center",
headerShown: true
Expand Down Expand Up @@ -94,7 +94,6 @@ const AppNavigator = () => (
component={Buttons}
options={{
headerTitle: APP_ROUTES.COMPONENTS.BUTTONS.title,

headerBackTitleVisible: false
}}
/>
Expand Down Expand Up @@ -146,6 +145,7 @@ const AppNavigator = () => (
headerBackTitleVisible: false
}}
/>

<Stack.Screen
name={APP_ROUTES.COMPONENTS.TAB_NAVIGATION.route}
component={TabNavigationScreen}
Expand All @@ -154,6 +154,25 @@ const AppNavigator = () => (
headerBackTitleVisible: false
}}
/>

<Stack.Screen
name={APP_ROUTES.SCREENS.SEARCH.route}
component={Search}
options={{
headerTitle: APP_ROUTES.SCREENS.SEARCH.title,
headerBackTitleVisible: false
}}
/>

<Stack.Group screenOptions={{ presentation: "formSheet" }}>
<Stack.Screen
name={APP_ROUTES.SCREENS.FULL_SCREEN_MODAL.route}
component={ListItems}
options={{
headerShown: false
}}
/>
</Stack.Group>
</Stack.Navigator>
);

Expand Down
2 changes: 2 additions & 0 deletions example/src/navigation/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ export type AppParamsList = {
[DESIGN_SYSTEM_ROUTES.COMPONENTS.ALERT.route]: undefined;
[DESIGN_SYSTEM_ROUTES.COMPONENTS.LIST_ITEMS.route]: undefined;
[DESIGN_SYSTEM_ROUTES.COMPONENTS.TAB_NAVIGATION.route]: undefined;
[DESIGN_SYSTEM_ROUTES.SCREENS.FULL_SCREEN_MODAL.route]: undefined;
[DESIGN_SYSTEM_ROUTES.SCREENS.SEARCH.route]: undefined;
};
7 changes: 7 additions & 0 deletions example/src/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ const APP_ROUTES = {
route: "DESIGN_SYSTEM_TAB_NAVIGATION",
title: "Tab Navigation"
}
},
SCREENS: {
FULL_SCREEN_MODAL: {
route: "DESIGN_SYSTEM_FULLSCR_MODAL",
title: "Full screen modal"
},
SEARCH: { route: "DESIGN_SYSTEM_SEARCHBAR", title: "Search" }
}
} as const;

Expand Down
6 changes: 5 additions & 1 deletion example/src/pages/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
VSpacer
} from "@pagopa/io-app-design-system";
import React, { useContext } from "react";
import { View } from "react-native";
import { StatusBar, View } from "react-native";
import { NoMarginScreen } from "../components/Screen";
import { SpacerViewerBox } from "../components/SpacerViewerBox";

Expand All @@ -24,6 +24,10 @@ export const Layout = () => {

return (
<NoMarginScreen>
<StatusBar
barStyle={"default"}
backgroundColor={IOColors.black}
></StatusBar>
<ContentWrapper>
<H1
color={theme["textHeading-default"]}
Expand Down
Loading

0 comments on commit 29686c4

Please sign in to comment.