App.js 4.54 KB
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
import * as React from 'react';
YoonDongMin's avatar
모달    
YoonDongMin committed
2
3
import { useState } from 'react';
import { StyleSheet, View, Text, TextInput, Button, Keyboard, TouchableWithoutFeedback, Modal } from 'react-native';
Choi Ga Young's avatar
Choi Ga Young committed
4
5
6
7
8
9
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';
YoonDongMin's avatar
부채    
YoonDongMin committed
10
import DeptPage from './DeptPage';
YoonDongMin's avatar
모달    
YoonDongMin committed
11
import ReviewForm from './screens/reviewForm';
YoonDongMin's avatar
부채    
YoonDongMin committed
12
13
import { SpeedDial } from 'react-native-elements';

YoonDongMin's avatar
모달    
YoonDongMin committed
14

Test User's avatar
Test User committed
15

YoonDongMin's avatar
YoonDongMin committed
16

Choi Ga Young's avatar
Choi Ga Young committed
17
function MainScreen({ navigation }) {
YoonDongMin's avatar
부채    
YoonDongMin committed
18
  const [number, onChangeNumber] = useState(null);
YoonDongMin's avatar
모달    
YoonDongMin committed
19
  const [modalOpen, setModalOpen] = useState(false);
YoonDongMin's avatar
부채    
YoonDongMin committed
20
21
22
23
  // const [reviews, setReviews] = useState([
  //   { title: 'aa', rating: 5, body: 'bb', key: '1' },
  // ]);
  const [open, setOpen] = useState(false)
YoonDongMin's avatar
모달    
YoonDongMin committed
24
25
26
27
28
29
30
31
32

  const addReview = (review) => {
    review.key = Math.random().toString();
    setReviews((currentReviews) => {
      return [review, ...currentReviews]
    });
    setModalOpen(false);
  }

Choi Ga Young's avatar
Choi Ga Young committed
33
34
  return (
    <>
YoonDongMin's avatar
YoonDongMin committed
35
36
      <TouchableWithoutFeedback onPress={() => {
        Keyboard.dismiss();
YoonDongMin's avatar
모달    
YoonDongMin committed
37

YoonDongMin's avatar
YoonDongMin committed
38
      }}>
YoonDongMin's avatar
모달    
YoonDongMin committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        <View style={{ flex: 1 }}>


          <View >
            <Text style={style.Font}>여기는 메인 페이지 입니다.</Text>
            <Text style={style.Font}>아래는 input 테스트를 위한 것입니다.</Text>
            <TextInput
              style={style.TextInput}
              onChangeText={onChangeNumber}
              keyboardType="numeric"
            />
            <Text>입력한 숫자 보기: {number} </Text>
          </View>

          <Button
            title="월별 페이지로 이동"
            onPress={() => navigation.navigate('Monthly')}
          />
YoonDongMin's avatar
부채    
YoonDongMin committed
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
          <SpeedDial
            isOpen={open}
            icon={{ name: 'edit', color: '#fff' }} //연필모양
            openIcon={{ name: 'close', color: '#fff' }} //x모양
            onOpen={() => setOpen(!open)}
            onClose={() => setOpen(!open)}
          >
            <SpeedDial.Action
              icon={{ name: 'add', color: '#fff' }}
              title="부채"
              onPress={() => setModalOpen(true)}
            />
            <SpeedDial.Action
              icon={{ name: 'delete', color: '#fff' }}
              title="Delete"
              onPress={() => setModalOpen(true)}
            />

          </SpeedDial>
          <Modal visible={modalOpen} animationType='slide'>
              <View style={style.modalContent}>
                <Ionicons
                  name='close'
                  color='red'
                  size={24}
                  style={{ ...style.modalToggle, ...style.modalClose }} //...은 중괄호를 풀어서 합치려고 이용함
                  onPress={() => setModalOpen(false)}
                />
                <DeptPage />
              </View>
            </Modal>
          <MoneyDB />

YoonDongMin's avatar
YoonDongMin committed
90
        </View>
YoonDongMin's avatar
모달    
YoonDongMin committed
91

YoonDongMin's avatar
부채    
YoonDongMin committed
92
      </TouchableWithoutFeedback>
YoonDongMin's avatar
YoonDongMin committed
93
    </>
Choi Ga Young's avatar
Choi Ga Young committed
94
95
  )
}
Test User's avatar
Test User committed
96

YoonDongMin's avatar
YoonDongMin committed
97
98


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

Choi Ga Young's avatar
Choi Ga Young committed
101
function App() {
Test User's avatar
Test User committed
102
  return (
YoonDongMin's avatar
YoonDongMin committed
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
    <NavigationContainer>
      <Tab.Navigator screenOptions={({ route }) => ({
        tabBarIcon: ({ focused, color, size }) => {
          let iconName;

          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';
          }
          // You can return any component that you like here!
          return <Ionicons name={iconName} size={size} color={color} />;
        },
      })}
        tabBarOptions={{
          activeTintColor: 'tomato',
          inactiveTintColor: 'gray',
        }}>
        <Tab.Screen name="Main" component={MainScreen} />
        <Tab.Screen name="Monthly" component={Monthly} />
        <Tab.Screen name="Analy" component={Analy} />
      </Tab.Navigator>
    </NavigationContainer>
Test User's avatar
Test User committed
128
129

  );
Choi Ga Young's avatar
Choi Ga Young committed
130
}
Test User's avatar
Test User committed
131

Choi Ga Young's avatar
Choi Ga Young committed
132
const style = StyleSheet.create({
YoonDongMin's avatar
모달    
YoonDongMin committed
133
134
135
  modalToggle: {
    marginBottom: 10,
    borderWidth: 1,
YoonDongMin's avatar
부채    
YoonDongMin committed
136
    borderColor: 'grey', //grey
YoonDongMin's avatar
모달    
YoonDongMin committed
137
138
    padding: 10,
    borderRadius: 10,
YoonDongMin's avatar
부채    
YoonDongMin committed
139
    alignSelf: 'center', //위치를 center로
YoonDongMin's avatar
모달    
YoonDongMin committed
140
141
142
143
144
145
  },
  modalClose: {
    marginTop: 20,
    marginBottom: 0,
  },
  modalContent: {
YoonDongMin's avatar
부채    
YoonDongMin committed
146
    flex: 1, //이후 유용한 키보드를 추가하려고 ex)dismissing keyboard
YoonDongMin's avatar
모달    
YoonDongMin committed
147
148
  },

Choi Ga Young's avatar
Choi Ga Young committed
149
150
151
152
153
  TextInput: {
    borderColor: 'skyblue',
    height: 40,
    margin: 12,
    borderWidth: 1
Test User's avatar
Test User committed
154
  },
Choi Ga Young's avatar
Choi Ga Young committed
155
156
157
  Font: {
    fontSize: 24
  }
Test User's avatar
Test User committed
158
159
});
export default App;