Skip to content

Commit

Permalink
chore(Cross): [IOAPPX-414] Add NativeStackNavigator to the Design S…
Browse files Browse the repository at this point in the history
…ystem section (#6340)
  • Loading branch information
dmnplb authored Dec 3, 2024
1 parent 0b3b8e3 commit ac9c2bd
Show file tree
Hide file tree
Showing 80 changed files with 571 additions and 71 deletions.
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ PODS:
- RCT-Folly (= 2021.07.22.00)
- React-Core
- ReactCommon/turbomodule/core
- RNScreens (3.31.1):
- RNScreens (3.35.0):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- React-RCTImage
Expand Down Expand Up @@ -1129,7 +1129,7 @@ SPEC CHECKSUMS:
RNQrGenerator: 1676221c08bfabec978242989c733810dad20959
RNReactNativeHapticFeedback: 6d24decfa94e037c2ecc312407d2a057b7933f10
RNReanimated: c2027c397233801d4aceb7375e000ac87ec2e67d
RNScreens: b8d370282cdeae9df85dd5eab20c88eb5181243b
RNScreens: 2fc874a2605e88dedf43204a79fad1d2da4abfbe
RNSentry: 3e667c2c6ea5d35ea292c7f262c6b44e43842cc1
RNShare: 0fad69ae2d71de9d1f7b9a43acf876886a6cb99c
RNStoreReview: 31dbfd0dac2eea9675f0b84f1dd3261c2110c337
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"@react-navigation/bottom-tabs": "6.5.11",
"@react-navigation/material-top-tabs": "6.6.5",
"@react-navigation/native": "6.1.9",
"@react-navigation/native-stack": "^6.11.0",
"@react-navigation/stack": "6.3.20",
"@redux-saga/testing-utils": "^1.1.3",
"@sentry/react-native": "^5.32.0",
Expand Down Expand Up @@ -196,7 +197,7 @@
"react-native-responsive-screen": "^1.4.1",
"react-native-safe-area-context": "^4.10.4",
"react-native-screen-brightness": "^2.0.0-alpha",
"react-native-screens": "^3.31.1",
"react-native-screens": "^3.35.0",
"react-native-share": "^10.2.1",
"react-native-splash-screen": "^3.2.0",
"react-native-store-review": "^0.4.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ exports[`LoadingScreenContent should match the snapshot with title, a child, hea
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -801,6 +802,7 @@ exports[`LoadingScreenContent should match the snapshot with title, a child, hea
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -1398,6 +1400,7 @@ exports[`LoadingScreenContent should match the snapshot with title, no children,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -1992,6 +1995,7 @@ exports[`LoadingScreenContent should match the snapshot with title, no children,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ exports[`OperationResultScreenContent should match the snapshot with default pro
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ exports[`IOScrollViewCentredContent should match snapshot, with description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -1130,6 +1131,7 @@ exports[`IOScrollViewCentredContent should match snapshot, with description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -2281,6 +2283,7 @@ exports[`IOScrollViewCentredContent should match snapshot, with description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -3321,6 +3324,7 @@ exports[`IOScrollViewCentredContent should match snapshot, with description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -4141,6 +4145,7 @@ exports[`IOScrollViewCentredContent should match snapshot, with description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -5186,6 +5191,7 @@ exports[`IOScrollViewCentredContent should match snapshot, with description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -6120,6 +6126,7 @@ exports[`IOScrollViewCentredContent should match snapshot, without description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -7023,6 +7030,7 @@ exports[`IOScrollViewCentredContent should match snapshot, without description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -8151,6 +8159,7 @@ exports[`IOScrollViewCentredContent should match snapshot, without description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -9168,6 +9177,7 @@ exports[`IOScrollViewCentredContent should match snapshot, without description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -9965,6 +9975,7 @@ exports[`IOScrollViewCentredContent should match snapshot, without description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -10987,6 +10998,7 @@ exports[`IOScrollViewCentredContent should match snapshot, without description,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ exports[`IOScrollViewWithListItems Rendering renders correctly with default prop
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -1097,6 +1098,7 @@ exports[`IOScrollViewWithListItems Rendering renders correctly without optional
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down Expand Up @@ -1732,6 +1734,7 @@ exports[`IOScrollViewWithListItems Rendering renders subtitle as array correctly
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ exports[`CGNDiscountExpiredScreen should render correctly 1`] = `
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ exports[`CgnDiscountCodeScreen should render correctly 1`] = `
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ exports[`CgnDiscountDetailScreen should render correctly 1`] = `
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": undefined,
}
}
>
Expand Down
112 changes: 49 additions & 63 deletions ts/features/design-system/navigation/navigator.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import {
IOVisualCostants,
IOColors,
IconButton,
makeFontStyleObject,
useIOExperimentalDesign,
useIOTheme,
useIOThemeContext
} from "@pagopa/io-app-design-system";
import { ThemeProvider, useNavigation } from "@react-navigation/native";
import {
StackNavigationOptions,
TransitionPresets,
createStackNavigator
} from "@react-navigation/stack";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import * as React from "react";
import { Alert, Platform, View } from "react-native";
import { makeFontStyleObject } from "../../../components/core/fonts";
import { Alert, Platform } from "react-native";
import HeaderFirstLevel from "../../../components/ui/HeaderFirstLevel";
import {
IONavigationDarkTheme,
Expand Down Expand Up @@ -75,43 +72,21 @@ import { DSWallet } from "../core/DSWallet";
import { DesignSystemParamsList } from "./params";
import DESIGN_SYSTEM_ROUTES from "./routes";

const Stack = createStackNavigator<DesignSystemParamsList>();

// BackButton managed through React Navigation
const RNNBackButton = () => {
const navigation = useNavigation();
const { themeType } = useIOThemeContext();
return (
<View style={{ marginLeft: IOVisualCostants.appMarginDefault }}>
<IconButton
icon={Platform.select({
android: "backAndroid",
default: "backiOS"
})}
color={themeType === "dark" ? "contrast" : "neutral"}
onPress={() => {
navigation.goBack();
}}
accessibilityLabel={""}
/>
</View>
);
};
const Stack = createNativeStackNavigator<DesignSystemParamsList>();

const RNNCloseButton = () => {
const navigation = useNavigation();
const { themeType } = useIOThemeContext();

return (
<View style={{ marginRight: IOVisualCostants.appMarginDefault }}>
<IconButton
icon="closeMedium"
color="neutral"
onPress={() => {
navigation.goBack();
}}
accessibilityLabel={""}
/>
</View>
<IconButton
icon="closeMedium"
color={themeType === "dark" ? "contrast" : "neutral"}
onPress={() => {
navigation.goBack();
}}
accessibilityLabel={""}
/>
);
};

Expand Down Expand Up @@ -139,27 +114,25 @@ const HeaderFirstLevelComponent = () => (
/>
);

const customModalHeaderConf: StackNavigationOptions = {
headerLeft: () => null,
headerTitle: () => null,
headerRight: RNNCloseButton,
headerStyle: { height: IOVisualCostants.headerHeight },
headerStatusBarHeight: 0
};

export const DesignSystemNavigator = () => {
const { isExperimental } = useIOExperimentalDesign();
const { themeType } = useIOThemeContext();
const theme = useIOTheme();

const customHeaderConf: StackNavigationOptions = {
const customModalHeaderConf = {
headerRight: RNNCloseButton,
title: DESIGN_SYSTEM_ROUTES.DEBUG.FULL_SCREEN_MODAL.title,
sheetCornerRadius: 24,
headerTitleStyle: {
...(isExperimental
? makeFontStyleObject("Regular", false, "ReadexPro")
: makeFontStyleObject("Semibold", false, "TitilliumSansPro")),
fontSize: 14
},
headerTitleAlign: "center",
headerLeft: RNNBackButton
...makeFontStyleObject(
14,
isExperimental ? "Titillio" : "TitilliumSansPro",
18,
isExperimental ? "Regular" : "Semibold",
undefined
),
color: IOColors[theme["textHeading-default"]]
}
};

return (
Expand All @@ -170,13 +143,29 @@ export const DesignSystemNavigator = () => {
>
<Stack.Navigator
initialRouteName={DESIGN_SYSTEM_ROUTES.MAIN.route}
screenOptions={customHeaderConf}
screenOptions={{
headerTintColor: IOColors[theme["interactiveElem-default"]],
headerTitleStyle: {
...makeFontStyleObject(
14,
isExperimental ? "Titillio" : "TitilliumSansPro",
18,
isExperimental ? "Regular" : "Semibold",
undefined
),
color: IOColors[theme["textHeading-default"]]
},
headerTitleAlign: "center",
headerBackTitleVisible: false,
headerShown: true,
autoHideHomeIndicator: true
}}
>
<Stack.Screen
name={DESIGN_SYSTEM_ROUTES.MAIN.route}
component={DesignSystem}
options={{
headerTitle: DESIGN_SYSTEM_ROUTES.MAIN.title
title: DESIGN_SYSTEM_ROUTES.MAIN.title
}}
/>

Expand Down Expand Up @@ -563,13 +552,10 @@ export const DesignSystemNavigator = () => {

<Stack.Group
screenOptions={{
headerMode: "screen",
presentation: "modal",
presentation: "formSheet",
...(Platform.OS === "ios"
? {
gestureEnabled: isGestureEnabled,
cardOverlayEnabled: true,
...TransitionPresets.ModalPresentationIOS
gestureEnabled: isGestureEnabled
}
: null)
}}
Expand Down
2 changes: 1 addition & 1 deletion ts/features/design-system/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const DESIGN_SYSTEM_ROUTES = {
},
FULL_SCREEN_MODAL: {
route: "DS_FULLSCR_MODAL",
title: "Full screen modal"
title: "Full screen modal (native)"
},
SCREEN_END_MARGIN: {
route: "DS_SCREEN_END_MARGIN",
Expand Down
Loading

0 comments on commit ac9c2bd

Please sign in to comment.