App.js 3.12 KB
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
import React, { useState } from 'react';
Choi Ga Young's avatar
Choi Ga Young committed
2
3
4
import { StyleSheet, View, Text, TextInput, Button } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
Choi Ga Young's avatar
Choi Ga Young committed
5
import { createStackNavigator } from '@react-navigation/stack';
Choi Ga Young's avatar
Choi Ga Young committed
6
7
import Ionicons from 'react-native-vector-icons/Ionicons';
import Monthly from './Monthly';
Choi Ga Young's avatar
Choi Ga Young committed
8
import Analy from './Analy';
9
import PostMoney from './PostMoney';
10
import InsertCat from './InsertCat';
Choi Ga Young's avatar
Choi Ga Young committed
11
import DetailInfo from './DetailInfo';
Test User's avatar
Test User committed
12

Choi Ga Young's avatar
Choi Ga Young committed
13
function MainScreen({ navigation }) {
Choi Ga Young's avatar
Choi Ga Young committed
14
15
16
  const [number, onChangeNumber] = useState(null)
  const [totalAssets, setTotalAssets] = useState(0) //총 자산

Choi Ga Young's avatar
Choi Ga Young committed
17
18
19
  return (
    <>
      <View>
Choi Ga Young's avatar
Choi Ga Young committed
20
21
22
23
24
        <Text style={style.Font}>주간 캘린더 들어올 자리</Text>
        <View style={style.Contents}>
          <Text style={style.Font}> 자산</Text>
          <Text style={style.Font}>{totalAssets}</Text>
        </View>
Choi Ga Young's avatar
Choi Ga Young committed
25
26
        <TextInput
          style={style.TextInput}
Choi Ga Young's avatar
Choi Ga Young committed
27
          onChangeText={onChangeNumber}
Choi Ga Young's avatar
Choi Ga Young committed
28
29
30
31
32
33
34
          keyboardType="numeric"
        />
        <Text>입력한 숫자 보기: {number} </Text>
      </View>
      <Button
        title="월별 페이지로 이동"
        onPress={() => navigation.navigate('Monthly')}
Choi Ga Young's avatar
Choi Ga Young committed
35
      />
36
      <InsertCat />
Choi Ga Young's avatar
Choi Ga Young committed
37
    </>
Choi Ga Young's avatar
Choi Ga Young committed
38
39
  )
}
Test User's avatar
Test User committed
40

Choi Ga Young's avatar
Choi Ga Young committed
41
const Tab = createBottomTabNavigator();
Choi Ga Young's avatar
Choi Ga Young committed
42
const Stack = createStackNavigator();
Test User's avatar
Test User committed
43

Choi Ga Young's avatar
Choi Ga Young committed
44
function Home() {
Test User's avatar
Test User committed
45
  return (
Choi Ga Young's avatar
Choi Ga Young committed
46
47
48
    <Tab.Navigator screenOptions={({ route }) => ({
      tabBarIcon: ({ focused, color, size }) => {
        let iconName;
Test User's avatar
Test User committed
49

Choi Ga Young's avatar
Choi Ga Young committed
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
        if (route.name === 'Main') {
          iconName = focused
            ? 'home'
            : 'home-outline';
        } else if (route.name === 'Monthly') {
          iconName = focused ? 'calendar' : 'calendar-outline';
        } else if (route.name === 'Analy') {
          iconName = focused ? 'bar-chart' : 'bar-chart-outline';
        } 
        // else if (route.name === 'Calendar') {
        //   iconName = focused ? 'calendar-sharp' : 'calendar-sharp';
        // }

        // You can return any component that you like here!
        return <Ionicons name={iconName} size={size} color={color} />;
      },
    })}
      tabBarOptions={{
        activeTintColor: 'skyblue',
        inactiveTintColor: 'gray',
      }}>
      <Tab.Screen name="Main" component={MainScreen} />
      <Tab.Screen name="Monthly" component={Monthly} />
      {/*<Tab.Screen name="Calendar" component={Calendar} />*/}
      <Tab.Screen name="Analy" component={Analy} />
      <Tab.Screen name="PostMoney" component={PostMoney} />
    </Tab.Navigator>
  )
}
Test User's avatar
Test User committed
79

Choi Ga Young's avatar
Choi Ga Young committed
80
81
82
83
84
85
86
function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen options={{headerShown: false}} name="Home" component={Home} />
        <Stack.Screen name="DetailInfo" component={DetailInfo} />
      </Stack.Navigator>
Choi Ga Young's avatar
Choi Ga Young committed
87
    </NavigationContainer>
Test User's avatar
Test User committed
88
  );
Choi Ga Young's avatar
Choi Ga Young committed
89
}
Test User's avatar
Test User committed
90

Choi Ga Young's avatar
Choi Ga Young committed
91
92
93
94
95
96
const style = StyleSheet.create({
  TextInput: {
    borderColor: 'skyblue',
    height: 40,
    margin: 12,
    borderWidth: 1
Test User's avatar
Test User committed
97
  },
Choi Ga Young's avatar
Choi Ga Young committed
98
99
  Font: {
    fontSize: 24
Choi Ga Young's avatar
Choi Ga Young committed
100
101
102
103
  },
  Contents: {
    justifyContent: "center",
    alignItems: "center",
Choi Ga Young's avatar
Choi Ga Young committed
104
    margin: 10
Choi Ga Young's avatar
Choi Ga Young committed
105
  }
Test User's avatar
Test User committed
106
107
});
export default App;