From 45193e6d6e1ef0a472062f84a41527ac9edad040 Mon Sep 17 00:00:00 2001 From: G Date: Thu, 23 May 2024 22:42:42 +0000 Subject: [PATCH] renaming, refactoring a good bit the navigation system --- src/navigations/AppBottomTabsNavigator.tsx | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/navigations/AppMainStackNavigator.tsx | 22 ++++++++++++++++++++++ src/navigations/BottomTabs.tsx | 95 ----------------------------------------------------------------------------------------------- src/navigations/InitialNavigationHandler.tsx | 4 ++-- src/navigations/PaymentStackNavigation.tsx | 4 ++-- src/navigations/Types.ts | 28 +++++++++++++--------------- src/navigations/UnloggedUserStackNavigation.tsx | 22 ---------------------- src/screens/HomeUserNotLoggedIn.tsx | 2 +- 8 files changed, 133 insertions(+), 137 deletions(-) create mode 100644 src/navigations/AppBottomTabsNavigator.tsx create mode 100644 src/navigations/AppMainStackNavigator.tsx delete mode 100644 src/navigations/BottomTabs.tsx delete mode 100644 src/navigations/UnloggedUserStackNavigation.tsx diff --git a/src/navigations/AppBottomTabsNavigator.tsx b/src/navigations/AppBottomTabsNavigator.tsx new file mode 100644 index 0000000..b5ec146 --- /dev/null +++ b/src/navigations/AppBottomTabsNavigator.tsx @@ -0,0 +1,93 @@ +import { Entypo, FontAwesome, Ionicons } from "@expo/vector-icons"; +import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; +import { useTheme } from "@shopify/restyle"; +// import palette +import type { Theme } from "@themes/Theme"; +import { View } from "react-native"; +import Text from "../components/bases/Text"; +import PaymentStackNavigator from "./PaymentStackNavigation"; +const Tab = createBottomTabNavigator(); + +export const AppBottomTabsNavigator = () => { + const theme = useTheme(); + + return ( + + ( + + ), + tabBarActiveTintColor: theme.colors.secondary, + }} + /> + ( + + ), + tabBarActiveTintColor: theme.colors.secondary, + }} + /> + ( + + ), + tabBarActiveTintColor: theme.colors.secondary, + }} + /> + ( + + ), + tabBarActiveTintColor: theme.colors.secondary, + }} + /> + + ); +}; + +const HomeScreen = () => { + return ( + + Home! + + ); +}; + +const Transactions = () => { + return ( + + Transactions! + + ); +}; + +const SettingsScreen = () => { + return ( + + Settings! + + ); +}; + +const ProfileScreen = () => { + return ( + + Profile! + + ); +}; diff --git a/src/navigations/AppMainStackNavigator.tsx b/src/navigations/AppMainStackNavigator.tsx new file mode 100644 index 0000000..22086b3 --- /dev/null +++ b/src/navigations/AppMainStackNavigator.tsx @@ -0,0 +1,22 @@ +import { createNativeStackNavigator } from "@react-navigation/native-stack"; +import HomeUserNotLoggedIn from "@screens/HomeUserNotLoggedIn"; +import UserLoginScreen from "@screens/UserLoginScreen"; +import { AppBottomTabsNavigator } from "./AppBottomTabsNavigator"; +import type { ImainStackNavigator } from "./Types"; + +const Stack = createNativeStackNavigator(); + +const AppMainStackNavigator = () => { + return ( + + + + + + ); +}; + +export default AppMainStackNavigator; diff --git a/src/navigations/BottomTabs.tsx b/src/navigations/BottomTabs.tsx deleted file mode 100644 index b651222..0000000 --- a/src/navigations/BottomTabs.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { Entypo } from "@expo/vector-icons"; -import { FontAwesome } from "@expo/vector-icons"; -import { Ionicons } from "@expo/vector-icons"; -import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; -import { useTheme } from "@shopify/restyle"; -// import palette -import type { Theme } from "@themes/Theme"; -import { View } from "react-native"; -import Text from "../components/bases/Text"; -import PaymentStackNavigator from "./PaymentStackNavigation"; -const Tab = createBottomTabNavigator(); - -export const BottomTabs = () => { - const theme = useTheme(); - - return ( - - ( - - ), - tabBarActiveTintColor: theme.colors.secondary, - }} - /> - ( - - ), - tabBarActiveTintColor: theme.colors.secondary, - }} - /> - ( - - ), - tabBarActiveTintColor: theme.colors.secondary, - }} - /> - ( - - ), - tabBarActiveTintColor: theme.colors.secondary, - }} - /> - - ); -}; - -const HomeScreen = () => { - return ( - - Home! - - ); -}; - -const Transactions = () => { - return ( - - Transactions! - - ); -}; - -const SettingsScreen = () => { - return ( - - Settings! - - ); -}; - -const ProfileScreen = () => { - return ( - - Profile! - - ); -}; diff --git a/src/navigations/InitialNavigationHandler.tsx b/src/navigations/InitialNavigationHandler.tsx index 5562e4d..186f7e0 100644 --- a/src/navigations/InitialNavigationHandler.tsx +++ b/src/navigations/InitialNavigationHandler.tsx @@ -1,11 +1,11 @@ import { useUserAuthenticationContext } from "@/contexts/UserAuthenticationContext"; -import UnloggedUserStackNavigation from "./UnloggedUserStackNavigation"; +import AppMainStackNavigator from "./AppMainStackNavigator"; const InitialNavigationHandler = () => { const { isAuthenticated } = useUserAuthenticationContext(); console.log("isAuthenticated", isAuthenticated); - return ; + return ; }; export default InitialNavigationHandler; diff --git a/src/navigations/PaymentStackNavigation.tsx b/src/navigations/PaymentStackNavigation.tsx index 5cea561..a5aee6a 100644 --- a/src/navigations/PaymentStackNavigation.tsx +++ b/src/navigations/PaymentStackNavigation.tsx @@ -3,9 +3,9 @@ import HomePageWithPaymentOptions from "@screens/HomePageWithPaymentOptions"; import NumberAndOtpForPaymentScreen from "@screens/NumberAndOtpForPaymentScreen"; import PaymentAmountInputScreen from "@screens/PaymentAmountInputScreen"; import PaymentResultScreen from "@screens/PaymentResultScreen"; -import type { PaymentStackParamList } from "./Types"; +import type { IpaymentStackNavigator } from "./Types"; -const Stack = createNativeStackNavigator(); +const Stack = createNativeStackNavigator(); const PaymentStackNavigator = () => { return ( diff --git a/src/navigations/Types.ts b/src/navigations/Types.ts index 6cd3f30..604c7e1 100644 --- a/src/navigations/Types.ts +++ b/src/navigations/Types.ts @@ -1,35 +1,33 @@ import type { PaymentCode } from "@/utils/requests/Types"; import type { NativeStackScreenProps } from "@react-navigation/native-stack"; -export type PaymentStackParamList = { +export type IpaymentStackNavigator = { homePageWithPaymentOptions: undefined; numberAndOtpForPaymentScreen: undefined; paymentAmountInputScreen: { paymentType: PaymentCode; }; - homeUserNotLoggedIn: undefined; - userLoginScreen: undefined; + // homeUserNotLoggedIn: undefined; + // userLoginScreen: undefined; paymentResultScreen: undefined; }; -export type PaymentStackScreenProps = NativeStackScreenProps< - PaymentStackParamList, - T, - "PaymentStackParamList" ->; +export type PaymentStackScreenProps = + NativeStackScreenProps; -export type PaymentStackScreenComponentProps = React.FC< +export type PaymentStackScreenComponentProps = React.FC< PaymentStackScreenProps >; -export type UnloggedUserStackParamList = { +export type ImainStackNavigator = { homeUserNotLoggedIn: undefined; userLoginScreen: undefined; - bottomTabs: undefined; + appBottomTabsNavigator: undefined; }; -export type UnloggedUserStackScreenProps = - NativeStackScreenProps; +export type UnloggedUserStackScreenProps = + NativeStackScreenProps; -export type UnloggedUserStackScreenComponentProps = - React.FC>; +export type UnloggedUserStackScreenComponentProps = React.FC< + UnloggedUserStackScreenProps +>; diff --git a/src/navigations/UnloggedUserStackNavigation.tsx b/src/navigations/UnloggedUserStackNavigation.tsx deleted file mode 100644 index 88fdb5a..0000000 --- a/src/navigations/UnloggedUserStackNavigation.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { createNativeStackNavigator } from "@react-navigation/native-stack"; -import HomeUserNotLoggedIn from "@screens/HomeUserNotLoggedIn"; -import UserLoginScreen from "@screens/UserLoginScreen"; -import { BottomTabs } from "./BottomTabs"; -import type { UnloggedUserStackParamList } from "./Types"; - -const Stack = createNativeStackNavigator(); - -const UnloggedUserStackNavigation = () => { - return ( - - - - - - ); -}; - -export default UnloggedUserStackNavigation; diff --git a/src/screens/HomeUserNotLoggedIn.tsx b/src/screens/HomeUserNotLoggedIn.tsx index cb67422..2415fc8 100644 --- a/src/screens/HomeUserNotLoggedIn.tsx +++ b/src/screens/HomeUserNotLoggedIn.tsx @@ -10,7 +10,7 @@ const HomeUserNotLoggedIn: UnloggedUserStackScreenComponentProps<"homeUserNotLog const { isAuthenticated } = useUserAuthenticationContext(); if (isAuthenticated) { - navigation.replace("bottomTabs"); + navigation.replace("appBottomTabsNavigator"); } return ( -- libgit2 0.27.1