작성
·
168
0
수락 후, 녹색 도착버튼을 누르면 반응이 없습니다.
console.dir(navigation); 앞뒤에 test붙여서 출력해보았는데요,
어떤 object를 확인해봐야 할까요?
녹색버튼 onClick에는 console.log붙여봤는데 반응이 없습니다.
Ing.tsx소스코드는 아래와 같습니다.
import React, {useEffect, useState} from 'react';
import {Dimensions, Text, View} from 'react-native';
import NaverMapView, {Marker, Path} from 'react-native-nmap';
import {useSelector} from 'react-redux';
import {RootState} from '../store/reducer';
import Geolocation from '@react-native-community/geolocation';
import {NativeStackScreenProps} from '@react-navigation/native-stack';
import {LoggedInParamList} from '../../AppInner';
type IngScreenProps = NativeStackScreenProps<LoggedInParamList, 'Delivery'>;
function Ing({navigation}: IngScreenProps) {
console.log('test');
console.dir(navigation);
console.log('test2');
const deliveries = useSelector((state: RootState) => state.order.deliveries);
const [myPosition, setMyPosition] = useState<{
latitude: number;
longitude: number;
} | null>(null);
useEffect(() => {
Geolocation.getCurrentPosition(
info => {
setMyPosition({
latitude: info.coords.latitude,
longitude: info.coords.longitude,
});
},
console.error,
{
enableHighAccuracy: true,
timeout: 20000,
},
);
}, []);
if (!deliveries?.[0]) {
return (
<View style={{alignItems: 'center', justifyContent: 'center', flex: 1}}>
<Text>주문을 먼저 수락해주세요!</Text>
</View>
);
}
if (!myPosition || !myPosition.latitude) {
return (
<View style={{alignItems: 'center', justifyContent: 'center', flex: 1}}>
<Text>내 위치를 로딩 중입니다. 권한을 허용했는지 확인해주세요.</Text>
</View>
);
}
const {start, end} = deliveries?.[0];
return (
<View>
<View
style={{
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
}}>
<NaverMapView
style={{width: '100%', height: '100%'}}
zoomControl={false}
center={{
zoom: 10,
tilt: 50,
latitude: (start.latitude + end.latitude) / 2,
longitude: (start.longitude + end.longitude) / 2,
}}>
{myPosition?.latitude && (
<Marker
coordinate={{
latitude: myPosition.latitude,
longitude: myPosition.longitude,
}}
width={15}
height={15}
anchor={{x: 0.5, y: 0.5}}
caption={{text: '나'}}
image={require('../assets/red-dot.png')}
/>
)}
{myPosition?.latitude && (
<Path
coordinates={[
{
latitude: myPosition.latitude,
longitude: myPosition.longitude,
},
{latitude: start.latitude, longitude: start.longitude},
]}
color="orange"
/>
)}
<Marker
coordinate={{
latitude: start.latitude,
longitude: start.longitude,
}}
width={15}
height={15}
anchor={{x: 0.5, y: 0.5}}
caption={{text: '출발'}}
image={require('../assets/blue-dot.png')}
/>
<Path
coordinates={[
{
latitude: start.latitude,
longitude: start.longitude,
},
{latitude: end.latitude, longitude: end.longitude},
]}
color="orange"
/>
<Marker
coordinate={{latitude: end.latitude, longitude: end.longitude}}
width={15}
height={15}
anchor={{x: 0.5, y: 0.5}}
caption={{text: '도착'}}
image={require('../assets/green-dot.png')}
onClick={() => {
console.log('click했음');
console.log(navigation);
navigation.push('Complete', {orderId: deliveries[0].orderId});
}}
/>
</NaverMapView>
</View>
</View>
);
}
export default Ing;