Skip to content

Commit

Permalink
fix: removes the require loop on navigators definition (#5110)
Browse files Browse the repository at this point in the history
## Short description
Moves the theme definition on a utility file removing the require loop
warning

## How to test
nothing should be chenged, just code reorg.
  • Loading branch information
CrisTofani authored Oct 13, 2023
1 parent 3b28745 commit 1cee8ce
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion ts/features/design-system/navigation/navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { DSTypography } from "../core/DSTypography";
import {
IONavigationDarkTheme,
IONavigationLightTheme
} from "../../../navigation/AppStackNavigator";
} from "../../../theme/navigations";
import { DesignSystemModalParamsList, DesignSystemParamsList } from "./params";
import DESIGN_SYSTEM_ROUTES from "./routes";

Expand Down
33 changes: 2 additions & 31 deletions ts/navigation/AppStackNavigator.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
/* eslint-disable functional/immutable-data */
import {
DarkTheme,
DefaultTheme,
LinkingOptions,
NavigationContainer
} from "@react-navigation/native";
import { LinkingOptions, NavigationContainer } from "@react-navigation/native";
import * as React from "react";
import { useRef } from "react";
import { View } from "react-native";
import {
IOColors,
IOThemeDark,
IOThemeLight
} from "@pagopa/io-app-design-system";
import LoadingSpinnerOverlay from "../components/LoadingSpinnerOverlay";
import {
bpdEnabled,
Expand Down Expand Up @@ -45,6 +35,7 @@ import {
IO_UNIVERSAL_LINK_PREFIX
} from "../utils/navigation";
import { useStoredExperimentalDesign } from "../common/context/DSExperimentalContext";
import { IONavigationLightTheme } from "../theme/navigations";
import AuthenticatedStackNavigator from "./AuthenticatedStackNavigator";
import NavigationService, { navigationRef } from "./NavigationService";
import NotAuthenticatedStackNavigator from "./NotAuthenticatedStackNavigator";
Expand Down Expand Up @@ -75,26 +66,6 @@ export const AppStackNavigator = (): React.ReactElement => {
return <AuthenticatedStackNavigator />;
};

// React Navigation Themes
// Dark & Light mode
export const IONavigationDarkTheme = {
...DarkTheme,
colors: {
...DarkTheme.colors,
background: IOColors[IOThemeDark["appBackground-primary"]],
card: IOColors[IOThemeDark["appBackground-primary"]]
}
};

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

const InnerNavigationContainer = (props: { children: React.ReactElement }) => {
const routeNameRef = useRef<string>();
const dispatch = useIODispatch();
Expand Down
26 changes: 26 additions & 0 deletions ts/theme/navigations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
IOColors,
IOThemeDark,
IOThemeLight
} from "@pagopa/io-app-design-system";
import { DarkTheme, DefaultTheme } from "@react-navigation/native";

// React Navigation Themes
// Dark & Light mode
export const IONavigationDarkTheme = {
...DarkTheme,
colors: {
...DarkTheme.colors,
background: IOColors[IOThemeDark["appBackground-primary"]],
card: IOColors[IOThemeDark["appBackground-primary"]]
}
};

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

0 comments on commit 1cee8ce

Please sign in to comment.