11/* eslint-disable react/jsx-props-no-spreading */
22/* eslint-disable global-require */
3- // import React, { useState } from 'react';
4- import React , { useEffect , useState , useContext } from 'react' ;
3+ import React , { useEffect , useState } from 'react' ;
54
6- // import { View, ScrollView } from 'react-native';
75import {
86 Text ,
97 TouchableOpacity ,
@@ -19,13 +17,14 @@ import Icon from 'react-native-vector-icons/FontAwesome';
1917
2018import * as Location from 'expo-location' ;
2119
22- import { AuthContext } from '../../../contexts' ;
20+ import { useDispatch , useSelector } from 'react-redux' ;
21+
22+ import { setLongtitude , setLatitude } from '../../../slice' ;
23+ import { get } from '../../../utils' ;
2324
2425import HomeAnimalEnrollment from './HomeAnimalEnrollment' ;
25- // import HomeHospital from './HomeHospital';
2626import HomeSearch from './HomeSearch' ;
2727import HomeBanner from './HomeBanner' ;
28- // import { HomeContainer, HomeHospitalText, Beta } from './style';
2928
3029import {
3130 NAVER_MAP_API_ID ,
@@ -34,43 +33,11 @@ import {
3433
3534import { HomeContainer } from './style' ;
3635
37- // const DataOfNearbyHospital = [
38- // {
39- // name: '성심 동물 메디컬 센터',
40- // adress: '봉명동 548-11',
41- // phone: '042-719-7566',
42- // key: '1',
43- // },
44- // {
45- // name: '로얄 동물 펫병원',
46- // adress: '봉명동 669',
47- // phone: '042-823-7583',
48- // key: '2',
49- // },
50- // {
51- // name: '대전동물메디컬센터 숲',
52- // adress: '봉명동 664-3단지',
53- // phone: '042-826-7584',
54- // key: '3',
55- // },
56- // {
57- // name: '도안 ECO종합 동물 병원',
58- // adress: '11-13, 봉명서로',
59- // phone: '042-485-7582',
60- // key: '4',
61- // },
62- // {
63- // name: '피니펫 동물병원',
64- // adress: '어은동 105-7',
65- // phone: '042-862-7588',
66- // key: '5',
67- // },
68- // ];
69-
7036export default function HomeScreen ( { navigation } ) {
71- const { location, setLocation, profile } = useContext ( AuthContext ) ;
37+ const dispatch = useDispatch ( ) ;
38+ const location = useSelector ( get ( 'location' ) ) ;
39+ const profile = useSelector ( get ( 'profile' ) ) ;
7240
73- // const [location, setLocation] = useState({ x: 127.1054221, y: 37.3591614 });
7441 const [ errorMsg , setErrorMsg ] = useState ( null ) ;
7542 const [ level , setLevel ] = useState ( 6 ) ;
7643
@@ -84,10 +51,12 @@ export default function HomeScreen({ navigation }) {
8451 const x = JSON . stringify ( locationFrom . coords . longitude ) ;
8552 const y = JSON . stringify ( locationFrom . coords . latitude ) ;
8653 if ( x && y ) {
87- setLocation ( {
54+ dispatch ( setLatitude ( {
8855 x,
56+ } ) ) ;
57+ dispatch ( setLongtitude ( {
8958 y,
90- } ) ;
59+ } ) ) ;
9160 }
9261 setLevel ( 13 ) ;
9362 }
@@ -149,7 +118,7 @@ export default function HomeScreen({ navigation }) {
149118 onPress = { ( ) => handleGetLocation ( ) }
150119 style = { {
151120 zIndex : 1 ,
152- position : 'absolute' ,
121+ // position: 'absolute',
153122 paddingTop : 30 ,
154123 paddingRight : 20 ,
155124 } }
0 commit comments