Commit 8589b5b3 authored by Choi Ga Young's avatar Choi Ga Young
Browse files

키보드 수정

parent 4cd275f1
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { View, StyleSheet } from 'react-native'; import { View, StyleSheet, Keyboard, TouchableWithoutFeedback } from 'react-native';
import InputBox from './components/InputBox'; import InputBox from './components/InputBox';
import ButtonsForm from './components/ButtonsForm'; import ButtonsForm from './components/ButtonsForm';
import SelectForm from './components/SelectForm'; import SelectForm from './components/SelectForm';
...@@ -83,8 +83,8 @@ function updatePage({ navigation, route }) { ...@@ -83,8 +83,8 @@ function updatePage({ navigation, route }) {
const deleteData = async () => { const deleteData = async () => {
try { try {
if (selectedIndex === 2){ if (selectedIndex === 2) {
await updateApi.delData({ findId: [route.params[1].id, route.params[1].id+1] }) await updateApi.delData({ findId: [route.params[1].id, route.params[1].id + 1] })
} else { } else {
await updateApi.delData({ findId: [route.params[1].id] }) await updateApi.delData({ findId: [route.params[1].id] })
} }
...@@ -97,9 +97,9 @@ function updatePage({ navigation, route }) { ...@@ -97,9 +97,9 @@ function updatePage({ navigation, route }) {
const changeData = async () => { const changeData = async () => {
try { try {
if(selectedIndex===2){ if (selectedIndex === 2) {
await updateApi.updateData({ findId: route.params[1].id }, [date, contents, -price, selected_cat.id, selected_subcat.id, selected_asset_type.id, selectedIndex + 1]) await updateApi.updateData({ findId: route.params[1].id }, [date, contents, -price, selected_cat.id, selected_subcat.id, selected_asset_type.id, selectedIndex + 1])
await updateApi.updateData({ findId: route.params[1].id+1 }, [date, contents, price, selected_cat.id, selected_subcat.id, selected_deposit_asset_type.id, selectedIndex + 1]) await updateApi.updateData({ findId: route.params[1].id + 1 }, [date, contents, price, selected_cat.id, selected_subcat.id, selected_deposit_asset_type.id, selectedIndex + 1])
} else { } else {
await updateApi.updateData({ findId: route.params[1].id }, [date, contents, price, selected_cat.id, selected_subcat.id, selected_asset_type.id, selectedIndex + 1]) await updateApi.updateData({ findId: route.params[1].id }, [date, contents, price, selected_cat.id, selected_subcat.id, selected_asset_type.id, selectedIndex + 1])
} }
...@@ -121,83 +121,88 @@ function updatePage({ navigation, route }) { ...@@ -121,83 +121,88 @@ function updatePage({ navigation, route }) {
navigation.goBack() navigation.goBack()
} }
return ( return (
<View> <TouchableWithoutFeedback onPress={() => {
<View> Keyboard.dismiss();
{selectedIndex === 2 ? null : <ButtonsForm }} >
onPress={(index) => setSelectedIndex(index)} <View style={{ flex: 1 }}>
selectedIndex={selectedIndex} <View>
group={["수입", "지출"]} />} {selectedIndex === 2 ? null : <ButtonsForm
onPress={(index) => { setSelectedIndex(index); Keyboard.dismiss(); }}
<DatePicker selectedIndex={selectedIndex}
inputTitle="날짜" group={["수입", "지출"]} />}
date={date}
setDate={setDate} <DatePicker
/> inputTitle="날짜"
<InputBox date={date}
inputTitle="내용" setDate={setDate}
value={contents} />
onChangeText={ <InputBox
(contents) => setContents(contents) inputTitle="내용"
} value={contents}
maxLength={30} onChangeText={
/> (contents) => setContents(contents)
<InputBox }
inputTitle="금액" maxLength={30}
value={price} />
onChangeText={ <InputBox
(price) => setPrice(price) inputTitle="금액"
} value={price}
keyboardType="numeric" onChangeText={
maxLength={30} (price) => setPrice(price)
/> }
<SelectForm keyboardType="numeric"
inputTitle={selectedIndex === 2 ? "출금" : "자산"} maxLength={30}
placeholder="자산 선택" />
data={asset_type}
selectedData={selected_asset_type}
onValueChange={(asset) => setSelected_asset_type(asset)}
onUpdateDataPress={onUpdateAssetPress}
/>
{selectedIndex === 2 &&
<SelectForm <SelectForm
inputTitle="입금" inputTitle={selectedIndex === 2 ? "출금" : "자산"}
placeholder="자산 선택" placeholder="자산 선택"
data={asset_type} data={asset_type}
selectedData={selected_deposit_asset_type} selectedData={selected_asset_type}
onValueChange={(deposit_asset) => setSelected_deposit_asset_type(deposit_asset)} onValueChange={(asset) => setSelected_asset_type(asset)}
onUpdateDataPress={onUpdateAssetPress} onUpdateDataPress={onUpdateAssetPress}
/>} />
<SelectForm {selectedIndex === 2 &&
inputTitle="구분" <SelectForm
placeholder="카테고리 선택" inputTitle="입금"
data={categories} placeholder="자산 선택"
selectedData={selected_cat} data={asset_type}
onValueChange={(cat) => setSelected_cat(cat)} selectedData={selected_deposit_asset_type}
subData={subcategories} onValueChange={(deposit_asset) => setSelected_deposit_asset_type(deposit_asset)}
selectedSubData={selected_subcat} onUpdateDataPress={onUpdateAssetPress}
onSubValueChange={(subcat) => setSelected_subcat(subcat)} />}
onUpdateDataPress={onUpdateCatPress} <SelectForm
/> inputTitle="구분"
</View> placeholder="카테고리 선택"
<View style={style.buttonRow}> data={categories}
<StyledButton selectedData={selected_cat}
name="저장" onValueChange={(cat) => setSelected_cat(cat)}
onPress={changeData} subData={subcategories}
style={style.submitButton} selectedSubData={selected_subcat}
/> onSubValueChange={(subcat) => setSelected_subcat(subcat)}
<StyledButton onUpdateDataPress={onUpdateCatPress}
name="삭제" />
onPress={deleteData} </View>
style={style.delButton} <View style={style.buttonRow}>
/> <StyledButton
<StyledButton name="저장"
name="취소" onPress={changeData}
onPress={() => navigation.goBack()} style={style.submitButton}
style={style.cancelButton} />
/> <StyledButton
name="삭제"
onPress={deleteData}
style={style.delButton}
/>
<StyledButton
name="취소"
onPress={() => navigation.goBack()}
style={style.cancelButton}
/>
</View>
</View> </View>
</View> </TouchableWithoutFeedback>
) )
}; };
const style = StyleSheet.create({ const style = StyleSheet.create({
......
...@@ -104,10 +104,10 @@ function Calendar({ ...@@ -104,10 +104,10 @@ function Calendar({
setMonth(month + 1) setMonth(month + 1)
} }
} }
useEffect(() => { // useEffect(() => {
setMonth(todayM) // setMonth(todayM)
setYear(todayY) // setYear(todayY)
}, []) // }, [])
const onLayout = (event) => { const onLayout = (event) => {
const { x, y, height, width } = event.nativeEvent.layout; const { x, y, height, width } = event.nativeEvent.layout;
......
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