Skip to content

Commit a40bab1

Browse files
committed
♻️ [refactor] 기본 좌표값을 따로 상수로 만들어 관리할 수 있도록 개선
1 parent 01cfd79 commit a40bab1

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

Fitfty/Projects/Core/Sources/Utilities/LocationManager.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import Common
1313

1414
public final class LocationManager: NSObject {
1515

16+
public enum Constant {
17+
public static let defaultLongitude = 126.977829174031
18+
public static let defaultLatitude = 37.5663174209601
19+
20+
}
21+
1622
public static let shared = LocationManager()
1723
public var currentAuthorizationStatus: CLAuthorizationStatus { manager.authorizationStatus }
1824

@@ -55,8 +61,8 @@ extension LocationManager: CLLocationManagerDelegate {
5561
public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
5662
guard _location.value == nil ||
5763
(
58-
_location.value?.coordinate.longitude == 126.977829174031 &&
59-
_location.value?.coordinate.latitude == 37.5663174209601
64+
_location.value?.coordinate.longitude == Constant.defaultLongitude &&
65+
_location.value?.coordinate.latitude == Constant.defaultLatitude
6066
)
6167
else {
6268
return
@@ -68,7 +74,7 @@ extension LocationManager: CLLocationManagerDelegate {
6874
case .notDetermined, .restricted:
6975
requestWhenInUseAuthorization()
7076
default:
71-
_location.send(CLLocation(latitude: 37.5663174209601, longitude: 126.977829174031))
77+
_location.send(CLLocation(latitude: Constant.defaultLatitude, longitude: Constant.defaultLongitude))
7278
}
7379
}
7480

Fitfty/Projects/Core/Sources/Utilities/UserManager.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ extension DefaultUserManager: UserManager {
7474
}
7575
localStorage.write(key: .currentLocation, value: addressDictionary)
7676
_location.send(
77-
(Double(address.x) ?? 126.977829174031, Double(address.y) ?? 37.5663174209601)
77+
(
78+
Double(address.x) ?? LocationManager.Constant.defaultLongitude,
79+
Double(address.y) ?? LocationManager.Constant.defaultLatitude
80+
)
7881
)
7982
}
8083

@@ -96,8 +99,12 @@ extension DefaultUserManager: UserManager {
9699

97100
public func fetchCurrentLocation() {
98101
if let location = localStorage.read(key: .currentLocation) as? [String: Any] {
99-
let x = Double(location["x"] as? String ?? "126.977829174031") ?? 126.977829174031
100-
let y = Double(location["y"] as? String ?? "37.5663174209601") ?? 37.5663174209601
102+
let x = Double(
103+
location["x"] as? String ?? LocationManager.Constant.defaultLongitude.description
104+
) ?? LocationManager.Constant.defaultLongitude
105+
let y = Double(
106+
location["y"] as? String ?? LocationManager.Constant.defaultLatitude.description
107+
) ?? LocationManager.Constant.defaultLatitude
101108
_location.send((x, y))
102109
} else {
103110
LocationManager.shared.currentLocation()

0 commit comments

Comments
 (0)