ryuyoonju
07-30
240730 류윤주 1차 완성 코드 커밋
@86773933286f3654076367bb8b7a033cf64ce02d
--- android/app/src/main/AndroidManifest.xml
+++ android/app/src/main/AndroidManifest.xml
... | ... | @@ -9,6 +9,7 @@ |
9 | 9 |
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> |
10 | 10 |
<uses-permission android:name="android.permission.WAKE_LOCK" /> |
11 | 11 |
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> |
12 |
+ |
|
12 | 13 |
|
13 | 14 |
<application |
14 | 15 |
android:name=".MainApplication" |
--- android/app/src/main/assets/index.android.bundle
+++ android/app/src/main/assets/index.android.bundle
This diff is too big to display. |
--- package-lock.json
+++ package-lock.json
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 |
"@react-native-async-storage/async-storage": "^1.23.1", |
12 | 12 |
"@react-navigation/native": "^6.1.17", |
13 | 13 |
"@react-navigation/stack": "^6.4.1", |
14 |
+ "@sayem314/react-native-keep-awake": "^1.2.4", |
|
14 | 15 |
"axios": "^1.7.2", |
15 | 16 |
"base64-js": "^1.5.1", |
16 | 17 |
"crypto-js": "^4.2.0", |
... | ... | @@ -5880,6 +5881,15 @@ |
5880 | 5881 |
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", |
5881 | 5882 |
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" |
5882 | 5883 |
}, |
5884 |
+ "node_modules/@sayem314/react-native-keep-awake": { |
|
5885 |
+ "version": "1.2.4", |
|
5886 |
+ "resolved": "https://registry.npmjs.org/@sayem314/react-native-keep-awake/-/react-native-keep-awake-1.2.4.tgz", |
|
5887 |
+ "integrity": "sha512-I9tRpZ8z693lce4seDbRK0zBzeCkubBnSGmABiRPTRy2ZkMJB1m+vaXiDHl6U3fJa29i2TTaKclH3A8to/Bs9A==", |
|
5888 |
+ "funding": { |
|
5889 |
+ "type": "individual", |
|
5890 |
+ "url": "https://github.com/sponsors/sayem314" |
|
5891 |
+ } |
|
5892 |
+ }, |
|
5883 | 5893 |
"node_modules/@sideway/address": { |
5884 | 5894 |
"version": "4.1.5", |
5885 | 5895 |
"resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.5.tgz", |
--- package.json
+++ package.json
... | ... | @@ -13,6 +13,7 @@ |
13 | 13 |
"@react-native-async-storage/async-storage": "^1.23.1", |
14 | 14 |
"@react-navigation/native": "^6.1.17", |
15 | 15 |
"@react-navigation/stack": "^6.4.1", |
16 |
+ "@sayem314/react-native-keep-awake": "^1.2.4", |
|
16 | 17 |
"axios": "^1.7.2", |
17 | 18 |
"base64-js": "^1.5.1", |
18 | 19 |
"crypto-js": "^4.2.0", |
--- src/screen/GpsScreen.js
+++ src/screen/GpsScreen.js
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 |
import { useNavigation } from '@react-navigation/native'; |
7 | 7 |
import Icon from 'react-native-vector-icons/FontAwesome'; |
8 | 8 |
import Geolocation from 'react-native-geolocation-service'; |
9 |
+import { useKeepAwake } from '@sayem314/react-native-keep-awake'; |
|
9 | 10 |
|
10 | 11 |
const GpsScreen = () => { |
11 | 12 |
const [isMeasuring, setIsMeasuring] = useState(false); |
... | ... | @@ -19,7 +20,9 @@ |
19 | 20 |
}); // 위치 데이터 상태 수정 |
20 | 21 |
const [watchId, setWatchId] = useState(null); |
21 | 22 |
const navigation = useNavigation(); |
22 |
- |
|
23 |
+ //화면꺼짐방지 |
|
24 |
+ useKeepAwake(); |
|
25 |
+ //타이머 |
|
23 | 26 |
useEffect(() => { |
24 | 27 |
let timer; |
25 | 28 |
|
... | ... | @@ -92,28 +95,35 @@ |
92 | 95 |
const handleStop = async () => { |
93 | 96 |
setIsMeasuring(false); |
94 | 97 |
setElapsedTime(0); |
95 |
- |
|
98 |
+ |
|
99 |
+ // 위치 데이터 초기화 |
|
100 |
+ setLocationData({ |
|
101 |
+ latitude: [], |
|
102 |
+ longitude: [], |
|
103 |
+ timestamp: [] |
|
104 |
+ }); |
|
105 |
+ |
|
96 | 106 |
if (watchId !== null) { |
97 | 107 |
Geolocation.clearWatch(watchId); |
98 | 108 |
setWatchId(null); |
99 | 109 |
} |
100 |
- |
|
110 |
+ |
|
101 | 111 |
try { |
102 | 112 |
const dataToSend = { |
103 | 113 |
user_id: userId, |
104 | 114 |
trip_id: tripId, |
105 | 115 |
trip_log: locationData, |
106 | 116 |
}; |
107 |
- |
|
117 |
+ |
|
108 | 118 |
console.log('Data to send:', dataToSend); |
109 |
- |
|
119 |
+ |
|
110 | 120 |
try { |
111 | 121 |
const response = await Api.sendTripLog(dataToSend, navigation); |
112 | 122 |
console.log("Response:", response); |
113 | 123 |
} catch (error) { |
114 | 124 |
Alert.alert('로그인 실패', error.message); |
115 | 125 |
} |
116 |
- |
|
126 |
+ |
|
117 | 127 |
} catch (error) { |
118 | 128 |
console.error('Error stopping location tracking:', error); |
119 | 129 |
} |
... | ... | @@ -147,7 +157,7 @@ |
147 | 157 |
(error) => { |
148 | 158 |
console.error('위치 감시 중 오류:', error); |
149 | 159 |
}, |
150 |
- { enableHighAccuracy: true, distanceFilter: 0, interval: 1000, fastestInterval: 1000, forceRequestLocation: true } |
|
160 |
+ { enableHighAccuracy: true, distanceFilter: 1, interval: 1000, fastestInterval: 1000, } |
|
151 | 161 |
); |
152 | 162 |
|
153 | 163 |
setWatchId(id); |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?