Commit 9a694c44 authored by Choi Ga Young's avatar Choi Ga Young
Browse files

clean 및 에러해결

parent 0c95c768
...@@ -80,7 +80,7 @@ const ChartM = ({ ...@@ -80,7 +80,7 @@ const ChartM = ({
< PieChart < PieChart
data={resDataM} data={resDataM}
width={screenWidth} width={screenWidth}
height={screenHeight / 3} height={screenHeight *0.3}
chartConfig={chartConfig} chartConfig={chartConfig}
accessor={"total"} accessor={"total"}
backgroundColor={"#ffffff"} backgroundColor={"#ffffff"}
...@@ -88,7 +88,7 @@ const ChartM = ({ ...@@ -88,7 +88,7 @@ const ChartM = ({
: <Text style={style.infoText}> 지출 내역이 없습니다.</Text> : <Text style={style.infoText}> 지출 내역이 없습니다.</Text>
} }
<FlatList <FlatList
style={{ backgroundColor: "#FFFFFF", height: screenHeight*0.42 }} style={{ backgroundColor: "#FFFFFF", height: screenHeight*0.51 }}
data={resDataM} data={resDataM}
renderItem={renderChart} renderItem={renderChart}
keyExtractor={item => item.color} keyExtractor={item => item.color}
...@@ -115,7 +115,8 @@ const style = StyleSheet.create({ ...@@ -115,7 +115,8 @@ const style = StyleSheet.create({
fontSize: 30, fontSize: 30,
textAlign: "center", textAlign: "center",
marginTop: "20%", marginTop: "20%",
fontFamily: 'GowunDodum-Regular' fontFamily: 'GowunDodum-Regular',
backgroundColor:'#ffffff'
} }
}); });
......
...@@ -2,14 +2,14 @@ import React, { useState, useEffect } from 'react'; ...@@ -2,14 +2,14 @@ import React, { useState, useEffect } from 'react';
import { StyleSheet, View, FlatList, TouchableOpacity, Modal, TouchableWithoutFeedback, Keyboard } from 'react-native'; import { StyleSheet, View, FlatList, TouchableOpacity, Modal, TouchableWithoutFeedback, Keyboard } from 'react-native';
import TodoItem from './components/TodoItem'; import TodoItem from './components/TodoItem';
import Ionicons from 'react-native-vector-icons/Ionicons'; import Ionicons from 'react-native-vector-icons/Ionicons';
import ButtonsForm from './components/ButtonsForm'; import ButtonsForm from './components/ButtonsForm';
import DeptForm from './screens/DeptForm'; import DeptForm from './screens/DeptForm';
import { TabView } from 'react-native-elements'; import { TabView } from 'react-native-elements';
import deptApi from './db/deptPage.api'; import deptApi from './db/deptPage.api';
function DeptPage({ navigation }) { function DeptPage({ navigation }) {
const [lend, setLend] = useState([]) const [lend, setLend] = useState([])
const [dept, setDept] = useState([]) const [dept, setDept] = useState([])
const [selectedIndex, setSelectedIndex] = useState(0) const [selectedIndex, setSelectedIndex] = useState(0)
const [modallOpen, setModallOpen] = useState(false); const [modallOpen, setModallOpen] = useState(false);
...@@ -23,7 +23,7 @@ function DeptPage({ navigation }) { ...@@ -23,7 +23,7 @@ function DeptPage({ navigation }) {
} }
} }
const loadDept = async () => { const loadDept = async () => {
try { try {
const deptArray = await deptApi.selectLoan("빌린금액") const deptArray = await deptApi.selectLoan("빌린금액")
setDept(deptArray); setDept(deptArray);
...@@ -44,7 +44,7 @@ function DeptPage({ navigation }) { ...@@ -44,7 +44,7 @@ function DeptPage({ navigation }) {
info['loan'] = "빌려준금액" info['loan'] = "빌려준금액"
} }
await deptApi.insertDept(info) await deptApi.insertDept(info)
setModallOpen(false); setModallOpen(false);
loadLoan() loadLoan()
} }
...@@ -53,7 +53,7 @@ function DeptPage({ navigation }) { ...@@ -53,7 +53,7 @@ function DeptPage({ navigation }) {
loadLoan() loadLoan()
} }
useEffect(() => { useEffect(() => {
loadLoan() loadLoan()
}, []) }, [])
...@@ -71,8 +71,8 @@ function DeptPage({ navigation }) { ...@@ -71,8 +71,8 @@ function DeptPage({ navigation }) {
<View> <View>
<View style={{ width: '100%', height: '75%' }}> <View style={{ width: '100%', height: '75%' }}>
<TabView value={selectedIndex} onChange={setSelectedIndex} > {selectedIndex === 0 ?
<TabView.Item style={{ width: '100%', height: '100%' }}> <View style={{ width: '100%', height: '100%' }}>
<FlatList <FlatList
data={lend} data={lend}
renderItem={({ item }) => ( renderItem={({ item }) => (
...@@ -81,8 +81,9 @@ function DeptPage({ navigation }) { ...@@ -81,8 +81,9 @@ function DeptPage({ navigation }) {
</TouchableOpacity> </TouchableOpacity>
)} )}
/> />
</TabView.Item> </View>
<TabView.Item style={{ width: '100%', height: '100%' }}> :
<View style={{ width: '100%', height: '100%' }}>
<FlatList <FlatList
data={dept} data={dept}
renderItem={({ item }) => ( renderItem={({ item }) => (
...@@ -91,13 +92,13 @@ function DeptPage({ navigation }) { ...@@ -91,13 +92,13 @@ function DeptPage({ navigation }) {
</TouchableOpacity> </TouchableOpacity>
)} )}
/> />
</TabView.Item> </View>
</TabView> }
</View> </View>
<Ionicons <Ionicons
name='add' name='add'
size={24} size={24}
style={style.modalToggle} style={style.modalToggle}
onPress={() => setModallOpen(true)} onPress={() => setModallOpen(true)}
/> />
</View> </View>
...@@ -131,14 +132,14 @@ const style = StyleSheet.create({ ...@@ -131,14 +132,14 @@ const style = StyleSheet.create({
}, },
modalToggle: { modalToggle: {
borderWidth: 1, borderWidth: 1,
borderColor: 'gray', borderColor: 'gray',
padding: 5, padding: 5,
borderRadius: 10, borderRadius: 10,
alignSelf: 'center', alignSelf: 'center',
}, },
modalContent: { modalContent: {
flex: 1, flex: 1,
} }
}); });
......
...@@ -54,7 +54,7 @@ const AssetItem = ({ item }) => { ...@@ -54,7 +54,7 @@ const AssetItem = ({ item }) => {
const getMarkedDates = (weeklyData) => { const getMarkedDates = (weeklyData) => {
if (weeklyData.length === 0) { if (weeklyData.length === 0) {
return null; return ([]);
} }
const markedData = weeklyData.map(data => { const markedData = weeklyData.map(data => {
...@@ -65,8 +65,7 @@ const getMarkedDates = (weeklyData) => { ...@@ -65,8 +65,7 @@ const getMarkedDates = (weeklyData) => {
} }
); );
}) })
return (markedData)
return markedData
} }
const getDots = (typeArray) => { const getDots = (typeArray) => {
...@@ -96,7 +95,6 @@ function MainScreen({ navigation }) { ...@@ -96,7 +95,6 @@ function MainScreen({ navigation }) {
const [selectedDate, setSelectedDate] = useState(getDateStr()) const [selectedDate, setSelectedDate] = useState(getDateStr())
const [startingDate, setStartingDate] = useState(initialStartingDate) const [startingDate, setStartingDate] = useState(initialStartingDate)
const [endDate, setEndDate] = useState(initialEndDate)
const [weekMoney, setWeekMoney] = useState({ input: 0, output: 0 }) const [weekMoney, setWeekMoney] = useState({ input: 0, output: 0 })
const [markedDates, setMarkedDates] = useState([]) const [markedDates, setMarkedDates] = useState([])
...@@ -106,16 +104,18 @@ function MainScreen({ navigation }) { ...@@ -106,16 +104,18 @@ function MainScreen({ navigation }) {
const [totalAssetsMoney, setTotalAssetsMoney] = useState([]) const [totalAssetsMoney, setTotalAssetsMoney] = useState([])
useEffect(() => { useEffect(() => {
getthisWeekData(initialStartingDate, initialEndDate) getthisWeekData(initialStartingDate, initialEndDate);
getTotalMoney() getTotalMoney();
getSingleData() getSingleData();
}, [isFocused]) }, [isFocused])
const getthisWeekData = async (start, end) => { const getthisWeekData = async (start, end) => {
const { data, input, output } = await weekApi.getWeeklyData(start, end) const { data, input, output } = await weekApi.getWeeklyData(start, end)
setStartingDate(start) setStartingDate(start)
setWeekMoney({ input: input, output, output }) setWeekMoney({ input: input, output, output })
setMarkedDates(getMarkedDates(data)) setTimeout(() => {
setMarkedDates(getMarkedDates(data))
}, 300)
} }
const getWeeklyData = async (start, end) => { const getWeeklyData = async (start, end) => {
...@@ -152,7 +152,7 @@ function MainScreen({ navigation }) { ...@@ -152,7 +152,7 @@ function MainScreen({ navigation }) {
selectedDate={selectedDate} selectedDate={selectedDate}
startingDate={startingDate} startingDate={startingDate}
onWeekChanged={(start, end) => getWeeklyData(start, end)} onWeekChanged={(start, end) => getWeeklyData(start, end)}
onDateSelected={(date) => setSelectedDate(date)} onDateSelected={(date) => setSelectedDate(getDateStr(date))}
markedDates={markedDates} markedDates={markedDates}
/> />
<View style={style.weekData}> <View style={style.weekData}>
...@@ -165,7 +165,7 @@ function MainScreen({ navigation }) { ...@@ -165,7 +165,7 @@ function MainScreen({ navigation }) {
{ {
singleMoney.length !== 0 ? singleMoney.length !== 0 ?
<View> <View>
{singleMoney.length !== 0 && singleMoney.map((item, index) => <DetailItem item={item} key={index} onPress={() => navigation.navigate('UpdatePage', [selectedDate, item])}/>)} {singleMoney.length !== 0 && singleMoney.map((item, index) => <DetailItem item={item} key={index} onPress={() => navigation.navigate('UpdatePage', [selectedDate, item])} />)}
</View> </View>
: <View style={{ marginTop: 10, marginBottom: 50 }}> : <View style={{ marginTop: 10, marginBottom: 50 }}>
<Text style={{ textAlign: "center", fontSize: 20, fontFamily: 'GowunDodum-Regular' }}>내역이 없습니다.</Text> <Text style={{ textAlign: "center", fontSize: 20, fontFamily: 'GowunDodum-Regular' }}>내역이 없습니다.</Text>
...@@ -195,7 +195,7 @@ function MainScreen({ navigation }) { ...@@ -195,7 +195,7 @@ function MainScreen({ navigation }) {
onClose={() => setOpen(!open)} onClose={() => setOpen(!open)}
> >
<SpeedDial.Action <SpeedDial.Action
icon={<FontAwesome name={'money'} size={20} color={'#fff'}/>} icon={<FontAwesome name={'money'} size={20} color={'#fff'} />}
title="부채" title="부채"
onPress={() => navigation.navigate('DeptPage')} onPress={() => navigation.navigate('DeptPage')}
/> />
......
...@@ -37,10 +37,10 @@ const PostMoney = ({ navigation }) => { ...@@ -37,10 +37,10 @@ const PostMoney = ({ navigation }) => {
const [subcategories, setSubcategories] = useState([]) const [subcategories, setSubcategories] = useState([])
const [selected_subcat, setSelected_subcat] = useState(INIT_SUBCATEGORY) const [selected_subcat, setSelected_subcat] = useState(INIT_SUBCATEGORY)
const [disabled, setDisabled] = useState(true) const [disabled, setDisabled] = useState(true)
const [success, setSuccess] = useState(false) const [success, setSuccess] = useState(false)
useEffect(() => { useEffect(() => {
loadCat() loadCat()
loadSubCat() loadSubCat()
...@@ -51,9 +51,9 @@ const PostMoney = ({ navigation }) => { ...@@ -51,9 +51,9 @@ const PostMoney = ({ navigation }) => {
useEffect(() => { useEffect(() => {
let isProper = false let isProper = false
if (selectedIndex === 2) { if (selectedIndex === 2) {
isProper = [contents, price, selected_asset_type.value, selected_deposit_asset_type.value, selected_cat.value].every( elem => elem !== '') isProper = [contents, price, selected_asset_type.value, selected_deposit_asset_type.value, selected_cat.value].every(elem => elem !== '')
} else { } else {
isProper = [contents, price, selected_asset_type.value, selected_cat.value].every( elem => elem !== '') isProper = [contents, price, selected_asset_type.value, selected_cat.value].every(elem => elem !== '')
} }
if (isProper) { if (isProper) {
...@@ -121,9 +121,11 @@ const PostMoney = ({ navigation }) => { ...@@ -121,9 +121,11 @@ const PostMoney = ({ navigation }) => {
} }
if (success) { if (success) {
navigation.goBack() setTimeout(() => {
navigation.goBack()
}, 500)
} }
return ( return (
<TouchableWithoutFeedback onPress={() => { <TouchableWithoutFeedback onPress={() => {
Keyboard.dismiss(); Keyboard.dismiss();
...@@ -131,7 +133,7 @@ const PostMoney = ({ navigation }) => { ...@@ -131,7 +133,7 @@ const PostMoney = ({ navigation }) => {
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<View> <View>
<ButtonsForm <ButtonsForm
onPress={(index) => {setSelectedIndex(index); Keyboard.dismiss();}} onPress={(index) => { setSelectedIndex(index); Keyboard.dismiss(); }}
selectedIndex={selectedIndex} selectedIndex={selectedIndex}
group={["수입", "지출", "이동"]} /> group={["수입", "지출", "이동"]} />
<DatePicker <DatePicker
......
...@@ -134,8 +134,11 @@ function updatePage({ navigation, route }) { ...@@ -134,8 +134,11 @@ function updatePage({ navigation, route }) {
} }
if (success) { if (success) {
navigation.goBack() setTimeout(() => {
navigation.goBack()
}, 500)
} }
return ( return (
<TouchableWithoutFeedback onPress={() => { <TouchableWithoutFeedback onPress={() => {
Keyboard.dismiss(); Keyboard.dismiss();
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment