diff --git a/injeRecipe/App.tsx b/injeRecipe/App.tsx index 4c5e1dc..2aa5305 100644 --- a/injeRecipe/App.tsx +++ b/injeRecipe/App.tsx @@ -16,14 +16,15 @@ import { } from 'react-native'; -import { NavigationContainer } from '@react-navigation/native'; +import { NavigationContainer, useNavigation } from '@react-navigation/native'; import { SafeAreaProvider } from 'react-native-safe-area-context'; -import { Provider } from 'react-redux' +import { Provider, useDispatch } from 'react-redux' import store from './src/redux/store'; import RootStackNavigation from './src/navigations/RootStackNavigation'; + function App(){ - + return ( diff --git a/injeRecipe/ios/Podfile.lock b/injeRecipe/ios/Podfile.lock index 09be99b..81bfdaf 100644 --- a/injeRecipe/ios/Podfile.lock +++ b/injeRecipe/ios/Podfile.lock @@ -1141,6 +1141,8 @@ PODS: - React-jsi (= 0.73.2) - React-logger (= 0.73.2) - React-perflogger (= 0.73.2) + - RNCAsyncStorage (1.22.0): + - React-Core - RNGestureHandler (2.15.0): - glog - RCT-Folly (= 2022.05.16.00) @@ -1239,6 +1241,7 @@ DEPENDENCIES: - React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`) - React-utils (from `../node_modules/react-native/ReactCommon/react/utils`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) - "RNGoogleSignin (from `../node_modules/@react-native-google-signin/google-signin`)" - RNReanimated (from `../node_modules/react-native-reanimated`) @@ -1371,6 +1374,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/react/utils" ReactCommon: :path: "../node_modules/react-native/ReactCommon" + RNCAsyncStorage: + :path: "../node_modules/@react-native-async-storage/async-storage" RNGestureHandler: :path: "../node_modules/react-native-gesture-handler" RNGoogleSignin: @@ -1452,6 +1457,7 @@ SPEC CHECKSUMS: React-runtimescheduler: df8945a656356ff10f58f65a70820478bfcf33ad React-utils: f5bc61e7ea3325c0732ae2d755f4441940163b85 ReactCommon: 45b5d4f784e869c44a6f5a8fad5b114ca8f78c53 + RNCAsyncStorage: c43e6d71e13bb4748503797784839e0fbbf89d56 RNGestureHandler: deda62b8339496ba721a45e0f3e2d7a319932cee RNGoogleSignin: fc408799f1990a12497a32f64280c0fe353ffcc1 RNReanimated: 7d6d32f238f914f13d9d6fb45c0aef557f7f901e diff --git a/injeRecipe/package-lock.json b/injeRecipe/package-lock.json index 2ffa682..c100c69 100644 --- a/injeRecipe/package-lock.json +++ b/injeRecipe/package-lock.json @@ -11,6 +11,7 @@ "@dotlottie/react-player": "^1.6.15", "@gorhom/bottom-sheet": "^4.6.0", "@lottiefiles/react-lottie-player": "^3.5.3", + "@react-native-async-storage/async-storage": "^1.22.0", "@react-native-community/geolocation": "^3.1.0", "@react-native-google-signin/google-signin": "^11.0.0", "@react-navigation/bottom-tabs": "^6.5.11", @@ -18,17 +19,20 @@ "@react-navigation/native-stack": "^6.9.17", "@tsconfig/react-native": "^3.0.3", "axios": "^1.6.7", + "deprecated-react-native-prop-types": "^5.0.0", "fork-ts-checker-webpack-plugin": "^9.0.2", "lottie-react-native": "^6.5.1", "react": "18.2.0", "react-dom": "^18.2.0", "react-native": "0.73.2", + "react-native-bit-swiper": "^1.1.8", "react-native-gesture-handler": "^2.15.0", "react-native-image-picker": "^7.1.0", "react-native-modal": "^13.0.1", "react-native-reanimated": "^3.7.0", "react-native-safe-area-context": "^4.8.2", "react-native-screens": "^3.29.0", + "react-native-swiper-flatlist": "^3.2.3", "react-native-vector-icons": "^10.0.3", "react-native-web": "^0.19.10", "react-redux": "^9.1.0", @@ -3833,6 +3837,17 @@ "url": "https://opencollective.com/preact" } }, + "node_modules/@react-native-async-storage/async-storage": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.22.0.tgz", + "integrity": "sha512-b5KD010iiZnot86RbAaHpLuHwmPW2qA3SSN/OSZhd1kBoINEQEVBuv+uFtcaTxAhX27bT0wd13GOb2IOSDUXSA==", + "dependencies": { + "merge-options": "^3.0.4" + }, + "peerDependencies": { + "react-native": "^0.0.0-0 || >=0.60 <1.0" + } + }, "node_modules/@react-native-community/cli": { "version": "12.3.3", "resolved": "https://registry.npmjs.org/@react-native-community/cli/-/cli-12.3.3.tgz", @@ -14280,6 +14295,25 @@ "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", "dev": true }, + "node_modules/merge-options": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz", + "integrity": "sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ==", + "dependencies": { + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/merge-options/node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "engines": { + "node": ">=8" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -15978,6 +16012,18 @@ "prop-types": "^15.7.2" } }, + "node_modules/react-native-bit-swiper": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/react-native-bit-swiper/-/react-native-bit-swiper-1.1.8.tgz", + "integrity": "sha512-UcG3NKlClg95qIL5xLe2fHkBaUWcqoGv62895vUosIejAK4vV9Ti8WcWFitTOw42/3CMpcjJhjW3gBC7csmE5w==", + "dependencies": { + "prop-types": "^15.6.1" + }, + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/react-native-gesture-handler": { "version": "2.15.0", "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.15.0.tgz", @@ -16059,6 +16105,14 @@ "react-native": "*" } }, + "node_modules/react-native-swiper-flatlist": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/react-native-swiper-flatlist/-/react-native-swiper-flatlist-3.2.3.tgz", + "integrity": "sha512-L4KSy4X1mzUx9a/gZa+lBpY7agS/GHCSzSjHjpIDQB7qh03jKm4PsKyYE5KfFzJRzBMm/srfrixfWzHncZmhkQ==", + "peerDependencies": { + "react-native": ">=0.59.0" + } + }, "node_modules/react-native-vector-icons": { "version": "10.0.3", "resolved": "https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-10.0.3.tgz", diff --git a/injeRecipe/package.json b/injeRecipe/package.json index cf38885..3daf318 100644 --- a/injeRecipe/package.json +++ b/injeRecipe/package.json @@ -15,6 +15,7 @@ "@dotlottie/react-player": "^1.6.15", "@gorhom/bottom-sheet": "^4.6.0", "@lottiefiles/react-lottie-player": "^3.5.3", + "@react-native-async-storage/async-storage": "^1.22.0", "@react-native-community/geolocation": "^3.1.0", "@react-native-google-signin/google-signin": "^11.0.0", "@react-navigation/bottom-tabs": "^6.5.11", @@ -22,17 +23,20 @@ "@react-navigation/native-stack": "^6.9.17", "@tsconfig/react-native": "^3.0.3", "axios": "^1.6.7", + "deprecated-react-native-prop-types": "^5.0.0", "fork-ts-checker-webpack-plugin": "^9.0.2", "lottie-react-native": "^6.5.1", "react": "18.2.0", "react-dom": "^18.2.0", "react-native": "0.73.2", + "react-native-bit-swiper": "^1.1.8", "react-native-gesture-handler": "^2.15.0", "react-native-image-picker": "^7.1.0", "react-native-modal": "^13.0.1", "react-native-reanimated": "^3.7.0", "react-native-safe-area-context": "^4.8.2", "react-native-screens": "^3.29.0", + "react-native-swiper-flatlist": "^3.2.3", "react-native-vector-icons": "^10.0.3", "react-native-web": "^0.19.10", "react-redux": "^9.1.0", diff --git a/injeRecipe/react-native-bit-swiper.d.ts b/injeRecipe/react-native-bit-swiper.d.ts new file mode 100644 index 0000000..5603424 --- /dev/null +++ b/injeRecipe/react-native-bit-swiper.d.ts @@ -0,0 +1 @@ +declare module 'react-native-bit-swiper'; diff --git a/injeRecipe/src/@types/screen.tsx b/injeRecipe/src/@types/screen.tsx index fc46d08..1861e08 100644 --- a/injeRecipe/src/@types/screen.tsx +++ b/injeRecipe/src/@types/screen.tsx @@ -1,17 +1,12 @@ export const RootStackParamList = { Home:"Home", Bottom:"Bottom", - HomeStack:"HomeStackNavigator" -} - -export type BottomStackParamList = { + HomeStack:"HomeStackNavigator", Main:undefined, Refrigator:undefined, Search:undefined, - Info:undefined -} - -export const HomeStackParamList = { + Info:undefined, SignIn:"SignIn", SignUp:undefined -} \ No newline at end of file +} + diff --git a/injeRecipe/src/assets/lottie/weather/cloudy.json b/injeRecipe/src/assets/lottie/weather/cloudy.json new file mode 100644 index 0000000..4fe1c77 --- /dev/null +++ b/injeRecipe/src/assets/lottie/weather/cloudy.json @@ -0,0 +1 @@ +{"v":"5.5.9","fr":30,"ip":0,"op":600,"w":200,"h":200,"nm":"天气-多云","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"“乌云”轮廓","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[89.95,115.1,0],"ix":2},"a":{"a":0,"k":[76.6,50.05,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,18.8],[7.5,6.5],[0,1],[19.401,0],[0,-19.299],[-0.101,-0.299],[5.2,0],[0,-18.5],[-18,-0.599],[0,0],[0,0],[0,0]],"o":[[0,-10.601],[0.101,-1],[0,-19.299],[-19.4,0],[0,0.301],[-4.401,-2.199],[-18.5,0],[0,18.1],[0,0],[0,0],[0,0],[18.5,-0.799]],"v":[[65.25,14.8],[52.95,-11.801],[53.15,-14.801],[17.95,-49.8],[-17.25,-14.801],[-17.149,-13.801],[-31.75,-17.2],[-65.25,16.3],[-32.85,49.699],[-32.85,49.8],[31.75,49.8],[31.75,49.699]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.969000004787,0.969000004787,0.969000004787,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[65.5,50.05],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,18.3],[19.4,0],[0,-18.5],[0,0],[0,0]],"o":[[0,-18.4],[-19.4,0],[0,0],[0,0],[19.2,-0.3]],"v":[[35.2,0],[0,-33.4],[-35.2,0],[-35.2,33.4],[0.4,33.4]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.917999985639,0.917999985639,0.917999985639,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[117.75,66.451],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 2","np":2,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":601,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"“太阳”轮廓","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[128.397,85.608,0],"ix":2},"a":{"a":0,"k":[37.356,37.368,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-20.489,-0.009],[-0.009,20.49],[0,0],[20.49,0.003],[0.003,-20.49]],"o":[[-0.009,20.49],[20.49,0.009],[0,0],[0.003,-20.49],[-20.49,-0.004],[0,0]],"v":[[-37.097,-0.008],[-0.013,37.109],[37.103,0.025],[37.103,-0.008],[0.009,-37.113],[-37.097,-0.02]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.929000016755,0.663000009574,0.081999999402,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[37.356,37.368],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":601,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"“光芒”轮廓","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":600,"s":[360]}],"ix":10},"p":{"a":0,"k":[128.449,85.6,0],"ix":2},"a":{"a":0,"k":[58.9,61.35,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[1.3,1],[-0.901,1.3],[0,0],[-1.299,-0.9],[0.9,-1.3],[0,0]],"o":[[-1.301,-1],[0,0],[1,-1.3],[1.3,1],[0,0],[-1,1.3]],"v":[[27.951,-38.5],[27.251,-42.7],[31.65,-48.7],[35.85,-49.4],[36.551,-45.2],[32.15,-39.2]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0.5,1.6],[-1.5,0.5],[0,0],[-0.5,-1.5],[1.5,-0.5],[0,0]],"o":[[-0.5,-1.6],[0,0],[1.599,-0.5],[0.5,1.6],[0,0],[-1.6,0.5]],"v":[[45.251,-14.7],[47.15,-18.5],[54.251,-20.8],[58.051,-18.9],[56.15,-15.1],[49.051,-12.8]],"c":true},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[-0.5,1.6],[-1.6,-0.6],[0,0],[0.599,-1.6],[1.599,0.6],[0,0]],"o":[[0.5,-1.6],[0,0],[1.601,0.5],[-0.5,1.6],[0,0],[-1.599,-0.5]],"v":[[45.251,14.7],[49.051,12.8],[56.15,15.1],[58.051,18.9],[54.251,20.8],[47.15,18.5]],"c":true},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ind":3,"ty":"sh","ix":4,"ks":{"a":0,"k":{"i":[[-1.4,1],[-0.899,-1.4],[0,0],[1.401,-0.9],[0.901,1.4],[0,0]],"o":[[1.3,-1],[0,0],[1,1.3],[-1.299,1],[0,0],[-1,-1.3]],"v":[[27.951,38.5],[32.15,39.2],[36.551,45.2],[35.85,49.4],[31.65,48.7],[27.251,42.7]],"c":true},"ix":2},"nm":"路径 4","mn":"ADBE Vector Shape - Group","hd":false},{"ind":4,"ty":"sh","ix":5,"ks":{"a":0,"k":{"i":[[-1.7,0],[0,-1.6],[0,0],[1.6,0],[0,1.6],[0,0]],"o":[[1.699,0],[0,0],[0,1.7],[-1.7,0],[0,0],[0,-1.7]],"v":[[-0.049,47.6],[2.951,50.6],[2.951,58.1],[-0.049,61.1],[-3.049,58.1],[-3.049,50.6]],"c":true},"ix":2},"nm":"路径 5","mn":"ADBE Vector Shape - Group","hd":false},{"ind":5,"ty":"sh","ix":6,"ks":{"a":0,"k":{"i":[[-1.3,-1],[0.901,-1.3],[0,0],[1.299,0.9],[-0.899,1.3],[0,0]],"o":[[1.3,1],[0,0],[-1,1.3],[-1.3,-1],[0,0],[1,-1.4]],"v":[[-28.049,38.5],[-27.35,42.7],[-31.749,48.7],[-35.949,49.4],[-36.65,45.2],[-32.249,39.2]],"c":true},"ix":2},"nm":"路径 6","mn":"ADBE Vector Shape - Group","hd":false},{"ind":6,"ty":"sh","ix":7,"ks":{"a":0,"k":{"i":[[-0.5,-1.6],[1.5,-0.5],[0,0],[0.5,1.5],[-1.5,0.5],[0,0]],"o":[[0.5,1.6],[0,0],[-1.6,0.5],[-0.5,-1.6],[0,0],[1.601,-0.6]],"v":[[-45.349,14.7],[-47.249,18.5],[-54.349,20.8],[-58.15,18.9],[-56.249,15.1],[-49.15,12.8]],"c":true},"ix":2},"nm":"路径 7","mn":"ADBE Vector Shape - Group","hd":false},{"ind":7,"ty":"sh","ix":8,"ks":{"a":0,"k":{"i":[[0.641,-1.597],[1.512,0.696],[0,0],[-0.695,1.512],[-1.512,-0.695],[0,0]],"o":[[-0.558,1.542],[0,0],[-1.543,-0.558],[0.558,-1.542],[0,0],[1.543,0.557]],"v":[[-44.187,-14.327],[-48.104,-12.657],[-55.041,-15.347],[-56.712,-19.264],[-52.795,-20.934],[-45.858,-18.244]],"c":true},"ix":2},"nm":"路径 8","mn":"ADBE Vector Shape - Group","hd":false},{"ind":8,"ty":"sh","ix":9,"ks":{"a":0,"k":{"i":[[1.399,-1],[0.9,1.4],[0,0],[-1.4,0.9],[-0.901,-1.4],[0,0]],"o":[[-1.3,1],[0,0],[-1,-1.3],[1.299,-1],[0,0],[1,1.3]],"v":[[-28.049,-38.5],[-32.249,-39.2],[-36.65,-45.2],[-35.949,-49.4],[-31.749,-48.7],[-27.35,-42.7]],"c":true},"ix":2},"nm":"路径 9","mn":"ADBE Vector Shape - Group","hd":false},{"ind":9,"ty":"sh","ix":10,"ks":{"a":0,"k":{"i":[[1.699,0],[0,1.6],[0,0],[-1.601,0],[0,-1.6],[0,0]],"o":[[-1.7,0],[0,0],[0,-1.7],[1.699,0],[0,0],[0,1.6]],"v":[[-0.049,-47.6],[-3.049,-50.6],[-3.049,-58.1],[-0.049,-61.1],[2.951,-58.1],[2.951,-50.6]],"c":true},"ix":2},"nm":"路径 10","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"合并路径 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"fl","c":{"a":0,"k":[0.929000016755,0.663000009574,0.081999999402,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[58.9,61.35],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":12,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":601,"st":0,"bm":0}],"markers":[]} \ No newline at end of file diff --git a/injeRecipe/src/color/colors.tsx b/injeRecipe/src/color/colors.tsx index d1bfcdc..14dc33c 100644 --- a/injeRecipe/src/color/colors.tsx +++ b/injeRecipe/src/color/colors.tsx @@ -3,6 +3,8 @@ export const Colors ={ BUTTON_SIGNUP : "#323232", FONT_WHITE: "#FFFFFF", SEPARATED_LINE : "#E5E5E5", + SEPARATED_LINE_TORNUP : "#515151", + BACKGROUND_DEFAULT : "#FEFCFC", REFRIGATOR_AI_BUTTON:"#cb6930", SELECTED_ITEM_BACKGROUND : "#ffcc99" diff --git a/injeRecipe/src/component/Header.tsx b/injeRecipe/src/component/Header.tsx index 9e1ad0c..5b5dad5 100644 --- a/injeRecipe/src/component/Header.tsx +++ b/injeRecipe/src/component/Header.tsx @@ -6,7 +6,7 @@ export function Header(){ const styles = StyleSheet.create({ container:{ - height:height*0.07, + height:100, alignContent:"center", alignItems:"center", justifyContent:"center", diff --git a/injeRecipe/src/feature/home/HomeView.tsx b/injeRecipe/src/feature/home/HomeView.tsx index 71a6eca..f588cd8 100644 --- a/injeRecipe/src/feature/home/HomeView.tsx +++ b/injeRecipe/src/feature/home/HomeView.tsx @@ -1,23 +1,97 @@ import LottieView from "lottie-react-native"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { Image, Pressable, SafeAreaView, StyleSheet, Text, View } from "react-native"; -import { GoogleAuthButton } from "../../screens/home/signin/google/GoogleAuthButton"; - - import { Margin } from "../../component/Margin"; import { SignUpButton } from "./SignUpButton"; import { LoginAimButton } from "./LoginAimButton"; import { useNavigation } from "@react-navigation/native"; +import { useDispatch } from "react-redux"; +import { useSignIn } from "../../hooks/useSignIn"; +import { setLoginedUser, setUserWeather, setWeatherRecommendMenu } from "../../redux/action/actionLogin"; +import Geolocation from "@react-native-community/geolocation"; +import { weatherService } from "../../services/weatherService"; +import { useWeather } from "../../hooks/useWeather"; +import { chatGptService } from "../../services/chatGptService"; export function HomeView() { + // hooks const navigation = useNavigation() - const [LoginIsExpanded,setLoginIsExpanded] = useState(false) + const dispatch = useDispatch() + const { + isSignedIn, + googleSigninConfigure, + getCurrentUser + } = useSignIn() + // api + const {POST_WEATHER} = weatherService() + const {GET_RECIPE_WEHATER} = chatGptService() + // state + const [LoginIsExpanded, setLoginIsExpanded] = useState(false) + const [weather, setWeather] = useState() + const [isSignedInGoogle, setIsSignedInGoogle] = useState() + const [getCurrentData,setGetCurrentData] = useState() + + const getIsSignedIn = async () => { + const result = await isSignedIn() + + setIsSignedInGoogle(result) + } + + const getCurrentGoogleUser = async () => { + const data = await getCurrentUser() + + if(data ==null) setGetCurrentData(false) + else {setGetCurrentData(true) + dispatch(setLoginedUser(data))} + + } + const getNowLocation = ()=> { + Geolocation.getCurrentPosition(data => { + const postData= { + lat:data.coords.latitude+"", + lon:data.coords.longitude+"" + } + + POST_WEATHER(postData).then((res)=>{ + console.log('POSTWEATHER',res.weather[0].main) + setWeather(res.weather[0].main) + console.log('------------',res.weather[0].main) + // gpt asked need + dispatch(setUserWeather(weather)) + + + }) + setTimeout(()=>{ + // spinner 추가 필요 + navigation.navigate('Bottom') + },1000) + }) + } + const getRecommendMenu = () =>{ + GET_RECIPE_WEHATER(weather).then((res)=>{ + + dispatch(setWeatherRecommendMenu(res)) + + }) + } + useEffect(() => { + googleSigninConfigure() + getIsSignedIn() + if (isSignedInGoogle) { + getCurrentGoogleUser() + if(getCurrentData){ + getRecommendMenu() + getNowLocation() + } + } + }) + const styles = StyleSheet.create({ container: { flex: 1, }, header: { - + flex: 0.25, alignContent: 'center', justifyContent: 'center', @@ -25,22 +99,22 @@ export function HomeView() { }, buttonSection: { flex: 0.2, - width:"100%", + width: "100%", alignContent: 'center', justifyContent: 'center', - alignItems:"center", - + alignItems: "center", + }, - buttonStyle:{ - width:"75%", - borderWidth:1, - alignItems:"center", - justifyContent:"center", - height:50, - borderRadius:18 + buttonStyle: { + width: "75%", + borderWidth: 1, + alignItems: "center", + justifyContent: "center", + height: 50, + borderRadius: 18 } }) - const onPressLogin = () =>{ + const onPressLogin = () => { navigation.navigate("Bottom") } @@ -50,7 +124,7 @@ export function HomeView() { {/* Image logo section */} @@ -59,22 +133,22 @@ export function HomeView() { source={require("/Users/kjm/Projects/capston/FE/InjeRecipe_FrontEnd/injeRecipe/src/assets/lottie/LottieLogo.json")} style={{ width: "100%", height: "90%", marginTop: -50 }} autoPlay - loop/> - - 화면전환용 로그인 - + loop /> + + 화면전환용 로그인 + {/* button section */} {/* 구글 로그인 로그인 등 컴포넌트화 시키기 */} {/* */} - - - - + + + + ) diff --git a/injeRecipe/src/feature/home/LoginButton.tsx b/injeRecipe/src/feature/home/LoginButton.tsx index b5a7917..7f51383 100644 --- a/injeRecipe/src/feature/home/LoginButton.tsx +++ b/injeRecipe/src/feature/home/LoginButton.tsx @@ -4,6 +4,8 @@ import { useSignIn } from "../../hooks/useSignIn" import { useNavigation } from "@react-navigation/native" import { GoogleSigninButton } from "@react-native-google-signin/google-signin" import { url } from "inspector" +import { useDispatch } from "react-redux" +import { setLoginedUser } from "../../redux/action/actionLogin" type props ={ text:string, @@ -15,15 +17,12 @@ export function LoginButton({text,value}:props){ onPressGoogleSignIn } = useSignIn() const [btBgColor,setBtBgColor] = useState('') - const configureGoogleUser = async() =>{ - const userData = await googleSigninConfigure() - console.log('hi user',userData) - } + const [isLoginedGoogle,setIsLoginedGoogle] = useState(false) + const dispatch = useDispatch() const navigation = useNavigation() + useEffect(()=>{ if(text == "구글 계정을 통한 로그인"){ - console.log('configure') - configureGoogleUser setBtBgColor('white') } else{ @@ -37,8 +36,13 @@ export function LoginButton({text,value}:props){ else if(value =="google"){ const getUserData = async() => { const res = await onPressGoogleSignIn() - console.log(res,'res') // res 요 녀석을 전역 스테이트로 관리하면 오케이 + if(res!=undefined){ + dispatch(setLoginedUser(res)) + navigation.navigate('Bottom') + } + + } getUserData() } diff --git a/injeRecipe/src/feature/info/InfoHeader.tsx b/injeRecipe/src/feature/info/InfoHeader.tsx new file mode 100644 index 0000000..5b5e9dd --- /dev/null +++ b/injeRecipe/src/feature/info/InfoHeader.tsx @@ -0,0 +1,26 @@ +import React from "react" +import { Text, View } from "react-native" +import Icon from "react-native-vector-icons/Ionicons" +import { Colors } from "../../color/Colors" + +export const InfoHeader =()=>{ + + return( + + + 더보기 + + + + + + + ) +} \ No newline at end of file diff --git a/injeRecipe/src/feature/info/InfoView.tsx b/injeRecipe/src/feature/info/InfoView.tsx index cf7da28..1ba0f8b 100644 --- a/injeRecipe/src/feature/info/InfoView.tsx +++ b/injeRecipe/src/feature/info/InfoView.tsx @@ -1,12 +1,56 @@ -import React from "react"; -import { Text, View } from "react-native"; +import React, { useEffect } from "react"; +import { Image, Pressable, SafeAreaView, ScrollView, Text, View } from "react-native"; +import { InfoHeader } from "./InfoHeader"; +import { useSelector } from "react-redux"; +import { RootReducerState } from "../../redux/store"; +import { url } from "inspector"; +import { useNavigation } from "@react-navigation/core"; export function InfoView(){ + const userData = useSelector((state:RootReducerState)=> state.login.loginUser) + const navigation = useNavigation(); + useEffect(()=>{ + console.log('infoUserData',userData) + }) return( - - - InfoView - - + + + {/* header */} + + + + {/* header */} + + {/* image */} + + + + {/* recipe text */} + {userData.user.name} + 나의 레시피 0 + + + {/* + */} + + + {/* flatlist로 대체 피드 형식으로? */} + {navigation.navigate("Home")}}> + 로그아웃 + + + ) } \ No newline at end of file diff --git a/injeRecipe/src/feature/main/KeyWordRcommendView.tsx b/injeRecipe/src/feature/main/KeyWordRcommendView.tsx new file mode 100644 index 0000000..a5f389d --- /dev/null +++ b/injeRecipe/src/feature/main/KeyWordRcommendView.tsx @@ -0,0 +1,116 @@ +import React, { useState } from "react" +import { FlatList, Text, TouchableOpacity, View } from "react-native" +import SwiperFlatList from "react-native-swiper-flatlist" +import { useDimention } from "../../hooks/useDimension" +import { Colors } from "../../color/Colors" +import Icon from "react-native-vector-icons/Ionicons"; +import { useRecommend } from "../../hooks/useRecommend" +import { RecipeRenderItem } from "./RecipeRenderItem" + +export const KeyWordRecommendView = () => { + const { + sampleData, + keyWord + } = useRecommend() + const [recepeItem, setRecepeItem] = useState(sampleData) + + + const [isClicked, setIsClicked] = useState(0) + const onPressKeyWord = (index:any) => { + setIsClicked(index) + } + const RenderItem = ({ item, index }: any) => { + + return ( + {onPressKeyWord(index)}}> + + {item.title} + + + ) + } + + return ( + + + {/* keyword select view */} + 키워드 + 를 적용해 + + 레시피를 확인해보세요. + + + + {/* keyword select view */} + + { + return () + }} + keyExtractor={(item) => `${item.key}`} + /> + + + item.id} + renderItem={({ item, index }) => { + return() + }} /> + + + + {/* refresh view */} + + + 새로운 레시피 가져오기 + + + + + + ) +} \ No newline at end of file diff --git a/injeRecipe/src/feature/main/MainHeaderAnim.tsx b/injeRecipe/src/feature/main/MainHeaderAnim.tsx new file mode 100644 index 0000000..cde23d8 --- /dev/null +++ b/injeRecipe/src/feature/main/MainHeaderAnim.tsx @@ -0,0 +1,24 @@ +import React, { useEffect, useMemo, useRef, useState } from "react" +import { Animated, PanResponder, Text, View } from "react-native" +import { useWeather } from "../../hooks/useWeather" +import { useDimention } from "../../hooks/useDimension" +import { useSelector } from "react-redux" +import { RootReducerState } from "../../redux/store" + +export const MainHeaderAnim = () => { + + const panResponder = PanResponder.create({ + onMoveShouldSetPanResponder:()=>true, + onPanResponderMove:(evt,gestureState) => { + // console.log(gestureState) + }, + }) + + + + + return ( + null + + ) +} \ No newline at end of file diff --git a/injeRecipe/src/feature/main/MainView.tsx b/injeRecipe/src/feature/main/MainView.tsx index 47f3d46..4e404d0 100644 --- a/injeRecipe/src/feature/main/MainView.tsx +++ b/injeRecipe/src/feature/main/MainView.tsx @@ -1,42 +1,171 @@ -import React from "react"; -import { Image, SafeAreaView, ScrollView, Text, View } from "react-native"; +import React, { useEffect, useRef, useState } from "react"; +import { Animated, Image, PanResponder, SafeAreaView, ScrollView, Text, View } from "react-native"; import { WeatherCard } from "./weather/WeatherCard"; import { Header } from "../../component/Header"; import { Margin } from "../../component/Margin"; import { Colors } from "../../color/Colors"; import { useDimention } from "../../hooks/useDimension"; +import { MainHeaderAnim } from "./MainHeaderAnim"; +import { useSelector } from "react-redux"; +import { RootReducerState } from "../../redux/store"; +import { useWeather } from "../../hooks/useWeather"; +import LottieView from "lottie-react-native"; +import { WeatherRecommendView } from "./WeatherRecommendView"; +import { KeyWordRecommendView } from "./KeyWordRcommendView"; -export function MainView(){ - const {getHeight } = useDimention() +export function MainView() { + + const { getHeight } = useDimention() const height = getHeight() - - return( - - - {/* Header */} -
+ const { getWeatherState } = useWeather() + const [bgColor, setBgColor] = useState('') + const [imageUri, setImageUri] = useState('') + const [aiMessage, setAiMessage] = useState('') + + const weather = useSelector((state: RootReducerState) => state.login.userWeather) + + + useEffect(() => { + console.log(weather) + const data = getWeatherState(weather) + setBgColor(data?.BgColor) + setAiMessage(data?.AiMessage) + setImageUri(data?.ImageUri) + + }, []) + const ViewOriginal = () => { + return ( + <> + + {/* Header */} +
+ + + + {/* recomend Ai Recipe */} + + 추천 레시피 + + + + + + + {/* popular recipe */} + + 인기 레시피 + + + + + + + ) + } + const fadeTitleAnim = useRef(new Animated.Value(0)).current; + const fadeAnim = useRef(new Animated.Value(1)).current; + const handleScroll = (event:any) => { + const scrollY = event.nativeEvent.contentOffset.y; + // 최대 스크롤 가능한 높이 (예: 500) + const maxScrollHeight = 500; + // 투명도 계산 + const opacity = 1 - (scrollY / maxScrollHeight); + const titleOpacity =(scrollY / maxScrollHeight) + // Animated API를 사용하여 투명도 업데이트 + const anims = [ + Animated.timing( + fadeAnim, + { + toValue: opacity, + duration: 0, // 애니메이션 지속 시간 (0으로 설정하여 즉시 업데이트) + useNativeDriver: false, // 네이티브 드라이버 사용 여부 + }), + Animated.timing( + fadeTitleAnim, + { + toValue: titleOpacity, + duration: 0, // 애니메이션 지속 시간 (0으로 설정하여 즉시 업데이트) + useNativeDriver: false, // 네이티브 드라이버 사용 여부 + })] + Animated.parallel(anims).start(); + }; + + return ( + + - - - {/* recomend Ai Recipe */} - - 추천 레시피 + + + - - + + - - - {/* popular recipe */} - - 인기 레시피 + 인제 레시피 + + + + + + + + + + + + + {aiMessage} + + + + + - - + + - - - + + + ) } \ No newline at end of file diff --git a/injeRecipe/src/feature/main/RecipeRenderItem.tsx b/injeRecipe/src/feature/main/RecipeRenderItem.tsx new file mode 100644 index 0000000..31a42b5 --- /dev/null +++ b/injeRecipe/src/feature/main/RecipeRenderItem.tsx @@ -0,0 +1,51 @@ +import React from "react" +import { Image, Text, View } from "react-native" +import { useDimention } from "../../hooks/useDimension" +import { Colors } from "../../color/Colors" + +export const RecipeRenderItem=({item,index}:any) =>{ + const { getHeight, getWeight } = useDimention() + const ItemView = ({num}:any) => { + console.log('item',item.item[num]) + return( + + + + + + + 작성자 이름 + + + {item.item[num].title} + + + + + ) + } + return ( + + + + + + ) +} \ No newline at end of file diff --git a/injeRecipe/src/feature/main/WeatherRecommendView.tsx b/injeRecipe/src/feature/main/WeatherRecommendView.tsx new file mode 100644 index 0000000..4b37eec --- /dev/null +++ b/injeRecipe/src/feature/main/WeatherRecommendView.tsx @@ -0,0 +1,72 @@ +import React, { useEffect, useState } from "react"; +import { FlatList, Text, View } from "react-native"; +import BitSwiper from 'react-native-bit-swiper'; +import PropTypes from 'prop-types'; +import { SwiperFlatList } from 'react-native-swiper-flatlist' +import { useSelector } from "react-redux"; +import { RootReducerState } from "../../redux/store"; +import { useDimention } from "../../hooks/useDimension"; +import { useRecommend } from "../../hooks/useRecommend"; +import Icon from "react-native-vector-icons/Ionicons"; +import { Colors } from "../../color/Colors"; +import { RecipeRenderItem } from "./RecipeRenderItem"; +export const WeatherRecommendView = () => { + const data: any = useSelector((state) => state.login.recommendMenu) + const { sampleData } = useRecommend() + const { getHeight, getWeight } = useDimention() + // const [keyWord,setKeyword] = useState|any>(data.menu) 서버 끊겨있어서 임시 데이터 + const [keyWord, setKeyword] = useState | any>(sampleData) + + return ( + + + {/* keyword select view */} + 흐린 날씨 + 에는 + + 다음과 같은 레시피를 사용해보세요. + + + item.id} + renderItem={({ item, index }) => { + console.log('myitem', item) + return ( + + ) + }} /> + + + {/* refresh view */} + + + 새로운 레시피 가져오기 + + + + + + ); +}; + + +export default WeatherRecommendView; diff --git a/injeRecipe/src/feature/main/weather/WeatherCard.tsx b/injeRecipe/src/feature/main/weather/WeatherCard.tsx index 512da8d..acda506 100644 --- a/injeRecipe/src/feature/main/weather/WeatherCard.tsx +++ b/injeRecipe/src/feature/main/weather/WeatherCard.tsx @@ -9,7 +9,7 @@ import { chatGptService } from "../../../services/chatGptService"; const hegiht = Dimensions.get('window').height export function WeatherCard({ height }: any) { const {POST_WEATHER} = weatherService() - const {GET_RECIPE} =chatGptService() + const {GET_RECIPE_WEHATER} =chatGptService() const [location,setLocation] = useState() const [weather, setWeather] = useState() @@ -33,8 +33,8 @@ export function WeatherCard({ height }: any) { console.log(typeof postData.lat) console.log(typeof postData.lon) POST_WEATHER(postData).then((res)=>{ - console.log('POSTWEATHER',res.weather[0].main) - setWeather(res.weather[0].main) + console.log('POSTWEATHER',res.weather.main) + setWeather(res.weather.main) }) } },[location]) @@ -42,7 +42,10 @@ export function WeatherCard({ height }: any) { useMemo(()=>{ console.log(weather) },[weather]) - + + + + return ( - - +import BitSwiper from 'react-native-bit-swiper'; +import { Colors } from "../../color/Colors"; +export function AiRecommendView() { + const data = ['', '', '', ''] + return ( + + + { }} /> - - + + {/* item view */} - + + ( + + + + + + + + + 재료 정보 + + + + )} + /> + + - + {/* button view */} - + + 레시피 확인하기 + - ) diff --git a/injeRecipe/src/feature/refrigator/RefrigatorHeader.tsx b/injeRecipe/src/feature/refrigator/RefrigatorHeader.tsx index d8f3c0d..bab81b7 100644 --- a/injeRecipe/src/feature/refrigator/RefrigatorHeader.tsx +++ b/injeRecipe/src/feature/refrigator/RefrigatorHeader.tsx @@ -10,6 +10,7 @@ type props = { type componentProps = { left:boolean, right:boolean, + title:string, handlePresentModalPress:any } const HeaderIcon = ({id,func}:props) => { @@ -32,6 +33,7 @@ const HeaderIcon = ({id,func}:props) => { export function RefrigatorHeader({ left, right, + title, handlePresentModalPress }:componentProps) { const navigation = useNavigation() @@ -60,7 +62,7 @@ export function RefrigatorHeader({ color: Colors.FONT_WHITE, fontSize: 18, fontWeight: 'bold' - }}>나의 냉장고 + }}>{title} {/* */} diff --git a/injeRecipe/src/feature/refrigator/RefrigatorView.tsx b/injeRecipe/src/feature/refrigator/RefrigatorView.tsx index a333ff4..27cfc0f 100644 --- a/injeRecipe/src/feature/refrigator/RefrigatorView.tsx +++ b/injeRecipe/src/feature/refrigator/RefrigatorView.tsx @@ -38,9 +38,10 @@ export function RefrigatorView(){ + title="나의 냉장고" + left={false} + right={true} + handlePresentModalPress={handlePresentModalPress}/> diff --git a/injeRecipe/src/hooks/useDimension.ts b/injeRecipe/src/hooks/useDimension.ts index 89f40fe..d0d6953 100644 --- a/injeRecipe/src/hooks/useDimension.ts +++ b/injeRecipe/src/hooks/useDimension.ts @@ -4,7 +4,11 @@ export const useDimention = () =>{ const getHeight = () =>{ return Dimensions.get("screen").height } + const getWeight = () => { + return Dimensions.get("screen").width + } return{ - getHeight + getHeight, + getWeight } } \ No newline at end of file diff --git a/injeRecipe/src/hooks/useRecommend.ts b/injeRecipe/src/hooks/useRecommend.ts new file mode 100644 index 0000000..338dfe4 --- /dev/null +++ b/injeRecipe/src/hooks/useRecommend.ts @@ -0,0 +1,60 @@ +export const useRecommend=()=>{ + const sampleData = [ + {id:1, + item:[ + { + index:1, + title:'제육' + }, + { + index:2, + title:'피자' + }, + ]}, + {id:2, + item:[ + { + index:1, + title:'치킨' + }, + { + index:2, + title:'햄버거' + }, + ] + }, + {id:3, + item:[ + { + index:1, + title:'라면' + }, + { + index:2, + title:'우동' + }, + ]}, + {id:4, + item:[ + { + index:1, + title:'치즈' + }, + { + index:2, + title:'육개장' + }, + ]}, + ] + + const keyWord = [ + {key:1,title:'한식'}, + {key:2,title:'일식'}, + {key:3,title:'중식'}, + {key:4,title:'양식'}, + ] + return{ + keyWord, + sampleData + } +} \ No newline at end of file diff --git a/injeRecipe/src/hooks/useSignIn.ts b/injeRecipe/src/hooks/useSignIn.ts index c3238fa..2308695 100644 --- a/injeRecipe/src/hooks/useSignIn.ts +++ b/injeRecipe/src/hooks/useSignIn.ts @@ -1,55 +1,76 @@ +import AsyncStorage from '@react-native-async-storage/async-storage'; import { - GoogleSignin, - statusCodes, - } from '@react-native-google-signin/google-signin' -export const useSignIn =()=>{ - const googleSigninConfigure = () => { - GoogleSignin.configure({ - webClientId:'1061735857952-hfskjefce69p4msarih2vr714kto3res.apps.googleusercontent.com', - iosClientId:'1061735857952-hfskjefce69p4msarih2vr714kto3res.apps.googleusercontent.com', //파이어베이스 서버 이용을 안할경우 필요한듯 - - }); + GoogleSignin, + statusCodes, +} from '@react-native-google-signin/google-signin' +export const useSignIn = () => { + const googleSigninConfigure = () => { + GoogleSignin.configure({ + webClientId: '1061735857952-hfskjefce69p4msarih2vr714kto3res.apps.googleusercontent.com', + iosClientId: '1061735857952-hfskjefce69p4msarih2vr714kto3res.apps.googleusercontent.com', //파이어베이스 서버 이용을 안할경우 필요한듯 + + }); + } + const _signIn = async () => { + + try { + await GoogleSignin.hasPlayServices() + + const res = await GoogleSignin.signIn() + const jsonValue = JSON.stringify(res); + await AsyncStorage.setItem('Google_user', jsonValue); + + + return res + //setState({ userInfo, error: undefined }); + } catch (error: any) { + + if (error.code === statusCodes.SIGN_IN_CANCELLED) { + console.log('Errrr1') + // user cancelled the login flow + } else if (error.code === statusCodes.IN_PROGRESS) { + console.log('Errrr2') + // operation (e.g. sign in) is in progress already + } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) { + console.log('Errrr3') + // play services not available or outdated + } else { + console.log('Errrr4') + // some other error happened + } } - const _signIn = async () => { - - try { - await GoogleSignin.hasPlayServices() - - const res =await GoogleSignin.signIn() - console.log('res',res) - return res - //setState({ userInfo, error: undefined }); - } catch (error:any) { - - if (error.code === statusCodes.SIGN_IN_CANCELLED) { - console.log('Errrr1') - // user cancelled the login flow - } else if (error.code === statusCodes.IN_PROGRESS) { - console.log('Errrr2') - // operation (e.g. sign in) is in progress already - } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) { - console.log('Errrr3') - // play services not available or outdated - } else { - console.log('Errrr4') - // some other error happened - } - } - }; - const onPressGoogleSignIn = async() =>{ - try{ - const signInResult =await _signIn() + }; + + const onPressGoogleSignIn = async () => { + try { + const signInResult = await _signIn() return signInResult - } - catch(error){ - - } - - - } - return{ - googleSigninConfigure, - onPressGoogleSignIn + catch (error) { + + } + } + + const isSignedIn = async () => { + const isSignedIn = await GoogleSignin.isSignedIn(); + return isSignedIn + + }; + const getCurrentUser = async () => { + const currentUser = await GoogleSignin.getCurrentUser(); + if (currentUser == null) { + const jsonValue = await AsyncStorage.getItem('Google_user'); + return jsonValue != null ? JSON.parse(jsonValue) : null; + } + else { + return currentUser } + + }; + return { + googleSigninConfigure, + onPressGoogleSignIn, + isSignedIn, + getCurrentUser + } } \ No newline at end of file diff --git a/injeRecipe/src/hooks/useWeather.ts b/injeRecipe/src/hooks/useWeather.ts new file mode 100644 index 0000000..76c94c5 --- /dev/null +++ b/injeRecipe/src/hooks/useWeather.ts @@ -0,0 +1,57 @@ +export const useWeather = () =>{ + const weatherMessage = { + snow:'눈이 오는데 \n 다음과 같은 \nn레시피는 어떤가요?', + cloud:'날도 흐린데 \n다음과 같은 \n레시피는 어떤가요?', + rain:'비도 오는데 \n다음과 같은 \n레시피는 어떤가요?', + clear:'날씨가 맑은데 \n다음과 같은 \n레시피는 어떤가요?.' + } + const weahterBackground ={ + snow:'/Users/kjm/Projects/capston/FE/InjeRecipe_FrontEnd/injeRecipe/src/assets/lottie/weather/weatherSnow.json', + cloud:'/Users/kjm/Projects/capston/FE/InjeRecipe_FrontEnd/injeRecipe/src/assets/lottie/weather/cloudy.json', + rain:'/Users/kjm/Projects/capston/FE/InjeRecipe_FrontEnd/injeRecipe/src/assets/lottie/weather/weatherRain.json', + clear:'/Users/kjm/Projects/capston/FE/InjeRecipe_FrontEnd/injeRecipe/src/assets/lottie/weather/weatherClear.json' + } + const weatherdBackColor = { + snow:'#363947', + cloud:'#E9E9E9', + rain:'#2b5876', + clear:'"#363947' + } + const getWeatherState = (weather:string) =>{ + if(weather=="Clouds"){ + return{ + AiMessage:weatherMessage.cloud, + BgColor:weatherdBackColor.cloud, + ImageUri:weahterBackground.cloud + } + + } + else if(weather=='clear'){ + return{ + AiMessage:weatherMessage.clear, + BgColor:weatherdBackColor.clear, + ImageUri:weahterBackground.clear + } + } + else if(weather=='rain'){ + return{ + AiMessage:weatherMessage.rain, + BgColor:weatherdBackColor.rain, + ImageUri:weahterBackground.rain + } + } + else if(weather=='snow'){ + return{ + AiMessage:weatherMessage.snow, + BgColor:weatherdBackColor.snow, + ImageUri:weahterBackground.snow + } + } + + + } + + return{ + getWeatherState, + } +} \ No newline at end of file diff --git a/injeRecipe/src/redux/action/actionLogin.ts b/injeRecipe/src/redux/action/actionLogin.ts index 980e0c6..7b01ded 100644 --- a/injeRecipe/src/redux/action/actionLogin.ts +++ b/injeRecipe/src/redux/action/actionLogin.ts @@ -1,9 +1,29 @@ export const SET_LOGINED_USER = "SET_LOGINED_USER" +export const SET_USER_WEATHER = "SET_USER_WEATHER" +export const SET_WEATHER_RECOMMEND_MENU = "SET_WEATHER_RECOMMEND_MENU" export const setLoginedUser = (data:any) =>{ + console.log(data) return{ type:SET_LOGINED_USER, data:data } +} + + +export const setUserWeather= (data:any) =>{ + console.log(data) + return{ + type:SET_USER_WEATHER, + data:data + } + +} + +export const setWeatherRecommendMenu = (data:any) => { + return{ + type:SET_WEATHER_RECOMMEND_MENU, + data:data + } } \ No newline at end of file diff --git a/injeRecipe/src/redux/reducer/loginReducer.ts b/injeRecipe/src/redux/reducer/loginReducer.ts index a4ea542..6583e62 100644 --- a/injeRecipe/src/redux/reducer/loginReducer.ts +++ b/injeRecipe/src/redux/reducer/loginReducer.ts @@ -1,14 +1,40 @@ -import { SET_LOGINED_USER } from "../action/actionLogin" -const data ={ +import { SET_LOGINED_USER, SET_USER_WEATHER, SET_WEATHER_RECOMMEND_MENU } from "../action/actionLogin" +const data ={ + loginUser:null, + userWeather:null, + recommendMenu:null } export const loginReducer = (state = data,action:any) =>{ + switch(action.type){ case SET_LOGINED_USER:{ - return state + console.log('state',action.data) + + return { + + + ...state, + loginUser:action.data + + } + } + case SET_USER_WEATHER:{ + return{ + + ...state, + userWeather:action.data + + + } + } + case SET_WEATHER_RECOMMEND_MENU:{ + return{ + ...state, + recommendMenu:action.data + } } - return null } - return null + return {...state} } \ No newline at end of file diff --git a/injeRecipe/src/redux/store.ts b/injeRecipe/src/redux/store.ts index 44ed30f..da4e31c 100644 --- a/injeRecipe/src/redux/store.ts +++ b/injeRecipe/src/redux/store.ts @@ -1,11 +1,11 @@ import { applyMiddleware, combineReducers, createStore } from 'redux' - +import logger from 'redux-logger' import { loginReducer } from './reducer/loginReducer' const rootReducer = combineReducers({ login:loginReducer }) -const store = createStore(rootReducer) +const store = createStore(rootReducer,applyMiddleware(logger)) export type RootReducerState = ReturnType export default store \ No newline at end of file diff --git a/injeRecipe/src/services/chatGptService.ts b/injeRecipe/src/services/chatGptService.ts index 290a7a8..92a8e7e 100644 --- a/injeRecipe/src/services/chatGptService.ts +++ b/injeRecipe/src/services/chatGptService.ts @@ -2,29 +2,36 @@ import axios from 'axios' export const chatGptService =() =>{ const path = 'http://localhost:8080' - const GET_RECIPE = async (data:object) =>{ - const message = {prompt:'너를 소개해봐'} + const GET_RECIPE_WEHATER = async (data:any) =>{ + const message = {prompt:''} + if(data == 'Clouds'){ + message.prompt = '날씨가 흐린데 메뉴를 추천해줘 답은 5개정도를 json객체 데이터 형식으로 단어로만 말해줘' + } + else if(data == 'snow'){ + message.prompt = '눈 오는데 메뉴를 추천해줘 답은 5개정도 단어로만 말해줘' + } + else if(data == 'rain'){ + message.prompt = '비 오는데 메뉴를 추천해줘 답은 5개정도 단어로만 말해줘' + } + else if(data == 'clear'){ + message.prompt = '맑은 날씨에 어울리는 메뉴를 추천해줘 답은 5개정도 단어로만 말해줘' + } + + const server = `${path}/openai/chat` try{ - - await axios.get(server,{ + console.log(message) + const res =await axios.get(server,{ params:message - }).then((res)=>{ - - console.log('GET_Message_RESPON',res.data,{ - headers: { - 'Content-Type': 'application/json' - } - }) - } - ) + }) + return res.data } catch(error){ console.log(error) } } return{ - GET_RECIPE + GET_RECIPE_WEHATER } } \ No newline at end of file diff --git a/injeRecipe/yarn.lock b/injeRecipe/yarn.lock index 4b747b5..e9a94b6 100644 --- a/injeRecipe/yarn.lock +++ b/injeRecipe/yarn.lock @@ -1724,6 +1724,13 @@ resolved "https://registry.npmjs.org/@preact/signals-core/-/signals-core-1.5.1.tgz" integrity sha512-dE6f+WCX5ZUDwXzUIWNMhhglmuLpqJhuy3X3xHrhZYI0Hm2LyQwOu0l9mdPiWrVNsE+Q7txOnJPgtIqHCYoBVA== +"@react-native-async-storage/async-storage@^1.22.0": + version "1.22.0" + resolved "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.22.0.tgz" + integrity sha512-b5KD010iiZnot86RbAaHpLuHwmPW2qA3SSN/OSZhd1kBoINEQEVBuv+uFtcaTxAhX27bT0wd13GOb2IOSDUXSA== + dependencies: + merge-options "^3.0.4" + "@react-native-community/cli-clean@12.3.0": version "12.3.0" resolved "https://registry.npmjs.org/@react-native-community/cli-clean/-/cli-clean-12.3.0.tgz" @@ -5629,6 +5636,11 @@ is-path-inside@^3.0.3: resolved "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz" integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + is-plain-obj@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz" @@ -6553,6 +6565,13 @@ merge-descriptors@1.0.1: resolved "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz" integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w== +merge-options@^3.0.4: + version "3.0.4" + resolved "https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz" + integrity sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ== + dependencies: + is-plain-obj "^2.1.0" + merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz" @@ -7480,7 +7499,7 @@ prompts@^2.0.1, prompts@^2.4.2: kleur "^3.0.3" sisteransi "^1.0.5" -prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1: +prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1: version "15.8.1" resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz" integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== @@ -7621,6 +7640,13 @@ react-native-animatable@1.3.3: dependencies: prop-types "^15.7.2" +react-native-bit-swiper@^1.1.8: + version "1.1.8" + resolved "https://registry.npmjs.org/react-native-bit-swiper/-/react-native-bit-swiper-1.1.8.tgz" + integrity sha512-UcG3NKlClg95qIL5xLe2fHkBaUWcqoGv62895vUosIejAK4vV9Ti8WcWFitTOw42/3CMpcjJhjW3gBC7csmE5w== + dependencies: + prop-types "^15.6.1" + react-native-gesture-handler@^2.15.0, react-native-gesture-handler@>=1.10.1: version "2.15.0" resolved "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.15.0.tgz" @@ -7668,6 +7694,11 @@ react-native-screens@^3.29.0, "react-native-screens@>= 3.0.0": react-freeze "^1.0.0" warn-once "^0.1.0" +react-native-swiper-flatlist@^3.2.3: + version "3.2.3" + resolved "https://registry.npmjs.org/react-native-swiper-flatlist/-/react-native-swiper-flatlist-3.2.3.tgz" + integrity sha512-L4KSy4X1mzUx9a/gZa+lBpY7agS/GHCSzSjHjpIDQB7qh03jKm4PsKyYE5KfFzJRzBMm/srfrixfWzHncZmhkQ== + react-native-vector-icons@^10.0.3: version "10.0.3" resolved "https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-10.0.3.tgz" @@ -7690,7 +7721,7 @@ react-native-web@^0.19.10: postcss-value-parser "^4.2.0" styleq "^0.1.3" -react-native@*, react-native@>=0.46, react-native@>=0.65.0, react-native@>=0.69, react-native@0.73.2: +react-native@*, "react-native@^0.0.0-0 || >=0.60 <1.0", react-native@>=0.46, react-native@>=0.59.0, react-native@>=0.65.0, react-native@>=0.69, react-native@0.73.2: version "0.73.2" resolved "https://registry.npmjs.org/react-native/-/react-native-0.73.2.tgz" integrity sha512-7zj9tcUYpJUBdOdXY6cM8RcXYWkyql4kMyGZflW99E5EuFPoC7Ti+ZQSl7LP9ZPzGD0vMfslwyDW0I4tPWUCFw==