From 79602942e1330953b68938b725962742c597a71e Mon Sep 17 00:00:00 2001 From: zeeun <98653814+zeeun@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:49:36 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=EC=8A=A4=ED=83=9D=ED=99=94=EB=A9=B4?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- screens/Home.js | 30 ++++++++++++++++++++++++------ screens/NewStackScreen.js | 16 ++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 screens/NewStackScreen.js diff --git a/screens/Home.js b/screens/Home.js index 2f65fd4..5bb13d8 100644 --- a/screens/Home.js +++ b/screens/Home.js @@ -12,6 +12,10 @@ import { import { Block, theme } from "galio-framework"; import ImagePicker from "../components/ImagePickerComponent"; import { Camera } from "expo-camera"; +import { createStackNavigator } from "@react-navigation/stack"; +import NewStackScreen from "./NewStackScreen"; // 경로를 실제 파일 경로로 변경하세요. + +const Stack = createStackNavigator(); const { width, height } = Dimensions.get("screen"); @@ -59,11 +63,11 @@ class Home extends React.Component { savePhoto = async () => { if (!this.state.photo) { - console.error("No photo to save."); + console.error("저장할 사진이 없습니다."); return; } - console.log("Saved Photo:", this.state.photo.base64); + console.log("사진 저장됨:", this.state.photo.base64); const formData = new FormData(); formData.append("imageFile", { @@ -86,11 +90,18 @@ class Home extends React.Component { } else { console.error("사진을 백엔드로 전송하는 데 실패했습니다.", response); } + + const data = await response.json(); + this.props.navigation.push("NewStackScreen", { data: data }); } catch (error) { console.error("사진을 백엔드로 전송 중 오류 발생:", error); + + // 백엔드 제출이 실패하더라도 에러 메시지를 포함하여 NewStackScreen으로 이동합니다. + this.props.navigation.push("NewStackScreen", { + error: "백엔드 제출 실패", + }); } - // Close the camera modal after saving this.setState({ photo: null, isCameraVisible: false }); }; @@ -196,9 +207,16 @@ class Home extends React.Component { render() { return ( - - {this.renderArticles()} - + + + {() => ( + + {this.renderArticles()} + + )} + + + ); } } diff --git a/screens/NewStackScreen.js b/screens/NewStackScreen.js new file mode 100644 index 0000000..0945652 --- /dev/null +++ b/screens/NewStackScreen.js @@ -0,0 +1,16 @@ +import React from "react"; +import { View, Text } from "react-native"; + +const NewStackScreen = ({ route }) => { + const { data } = route.params; + + return ( + + {/* {JSON.stringify(data)}{" "} */} + {/* Or however you want to display the data */} + 약물분석로그 + + ); +}; + +export default NewStackScreen;