diff --git a/components/DrugCard.js b/components/DrugCard.js new file mode 100644 index 0000000..8df086d --- /dev/null +++ b/components/DrugCard.js @@ -0,0 +1,47 @@ +import React from "react"; +import { View, Text, Image, StyleSheet } from "react-native"; + +const DrugCard = ({ item }) => { + const { itemName, efcyQesitm, warn, sideEffect, image, typeName } = item; + + return ( + + 제품 명: {itemName} + 효능: {efcyQesitm} + 주의사항: {warn} + 부작용: {sideEffect} + {image && } + 위험분류: {typeName} + + ); +}; + +const styles = StyleSheet.create({ + card: { + backgroundColor: "#fff", + borderRadius: 8, + padding: 20, + marginBottom: 20, + shadowColor: "#000", + shadowOffset: { + width: 0, + height: 2, + }, + shadowOpacity: 0.25, + shadowRadius: 3.84, + elevation: 5, + }, + title: { + fontSize: 18, + fontWeight: "bold", + marginBottom: 10, + }, + image: { + width: 100, + height: 100, + resizeMode: "cover", + marginBottom: 10, + }, +}); + +export default DrugCard; diff --git a/components/ImagePickerComponent.js b/components/ImagePickerComponent.js index c22181a..26b367e 100644 --- a/components/ImagePickerComponent.js +++ b/components/ImagePickerComponent.js @@ -5,8 +5,11 @@ import Constants from "expo-constants"; import axios from "axios"; import { withNavigation } from "@react-navigation/compat"; + + const ImagePickerComponent = ({ navigation }) => { const [selectedImage, setSelectedImage] = useState(null); + const [selectedImageData, setSelectedImageData] = useState(null); useEffect(() => { (async () => { @@ -22,6 +25,16 @@ const ImagePickerComponent = ({ navigation }) => { })(); }, []); + // ImagePickerComponent +useEffect(() => { + if (selectedImageData) { + navigation.push("NewStackScreen", { + selectedImageData: selectedImageData, + }); + } +}, [selectedImageData]); + + const pickImageAndSend = async () => { let result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Images, @@ -52,14 +65,17 @@ const ImagePickerComponent = ({ navigation }) => { headers: { "Content-Type": "multipart/form-data", }, - timeout: 100000000000000000000000, // 10초 시간 제한 설정 + timeout: 1000000000, // 10초 시간 제한 설정 } ); // Handle response from backend console.log(response.data); + setSelectedImageData(response.data); // Open a new stack screen after image selection - navigation.push("NewStackScreen", { selectedImage }); + navigation.push("NewStackScreen", { + selectedImageData: selectedImageData, + }); } catch (error) { console.error(error); } diff --git a/components/KakaoLogin.js b/components/KakaoLogin.js index 172db0c..06632f1 100644 --- a/components/KakaoLogin.js +++ b/components/KakaoLogin.js @@ -1,19 +1,12 @@ // KakaoLogin.js import React, { useState } from "react"; -import { - View, - Button, - Modal, - TouchableOpacity, - Text, - Image, -} from "react-native"; +import { View, TouchableOpacity, Image, Modal } from "react-native"; import { WebView } from "react-native-webview"; import axios from "axios"; const runFirst = `window.ReactNativeWebView.postMessage("this is message from web");`; -const KakaoLogin = ({ navigation }) => { +const KakaoLogin = ({ onLoginSuccess }) => { const [modalVisible, setModalVisible] = useState(false); const handleLoginButton = () => { @@ -43,7 +36,8 @@ const KakaoLogin = ({ navigation }) => { }) .then(function (response) { console.log("Backend Response:", response); - navigation.navigate("Home"); + // 카카오 로그인이 성공했을 때 콜백 함수 호출 + onLoginSuccess(); }) .catch(function (error) { console.log("Backend Error:", error); diff --git a/components/ModalComponent.js b/components/ModalComponent.js new file mode 100644 index 0000000..1b97cc7 --- /dev/null +++ b/components/ModalComponent.js @@ -0,0 +1,151 @@ +import React from "react"; +import { + View, + Text, + StyleSheet, + Modal, + Button, + TouchableOpacity, +} from "react-native"; +import RadioButton from "react-native-radio-button"; +import { Picker } from "@react-native-picker/picker"; +import DateTimePicker from "@react-native-community/datetimepicker"; + +const ModalComponent = (props) => { + return ( + + + + 복용 정보 입력 + {props.drugName} + + + 복용시작일: + + + + + 복용마감일: + + + + + 현재 복용중 여부: + + + Yes + + No + + + + + 하루 복용 횟수: + + + + + + + + + +