Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
rich-maker
Commits
d513a4bd
Commit
d513a4bd
authored
Aug 04, 2021
by
Choi Ga Young
Browse files
불필요한거 삭제 및 함수이름변경
parent
ff89d354
Changes
13
Hide whitespace changes
Inline
Side-by-side
Analy.js
View file @
d513a4bd
...
...
@@ -4,7 +4,6 @@ import ChartY from './ChartY';
import
chartApi
from
'
./db/chartData.api
'
;
import
ButtonsForm
from
'
./components/ButtonsForm
'
;
import
{
View
,
Dimensions
}
from
'
react-native
'
;
const
screenWidth
=
Dimensions
.
get
(
"
window
"
).
width
;
const
Analy
=
()
=>
{
const
date
=
new
Date
();
...
...
App.js
View file @
d513a4bd
import
React
from
'
react
'
;
import
{
StyleSheet
}
from
'
react-native
'
;
import
{
NavigationContainer
}
from
'
@react-navigation/native
'
;
import
{
createBottomTabNavigator
}
from
'
@react-navigation/bottom-tabs
'
;
import
{
createStackNavigator
}
from
'
@react-navigation/stack
'
;
...
...
@@ -15,7 +14,6 @@ import MemoPage from './MemoPage';
import
MemoDetails
from
'
./screens/MemoDetails
'
;
import
EditOption
from
'
./EditOption
'
;
const
Tab
=
createBottomTabNavigator
();
const
Stack
=
createStackNavigator
();
...
...
@@ -38,7 +36,7 @@ function Home() {
},
})}
tabBarOptions
=
{{
activeTintColor
:
'
skyblue
'
,
activeTintColor
:
'
#bfd3f2
'
,
inactiveTintColor
:
'
gray
'
,
}}
>
<
Tab
.
Screen
name
=
"
Main
"
component
=
{
MainScreen
}
/
>
...
...
@@ -95,21 +93,4 @@ function App() {
);
}
const
style
=
StyleSheet
.
create
({
TextInput
:
{
borderColor
:
'
skyblue
'
,
height
:
40
,
margin
:
12
,
borderWidth
:
1
},
Font
:
{
fontSize
:
24
},
Contents
:
{
justifyContent
:
"
center
"
,
alignItems
:
"
center
"
,
margin
:
10
}
});
export
default
App
;
CalDetail.js
View file @
d513a4bd
...
...
@@ -51,7 +51,6 @@ const DetailInfo = ({ route }) => {
<
Text
style
=
{{
textAlign
:
"
center
"
,
fontSize
:
20
,
fontFamily
:
'
GowunDodum-Regular
'
}}
>
내역이
없습니다
.
<
/Text
>
<
/View
>
}
<
/SafeAreaView
>
<
/
>
)
...
...
ChartY.js
View file @
d513a4bd
...
...
@@ -18,7 +18,7 @@ const ChartY = ({ resDataY, year, setYear }) => {
strokeWidth
:
2
,
// optional, default 3
barPercentage
:
0.5
,
// 그래프 width
useShadowColorFromDataset
:
false
,
// optional, default is false
fillShadowGradientOpacity
:
1
,
// 좀 더 진하게만 할 뿐 단색 설정은 못하는 것 같음
fillShadowGradientOpacity
:
1
,
};
const
prevBtn
=
()
=>
{
setYear
(
year
-
1
)
...
...
@@ -28,25 +28,19 @@ const ChartY = ({ resDataY, year, setYear }) => {
}
const
convertY
=
(
y
)
=>
{
console
.
log
(
'
convert y=====
'
,
y
)
let
res
=
''
;
if
(
y
>=
1000000000
)
{
res
=
(
y
/
1000000000
).
toFixed
(
2
)
+
"
B
"
console
.
log
(
'
단위변환중
'
,
res
)
}
else
if
(
y
>=
1000000
)
{
res
=
(
y
/
1000000
).
toFixed
(
2
)
+
"
M
"
console
.
log
(
'
단위변환중
'
,
res
)
}
else
if
(
y
>=
1000
)
{
res
=
(
y
/
1000
).
toFixed
(
2
)
+
"
K
"
console
.
log
(
'
단위변환중
'
,
res
)
}
return
res
}
console
.
log
(
'
잠만확인
'
,
resDataY
.
temp1
[
0
].
datasets
[
0
].
data
,
'
|
'
,
resDataY
.
temp2
[
0
].
datasets
[
0
].
data
)
let
totalYI
=
(
resDataY
.
temp1
[
0
].
datasets
[
0
].
data
).
reduce
((
acc
,
curr
)
=>
acc
+
curr
,
0
);
let
totalYO
=
(
resDataY
.
temp2
[
0
].
datasets
[
0
].
data
).
reduce
((
acc
,
curr
)
=>
acc
+
curr
,
0
);
console
.
log
(
'
합산 확인
'
,
totalYI
,
'
|
'
,
totalYO
)
return
(
<>
...
...
MemoPage.js
View file @
d513a4bd
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
import
{
StyleSheet
,
Text
,
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
Ionicons
from
'
react-native-vector-icons/Ionicons
'
;
import
MemoForm
from
'
./screens/MemoForm
'
;
import
memoApi
from
'
./db/memoPage.api
'
;
function
MemoPage
({
navigation
})
{
const
[
memos
,
setMemos
]
=
useState
([])
const
[
selectedIndex
,
setSelectedIndex
]
=
useState
(
0
)
const
[
memos
,
setMemos
]
=
useState
([]);
const
[
modalOpen
,
setModalOpen
]
=
useState
(
false
);
const
loadMemos
=
async
()
=>
{
...
...
@@ -20,7 +19,6 @@ function MemoPage({ navigation }) {
}
}
const
addInfo
=
async
(
info
)
=>
{
await
memoApi
.
insertMemo
(
info
)
setModalOpen
(
false
);
...
...
@@ -32,20 +30,15 @@ function MemoPage({ navigation }) {
loadMemos
();
}
useEffect
(()
=>
{
loadMemos
()
},
[])
return
(
<
TouchableWithoutFeedback
onPress
=
{()
=>
{
Keyboard
.
dismiss
();
}}
>
<
View
Style
=
{
style
.
container
}
>
<
View
style
=
{{
width
:
'
100%
'
,
height
:
'
95%
'
}}
>
<
View
style
=
{{
width
:
'
100%
'
,
height
:
'
80%
'
}}
>
<
View
>
...
...
@@ -58,12 +51,11 @@ function MemoPage({ navigation }) {
)}
/
>
<
/View
>
<
/View
>
<
Ionicons
name
=
'
add
'
size
=
{
24
}
style
=
{
style
.
modalToggle
}
//...은 중괄호를 풀어서 합치려고 이용함
style
=
{
style
.
modalToggle
}
onPress
=
{()
=>
setModalOpen
(
true
)}
/
>
<
/View
>
...
...
@@ -77,7 +69,6 @@ function MemoPage({ navigation }) {
onPress
=
{()
=>
setModalOpen
(
false
)}
/
>
<
MemoForm
addInfo
=
{
addInfo
}
/
>
<
/View
>
<
/Modal
>
<
/View
>
...
...
@@ -105,10 +96,9 @@ const style = StyleSheet.create({
},
modalContent
:
{
flex
:
1
,
//이후 유용한 키보드를 추가하려고 ex)dismissing keyboard
flex
:
1
,
},
TextInput
:
{
borderColor
:
'
skyblue
'
,
height
:
40
,
...
...
PostMoney.js
View file @
d513a4bd
...
...
@@ -6,7 +6,7 @@ import SelectForm from './components/SelectForm';
import
StyledButton
from
'
./components/StyledButton
'
;
import
DatePicker
from
'
./components/DatePicker
'
;
import
moneyApi
from
'
./db/postMoney.api
'
;
import
{
getDate
}
from
'
./utils/dateFunction
'
import
{
getDate
Str
}
from
'
./utils/dateFunction
'
const
INIT_ASSETSTYPE
=
{
id
:
1
,
...
...
@@ -24,9 +24,9 @@ const INIT_SUBCATEGORY = {
foreign_id
:
0
,
}
const
PostMoney
=
({
navigation
})
=>
{
const
PostMoney
=
({
navigation
})
=>
{
const
[
selectedIndex
,
setSelectedIndex
]
=
useState
(
0
)
const
[
date
,
setDate
]
=
useState
(
getDate
())
const
[
date
,
setDate
]
=
useState
(
getDate
Str
())
const
[
contents
,
setContents
]
=
useState
(
''
)
const
[
price
,
setPrice
]
=
useState
(
''
)
const
[
asset_type
,
setAsset_type
]
=
useState
([])
...
...
@@ -36,7 +36,7 @@ const PostMoney = ({navigation}) => {
const
[
selected_cat
,
setSelected_cat
]
=
useState
(
INIT_CATEGORY
)
const
[
subcategories
,
setSubcategories
]
=
useState
([])
const
[
selected_subcat
,
setSelected_subcat
]
=
useState
(
INIT_SUBCATEGORY
)
const
[
success
,
setSuccess
]
=
useState
(
false
)
useEffect
(()
=>
{
...
...
@@ -110,15 +110,16 @@ const PostMoney = ({navigation}) => {
}
const
onUpdateCatPress
=
()
=>
{
navigation
.
navigate
(
'
EditOption
'
,
selectedIndex
+
1
)
navigation
.
navigate
(
'
EditOption
'
,
selectedIndex
+
1
)
}
const
onUpdateAssetPress
=
()
=>
{
navigation
.
navigate
(
'
EditOption
'
,
0
)
}
if
(
success
){
if
(
success
)
{
initData
()
setSuccess
(
false
)
}
...
...
components/Calendar.js
View file @
d513a4bd
...
...
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
import
{
SafeAreaView
,
StyleSheet
,
View
,
Text
,
FlatList
,
TouchableOpacity
}
from
'
react-native
'
;
import
{
Button
}
from
'
react-native-elements
'
;
import
Ionicons
from
'
react-native-vector-icons/Ionicons
'
;
import
{
getDateStr
}
from
'
../utils/dateFunction
'
;
const
DateItem
=
({
dateitem
,
textColor
,
onPress
,
flatListHeight
})
=>
{
return
(
...
...
@@ -104,7 +105,7 @@ function Calendar({
}
return
(
<
DateItem
dateitem
=
{
item
}
textColor
=
{{
color
}}
onPress
=
{()
=>
navigation
.
navigate
(
'
CalDetail
'
,
String
(
item
.
date
.
toJSON
()).
split
(
/T/
)[
0
]
)}
flatListHeight
=
{
flatListHeight
/
(
Dates
.
length
/
7
)}
/
>
<
DateItem
dateitem
=
{
item
}
textColor
=
{{
color
}}
onPress
=
{()
=>
navigation
.
navigate
(
'
CalDetail
'
,
getDateStr
(
item
.
date
)
)}
flatListHeight
=
{
flatListHeight
/
(
Dates
.
length
/
7
)}
/
>
)
}
const
prevBtn
=
()
=>
{
...
...
@@ -170,19 +171,19 @@ function Calendar({
};
const
style
=
StyleSheet
.
create
({
EntContainer
:
{
//전체 (SafeAreaView)
EntContainer
:
{
flex
:
1
,
padding
:
20
},
Head
:
{
//00년00월
Head
:
{
fontSize
:
24
,
fontFamily
:
'
GowunDodum-Regular
'
},
Container
:
{
//년월, 버튼 뷰에 적용
Container
:
{
justifyContent
:
"
center
"
,
alignItems
:
"
center
"
,
},
dateContainer
:
{
//각 date에 적용 (Text 태그), DateItem 컴포넌트에 적용
dateContainer
:
{
flex
:
1
,
borderWidth
:
0.8
,
borderColor
:
'
#DCDCDC
'
...
...
@@ -194,7 +195,6 @@ const style = StyleSheet.create({
Days
:
{
flexDirection
:
'
row
'
,
backgroundColor
:
'
#6495ED
'
},
DayText
:
{
flex
:
1
,
...
...
components/DatePicker.js
View file @
d513a4bd
import
React
,
{
useState
}
from
"
react
"
;
import
{
Button
,
View
,
Text
,
StyleSheet
,
Pressable
}
from
"
react-native
"
;
import
DateTimePickerModal
from
"
react-native-modal-datetime-picker
"
;
import
{
getDateStr
}
from
'
../utils/dateFunction
'
;
const
DatePicker
=
(
props
)
=>
{
const
[
isDatePickerVisible
,
setDatePickerVisibility
]
=
useState
(
false
);
...
...
@@ -14,8 +15,7 @@ const DatePicker = (props) => {
};
const
handleConfirm
=
(
date
)
=>
{
console
.
log
(
"
A date has been picked:
"
,
String
(
date
.
toJSON
()).
split
(
/T/
)[
0
]);
props
.
setDate
(
String
(
date
.
toJSON
()).
split
(
/T/
)[
0
])
props
.
setDate
(
getDateStr
(
date
))
hideDatePicker
();
};
...
...
screens/DeptDetails.js
View file @
d513a4bd
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
import
{
StyleSheet
,
View
,
Text
,
Button
,
Pressable
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
{
globalStyles
}
from
'
../styles/global
'
;
import
{
StyleSheet
,
View
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
InputBox
from
'
../components/InputBox
'
;
import
StyledButton
from
'
../components/StyledButton
'
;
import
DatePicker
from
'
../components/DatePicker.js
'
;
import
deptApi
from
'
../db/deptPage.api
'
;
import
{
getDateStr
}
from
'
../utils/dateFunction
'
;
function
DeptDetails
({
route
,
navigation
})
{
const
{
item
,
loadLoan
}
=
route
.
params
const
getDate
=
()
=>
{
var
date
=
new
Date
();
return
(
String
(
date
.
toJSON
()).
split
(
/T/
)[
0
]
)
const
getDate
s
=
()
=>
{
const
date
=
new
Date
();
return
(
getDateStr
(
date
)
)
}
const
[
date
,
setDate
]
=
useState
(
getDate
())
const
[
date
,
setDate
]
=
useState
(
getDate
s
())
const
[
message
,
setMessage
]
=
useState
(
''
)
const
[
money
,
setMoney
]
=
useState
(
''
)
const
[
remained_money
,
setRemained_money
]
=
useState
(
''
)
...
...
@@ -28,9 +28,7 @@ function DeptDetails({ route, navigation }) {
await
deptApi
.
updateDept
({
date
,
message
,
money
,
remained_money
},
item
.
id
)
loadLoan
()
navigation
.
navigate
(
'
DeptPage
'
)
}
return
(
<
TouchableWithoutFeedback
onPress
=
{()
=>
{
Keyboard
.
dismiss
();
...
...
@@ -76,8 +74,6 @@ function DeptDetails({ route, navigation }) {
)
}
const
style
=
StyleSheet
.
create
({
Font
:
{
...
...
@@ -101,7 +97,4 @@ const style = StyleSheet.create({
}
});
export
default
DeptDetails
;
\ No newline at end of file
screens/DeptForm.js
View file @
d513a4bd
import
React
,
{
useState
}
from
'
react
'
;
import
{
StyleSheet
,
Button
,
View
,
Text
,
TextInput
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
React
from
'
react
'
;
import
{
Button
,
View
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
{
globalStyles
}
from
'
../styles/global.js
'
import
{
Formik
}
from
'
formik
'
;
import
*
as
yup
from
'
yup
'
;
import
DatePicker
from
'
../components/DatePicker.js
'
;
import
InputBox
from
'
../components/InputBox
'
;
import
{
getDateStr
}
from
'
../utils/dateFunction
'
;
const
ReviewSchema
=
yup
.
object
({
date
:
yup
.
string
()
//string만 받는다
.
required
(),
//아무것도 입력안했하면 안받음
date
:
yup
.
string
()
.
required
(),
message
:
yup
.
string
()
.
required
()
.
min
(
2
),
...
...
@@ -18,11 +19,10 @@ const ReviewSchema = yup.object({
.
required
()
})
const
getDate
=
()
=>
{
var
date
=
new
Date
();
return
(
String
(
date
.
toJSON
()).
split
(
/T/
)[
0
]
)
const
getDate
s
=
()
=>
{
const
date
=
new
Date
();
return
(
getDateStr
(
date
)
)
}
// const [date, setDate] = useState(getDate())
function
DeptForm
({
addInfo
})
{
return
(
...
...
@@ -33,51 +33,42 @@ function DeptForm({ addInfo }) {
<
Formik
initialValues
=
{{
date
:
''
,
message
:
''
,
money
:
''
,
remained_money
:
''
}}
validationSchema
=
{
ReviewSchema
}
onSubmit
=
{(
values
)
=>
{
//위의 4개의 val들을 전달
onSubmit
=
{(
values
)
=>
{
addInfo
(
values
);
}}
>
{({
handleChange
,
handleSubmit
,
values
})
=>
(
<
View
>
<
DatePicker
inputTitle
=
'
날짜
'
date
=
{
values
.
date
||
getDate
()}
//오늘날짜 아니면 바뀐날짜
date
=
{
values
.
date
||
getDate
s
()}
setDate
=
{
handleChange
(
'
date
'
)}
/
>
<
InputBox
inputTitle
=
"
내용
"
onChangeText
=
{
handleChange
(
'
message
'
)}
value
=
{
values
.
message
}
/
>
<
InputBox
inputTitle
=
"
금액
"
onChangeText
=
{
handleChange
(
'
money
'
)}
value
=
{
values
.
money
}
keyboardType
=
"
numeric
"
/>
<
InputBox
inputTitle
=
"
남은금액
"
onChangeText
=
{
handleChange
(
'
remained_money
'
)}
value
=
{
values
.
remained_money
}
keyboardType
=
"
numeric
"
/>
<
View
style
=
{{
marginVertical
:
'
10%
'
,
marginHorizontal
:
10
}}
>
<
Button
title
=
'
입력
'
color
=
'
dodgerblue
'
onPress
=
{
handleSubmit
}
/
>
<
Button
title
=
'
입력
'
color
=
'
dodgerblue
'
onPress
=
{
handleSubmit
}
/
>
<
/View
>
<
/View
>
)}
<
/Formik
>
<
/View
>
<
/TouchableWithoutFeedback
>
)
...
...
screens/MemoDetails.js
View file @
d513a4bd
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
StyleSheet
,
View
,
Text
,
Button
,
Pressable
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
{
globalStyles
}
from
'
../styles/global
'
;
import
{
StyleSheet
,
View
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
InputBox
from
'
../components/InputBox
'
;
import
StyledButton
from
'
../components/StyledButton
'
;
import
DatePicker
from
'
../components/DatePicker.js
'
;
import
memoApi
from
'
../db/memoPage.api
'
;
import
{
getDateStr
}
from
'
../utils/dateFunction
'
;
function
MemoDetails
({
route
,
navigation
})
{
const
{
item
,
loadMemos
}
=
route
.
params
const
getDate
=
()
=>
{
var
date
=
new
Date
();
return
(
String
(
date
.
toJSON
()).
split
(
/T/
)[
0
]
)
const
{
item
,
loadMemos
}
=
route
.
params
const
getDate
s
=
()
=>
{
const
date
=
new
Date
();
return
(
getDateStr
(
date
)
)
}
const
[
date
,
setDate
]
=
useState
(
getDate
())
const
[
date
,
setDate
]
=
useState
(
getDate
s
())
const
[
message
,
setMessage
]
=
useState
(
''
)
const
onUpdateHandle
=
async
()
=>
{
await
memoApi
.
updateMemo
({
date
,
message
},
item
.
id
)
loadMemos
()
navigation
.
navigate
(
'
MemoPage
'
)
// navigation.goBack()
// navigation.dispatch( navigation.navigate('MemoPage'));
}
useEffect
(()
=>
{
...
...
@@ -61,8 +57,6 @@ function MemoDetails({ route, navigation }) {
)
}
const
style
=
StyleSheet
.
create
({
buttonRow
:
{
...
...
@@ -81,7 +75,4 @@ const style = StyleSheet.create({
}
});
export
default
MemoDetails
;
\ No newline at end of file
screens/MemoForm.js
View file @
d513a4bd
import
React
,
{
useState
}
from
'
react
'
;
import
{
StyleSheet
,
Button
,
View
,
Text
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
React
from
'
react
'
;
import
{
Button
,
View
,
TouchableWithoutFeedback
,
Keyboard
}
from
'
react-native
'
;
import
{
globalStyles
}
from
'
../styles/global.js
'
import
{
Formik
}
from
'
formik
'
;
import
*
as
yup
from
'
yup
'
;
import
DatePicker
from
'
../components/DatePicker.js
'
;
import
InputBox
from
'
../components/InputBox.js
'
;
import
{
getDateStr
}
from
'
../utils/dateFunction
'
;
const
ReviewSchema
=
yup
.
object
({
// date: yup.string() //string만 받는다
// .required() //아무것도 입력안했하면 안받음
// , //최소4글짜
date
:
yup
.
string
()
.
required
(),
message
:
yup
.
string
()
.
required
()
.
min
(
2
),
})
const
getDate
=
()
=>
{
var
date
=
new
Date
();
return
(
String
(
date
.
toJSON
()).
split
(
/T/
)[
0
]
)
const
getDate
s
=
()
=>
{
const
date
=
new
Date
();
return
(
getDateStr
(
date
)
)
}
function
MemoForm
({
addInfo
})
{
return
(
<
TouchableWithoutFeedback
onPress
=
{()
=>
{
...
...
@@ -31,8 +30,7 @@ function MemoForm({ addInfo }) {
<
Formik
initialValues
=
{{
date
:
''
,
message
:
''
}}
validationSchema
=
{
ReviewSchema
}
onSubmit
=
{(
values
)
=>
{
//위의 4개의 val들을 전달
onSubmit
=
{(
values
)
=>
{
addInfo
(
values
);
}}
...
...
@@ -41,7 +39,7 @@ function MemoForm({ addInfo }) {
<
View
>
<
DatePicker
inputTitle
=
'
날짜
'
date
=
{
values
.
date
||
getDate
()}
//오늘날짜 아니면 바뀐날짜
date
=
{
values
.
date
||
getDate
s
()}
setDate
=
{
handleChange
(
'
date
'
)}
/
>
<
InputBox
...
...
@@ -50,7 +48,6 @@ function MemoForm({ addInfo }) {
value
=
{
values
.
message
}
/
>
<
View
style
=
{{
marginVertical
:
'
10%
'
,
marginHorizontal
:
10
}}
>
<
Button
title
=
'
입력
'
color
=
'
dodgerblue
'
onPress
=
{
handleSubmit
}
/
>
<
/View
>
...
...
utils/dateFunction.js
View file @
d513a4bd
export
function
getDate
(
item
)
{
export
function
getDate
Str
(
item
)
{
let
date
=
''
if
(
item
)
{
date
=
new
Date
(
item
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment