-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
138 lines (127 loc) · 4.31 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { AntDesign, Ionicons } from "@expo/vector-icons";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { NavigationContainer, useIsFocused } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { SplashScreen } from "expo";
import React, { useEffect } from "react";
import { TouchableOpacity, View } from "react-native";
import { Text } from "react-native-elements";
import DashboardScreen from "./app/screens/DashboardScreen";
import ExpenseScreen from "./app/screens/ExpenseScreen";
import HomeScreen from "./app/screens/HomeScreen";
import { testProps } from "./app/utils/common";
import * as Storage from "./app/utils/storage";
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
const DashboardScreenStack = createStackNavigator();
const Dashboard = () => {
return (
<DashboardScreenStack.Navigator>
<DashboardScreenStack.Screen
name="Dashboard"
options={{
headerTitle: () => (
<View accessible={true}>
<Text h4 style={{ color: "steelblue" }} {...testProps("dashboard header title")} accessible={true}>
Dashboard
</Text></View>
),
headerTitleAlign: "center"
}}
component={DashboardScreen}
/>
</DashboardScreenStack.Navigator>
);
};
const Expenses = () => {
const isFocused= useIsFocused();
return (
<Stack.Navigator headerMode="screen" >
<Stack.Screen
name="Home"
component={HomeScreen}
options={({ navigation }) => ({
unmountOnBlur: true,
headerTitleAlign: "center",
headerTitle: () => ( <View accessible={true}>
<Text h4 style={{ color: "steelblue" }} {...testProps("header title")} accessible={true}>
Expenses
</Text></View>
),
headerRightContainerStyle: { paddingHorizontal: 22 },
headerRight: () => {if(isFocused===true) return (
<TouchableOpacity
onPress={() => navigation.push("EditExpense")}
accessible={true}
style={{
flexDirection: "row",
justifyContent: "center",
alignItems: "center"
}}
>
<AntDesign
accessible={true}
{...testProps("Add Expense Button")}
color="steelblue"
name="plus"
size={24}
onPress={() => navigation.push("EditExpense")}
/>
</TouchableOpacity>
);else return (<View></View>)}
})}
/>
<Stack.Screen
name="EditExpense"
options={({ route }) => ({
headerTitleAlign: "center",
accessible: true,
title: "Add Expenses",
headerTitle: props => ( <View accessible={true}>
<Text
h4
style={{ color: "steelblue" }}
{...testProps("header title 2")} accessible={true} {...route}
>
{route.params.expenseItem ? "Edit" : "Add"} Expense
</Text></View>
)
})}
initialParams={{ expenseItem: null }}
component={ExpenseScreen}
/>
</Stack.Navigator>
);
};
export default function App() {
useEffect(() => {
Storage.checkTable();
SplashScreen.hide();
})
return (
<NavigationContainer>
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === "Home") {
iconName = "ios-home";
} else if (route.name === "Dashboard") {
iconName = "ios-stats";
}
// You can return any component that you like here!
return <Ionicons accessible={true} {...testProps(route.name)} name={iconName} size={size} color={color} />;
}
})}
tabBarOptions={{
showLabel:false,
activeTintColor: "steelblue",
inactiveTintColor: "gray"
}}
>
<Tab.Screen name="Home" component={Expenses} />
<Tab.Screen name="Dashboard" component={Dashboard} />
</Tab.Navigator>
</NavigationContainer>
);
}