App.js 3.75 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
11
import ReviewForm from './screens/reviewForm';

Test User's avatar
Test User committed
12

YoonDongMin's avatar
YoonDongMin committed
13

Choi Ga Young's avatar
Choi Ga Young committed
14
15
function MainScreen({ navigation }) {
  const [number, onChangeNumber] = React.useState(null);
YoonDongMin's avatar
모달    
YoonDongMin committed
16
17
18
19
20
21
22
23
24
25
26
27
28
  const [modalOpen, setModalOpen] = useState(false);
  const [reviews, setReviews] = useState([
    { title: 'aa', rating: 5, body: 'bb', key: '1' },
  ]);

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

Choi Ga Young's avatar
Choi Ga Young committed
29
30
  return (
    <>
YoonDongMin's avatar
YoonDongMin committed
31
32
      <TouchableWithoutFeedback onPress={() => {
        Keyboard.dismiss();
YoonDongMin's avatar
모달    
YoonDongMin committed
33

YoonDongMin's avatar
YoonDongMin committed
34
      }}>
YoonDongMin's avatar
모달    
YoonDongMin committed
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
        <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')}
          />
                    <Modal visible={modalOpen} animationType='slide'>
            <View style={style.modalContent}>
              <Ionicons
                name='close'
                size={24}
                style={{ ...style.modalToggle, ...style.modalClose }}
                onPress={() => setModalOpen(false)}
              />
              <ReviewForm addReview = {addReview} />
            </View>
          </Modal>
          <Ionicons
            name='add'
            size={24}
            style={style.modalToggle}
            onPress={() => setModalOpen(true)}
YoonDongMin's avatar
YoonDongMin committed
69
70
71
          />
        </View>
      </TouchableWithoutFeedback>
YoonDongMin's avatar
모달    
YoonDongMin committed
72

YoonDongMin's avatar
YoonDongMin committed
73
    </>
Choi Ga Young's avatar
Choi Ga Young committed
74
75
  )
}
Test User's avatar
Test User committed
76

YoonDongMin's avatar
YoonDongMin committed
77
78


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

Choi Ga Young's avatar
Choi Ga Young committed
81
function App() {
Test User's avatar
Test User committed
82
  return (
YoonDongMin's avatar
YoonDongMin committed
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
    <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
108
109

  );
Choi Ga Young's avatar
Choi Ga Young committed
110
}
Test User's avatar
Test User committed
111

Choi Ga Young's avatar
Choi Ga Young committed
112
const style = StyleSheet.create({
YoonDongMin's avatar
모달    
YoonDongMin committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
  modalToggle: {
    marginBottom: 10,
    borderWidth: 1,
    borderColor: '#f2f2f2',
    padding: 10,
    borderRadius: 10,
    alignSelf: 'center',
  },
  modalClose: {
    marginTop: 20,
    marginBottom: 0,
  },
  modalContent: {
    flex: 1,

  },

Choi Ga Young's avatar
Choi Ga Young committed
130
131
132
133
134
  TextInput: {
    borderColor: 'skyblue',
    height: 40,
    margin: 12,
    borderWidth: 1
Test User's avatar
Test User committed
135
  },
Choi Ga Young's avatar
Choi Ga Young committed
136
137
138
  Font: {
    fontSize: 24
  }
Test User's avatar
Test User committed
139
140
});
export default App;