Skip to content

Commit

Permalink
Merge pull request #6 from phuongngo0320/setup
Browse files Browse the repository at this point in the history
Setup p4
  • Loading branch information
pnv2003 authored May 21, 2024
2 parents e1d6477 + 4c8714b commit 5279571
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/Localization/keys/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ export enum LocalizationKey {
HOME = "home",
START = "start",
LOADING = "loading",

// nav-related
TRANSACTIONS = "transactions",
WALLETS = "wallets",
BUDGETS = "budgets",
ADD = "add",
}
5 changes: 5 additions & 0 deletions src/Localization/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ export const en = {
[LocalizationKey.HOME]: "Home",
[LocalizationKey.START]: "Start",
[LocalizationKey.LOADING]: "Loading",

[LocalizationKey.TRANSACTIONS]: "Log",
[LocalizationKey.WALLETS]: "Wallets",
[LocalizationKey.BUDGETS]: "Budgets",
[LocalizationKey.ADD]: "Add",
};
5 changes: 5 additions & 0 deletions src/Localization/languages/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ export const vi = {
[LocalizationKey.HOME]: "Trang chủ",
[LocalizationKey.START]: "Bắt đầu",
[LocalizationKey.LOADING]: "Đang tải",

[LocalizationKey.TRANSACTIONS]: "Giao dịch",
[LocalizationKey.WALLETS]: "Ví của tôi",
[LocalizationKey.BUDGETS]: "Ngân sách",
[LocalizationKey.ADD]: "Thêm",
};
28 changes: 23 additions & 5 deletions src/Navigation/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { AddTransactionContainer } from "@/Screens/AddTransaction";
import { WalletsContainer } from "@/Screens/Wallets";
import { BudgetsContainer } from "@/Screens/Budgets";
import { createMaterialBottomTabNavigator } from "react-native-paper/react-navigation";
import { LocalizationKey, i18n } from "@/Localization";
import { Icon } from "react-native-paper";
import { Icons } from "@/Theme";

const Tab = createMaterialBottomTabNavigator();

Expand All @@ -20,35 +23,50 @@ export const MainNavigator = () => {
name="Home"
component={HomeContainer}
options={{

tabBarLabel: i18n.t(LocalizationKey.HOME),
tabBarIcon: ({ color }) => (
<Icon source={Icons.HOME} size={26} color={color}/>
),
}}
/>
<Tab.Screen
name="Transactions"
component={TransactionsContainer}
options={{

tabBarLabel: i18n.t(LocalizationKey.TRANSACTIONS),
tabBarIcon: ({ color }) => (
<Icon source={Icons.HISTORY} size={26} color={color}/>
),
}}
/>
<Tab.Screen
name="AddTransaction"
component={AddTransactionContainer}
options={{

tabBarLabel: i18n.t(LocalizationKey.ADD),
tabBarIcon: ({ color }) => (
<Icon source={Icons.PLUS} size={26} color={color}/>
),
}}
/>
<Tab.Screen
name="Wallets"
component={WalletsContainer}
options={{

tabBarLabel: i18n.t(LocalizationKey.WALLETS),
tabBarIcon: ({ color }) => (
<Icon source={Icons.WALLET} size={26} color={color}/>
),
}}
/>
<Tab.Screen
name="Budgets"
component={BudgetsContainer}
options={{

tabBarLabel: i18n.t(LocalizationKey.BUDGETS),
tabBarIcon: ({ color }) => (
<Icon source={Icons.BUDGET} size={26} color={color}/>
),
}}
/>
</Tab.Navigator>
Expand Down
38 changes: 34 additions & 4 deletions src/Navigation/NavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,47 @@ import React, { FC } from "react";
import { Appbar } from "react-native-paper";
import { getHeaderTitle } from "@react-navigation/elements";
import { NativeStackHeaderProps } from "@react-navigation/native-stack";
import { RootScreens } from "@/Screens";
import { Language, i18n } from "@/Localization";

export const NavigationBar: FC<NativeStackHeaderProps> = ({ navigation, route, options, back }) => {
// const title = getHeaderTitle(options, route.name);
const title = getHeaderTitle(options, route.name);

if (title === RootScreens.WELCOME) {
return (<></>)
}

const isMain = title === RootScreens.MAIN;
const hasBack = back && !isMain;

if (!isMain) {
return (
<Appbar.Header>
{hasBack
? <Appbar.BackAction onPress={navigation.goBack} />
: null
}
<Appbar.Content title={title == RootScreens.MAIN ? "Finwise" : title} />
</Appbar.Header>
)
}

return (
<Appbar.Header>
{/* {back
{hasBack
? <Appbar.BackAction onPress={navigation.goBack} />
: null
} */}
<Appbar.Content title="Finwise" />
}
<Appbar.Content title={title == RootScreens.MAIN ? "Finwise" : title} />

<Appbar.Action icon={ i18n.locale == Language.ENGLISH ? "alpha-e-box" : "alpha-v-box" } />
<Appbar.Action icon="logout" onPress={() => {
// TODO: logout (clear user info and disable back action)
navigation.navigate(RootScreens.LOGIN);
}} />
<Appbar.Action icon="cog" onPress={() => {
navigation.navigate(RootScreens.SETTINGS);
}} />
</Appbar.Header>
)
}
12 changes: 12 additions & 0 deletions src/Navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import { WelcomeContainer } from "@/Screens/Welcome";
import { RootScreens } from "@/Screens";
import { SettingsContainer } from "@/Screens/Settings";
import { NavigationBar } from "./NavigationBar";
import { LoginContainer } from "@/Screens/Login";
import { SignupContainer } from "@/Screens/Signup";

export type RootStackParamList = {
[RootScreens.MAIN]: undefined;
[RootScreens.WELCOME]: undefined;
[RootScreens.SETTINGS]: undefined;
[RootScreens.LOGIN]: undefined;
[RootScreens.SIGNUP]: undefined;
};

const RootStack = createNativeStackNavigator<RootStackParamList>();
Expand All @@ -38,6 +42,14 @@ const ApplicationNavigator = () => {
name={RootScreens.SETTINGS}
component={SettingsContainer}
/>
<RootStack.Screen
name={RootScreens.LOGIN}
component={LoginContainer}
/>
<RootStack.Screen
name={RootScreens.SIGNUP}
component={SignupContainer}
/>
</RootStack.Navigator>
</NavigationContainer>
);
Expand Down
8 changes: 8 additions & 0 deletions src/Screens/Login/LoginContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";

export const LoginContainer = () => {
return (
<>
</>
)
}
1 change: 1 addition & 0 deletions src/Screens/Login/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./LoginContainer";
8 changes: 8 additions & 0 deletions src/Screens/PasswordChange/PasswordChangeContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";

export const PasswordChangeContainer = () => {
return (
<>
</>
)
}
1 change: 1 addition & 0 deletions src/Screens/PasswordChange/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./PasswordChangeContainer";
8 changes: 8 additions & 0 deletions src/Screens/Signup/SignupContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";

export const SignupContainer = () => {
return (
<>
</>
)
}
1 change: 1 addition & 0 deletions src/Screens/Signup/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./SignupContainer";
4 changes: 3 additions & 1 deletion src/Screens/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export enum RootScreens {
MAIN = "Main",
WELCOME = "Welcome",
SETTINGS = "Settings"
SETTINGS = "Settings",
LOGIN = "Login",
SIGNUP = "Signup",
}
2 changes: 2 additions & 0 deletions src/Theme/Variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export enum Icons{
ARROW_RIGHT = "arrow-right",
HOME = "home-outline",
HISTORY = "calendar-month",
WALLET = "wallet-outline",
BUDGET = "briefcase-outline",
ACCOUNT = "account-circle-outline",
PLUS = "plus-circle",
LOCATION = "map-marker",
Expand Down
1 change: 1 addition & 0 deletions src/Theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Variables";

0 comments on commit 5279571

Please sign in to comment.