App.js 2.71 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
5
6
7
8
import { StyleSheet, View, Text, TextInput, Button } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Ionicons from 'react-native-vector-icons/Ionicons';
import Monthly from './Monthly';
import Analy from './Analy';
import MoneyDB from './MoneyDB';
Choi Ga Young's avatar
Choi Ga Young committed
9
import Calendar from './Calendar';
Test User's avatar
Test User committed
10

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

Choi Ga Young's avatar
Choi Ga Young committed
15
16
17
  return (
    <>
      <View>
Choi Ga Young's avatar
Choi Ga Young committed
18
19
20
21
22
        <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
23
24
        <TextInput
          style={style.TextInput}
Choi Ga Young's avatar
Choi Ga Young committed
25
          onChangeText={onChangeNumber}
Choi Ga Young's avatar
Choi Ga Young committed
26
27
28
29
30
31
32
          keyboardType="numeric"
        />
        <Text>입력한 숫자 보기: {number} </Text>
      </View>
      <Button
        title="월별 페이지로 이동"
        onPress={() => navigation.navigate('Monthly')}
Choi Ga Young's avatar
Choi Ga Young committed
33
      />
Choi Ga Young's avatar
Choi Ga Young committed
34
      <MoneyDB />
Choi Ga Young's avatar
Choi Ga Young committed
35
    </>
Choi Ga Young's avatar
Choi Ga Young committed
36
37
  )
}
Test User's avatar
Test User committed
38

Choi Ga Young's avatar
Choi Ga Young committed
39
const Tab = createBottomTabNavigator();
Test User's avatar
Test User committed
40

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

Choi Ga Young's avatar
Choi Ga Young committed
48
49
50
51
52
53
54
55
56
57
58
          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';
          }
Test User's avatar
Test User committed
59

Choi Ga Young's avatar
Choi Ga Young committed
60
61
62
63
          // You can return any component that you like here!
          return <Ionicons name={iconName} size={size} color={color} />;
        },
      })}
Choi Ga Young's avatar
Choi Ga Young committed
64
        tabBarOptions={{
Choi Ga Young's avatar
Choi Ga Young committed
65
          activeTintColor: 'skyblue',
Choi Ga Young's avatar
Choi Ga Young committed
66
67
68
69
70
          inactiveTintColor: 'gray',
        }}>
        <Tab.Screen name="Main" component={MainScreen} />
        <Tab.Screen name="Monthly" component={Monthly} />
        <Tab.Screen name="Analy" component={Analy} />
Choi Ga Young's avatar
Choi Ga Young committed
71
        <Tab.Screen name="Calendar" component={Calendar} />
Choi Ga Young's avatar
Choi Ga Young committed
72
73
      </Tab.Navigator>
    </NavigationContainer>
Test User's avatar
Test User committed
74
  );
Choi Ga Young's avatar
Choi Ga Young committed
75
}
Test User's avatar
Test User committed
76

Choi Ga Young's avatar
Choi Ga Young committed
77
78
79
80
81
82
const style = StyleSheet.create({
  TextInput: {
    borderColor: 'skyblue',
    height: 40,
    margin: 12,
    borderWidth: 1
Test User's avatar
Test User committed
83
  },
Choi Ga Young's avatar
Choi Ga Young committed
84
85
  Font: {
    fontSize: 24
Choi Ga Young's avatar
Choi Ga Young committed
86
87
88
89
90
  },
  Contents: {
    justifyContent: "center",
    alignItems: "center",
    margin:10
Choi Ga Young's avatar
Choi Ga Young committed
91
  }
Test User's avatar
Test User committed
92
93
});
export default App;