Skip to content

Commit 6d7a843

Browse files
committed
code quality improvement
1 parent ec3fc12 commit 6d7a843

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Sources/MapViewModule/MapViewModule.swift

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct MapView: UIViewRepresentable {
1414
@Binding private var region: MKCoordinateRegion
1515

1616
private var customMapOverlay: CustomMapOverlay?
17-
@State private var presentCustomMapOverlayHash: CustomMapOverlay? = nil
17+
@State private var presentCustomMapOverlayHash: CustomMapOverlay?
1818

1919
private var mapType: MKMapType
2020

@@ -204,19 +204,19 @@ public struct MapView: UIViewRepresentable {
204204

205205
public func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation) {
206206
if let userCLLocation = userLocation.location {
207-
for i in 0..<self.monitoredRegions.count {
208-
let distance = self.monitoredRegions[i].center.distance(from: userCLLocation)
209-
if self.monitoredRegions[i].isInside && distance > CLLocationDistance(self.monitoredRegions[i].radius) {
207+
for index in 0..<self.monitoredRegions.count {
208+
let distance = self.monitoredRegions[index].center.distance(from: userCLLocation)
209+
if self.monitoredRegions[index].isInside && distance > CLLocationDistance(self.monitoredRegions[index].radius) {
210210
if let onLeaveMonitoredRegion = self.parent.onLeaveMonitoredRegion {
211-
onLeaveMonitoredRegion(self.monitoredRegions[i].id)
211+
onLeaveMonitoredRegion(self.monitoredRegions[index].id)
212212
}
213-
self.monitoredRegions[i].isInside = false
213+
self.monitoredRegions[index].isInside = false
214214
}
215-
if !self.monitoredRegions[i].isInside && distance < CLLocationDistance(self.monitoredRegions[i].radius) {
215+
if !self.monitoredRegions[index].isInside && distance < CLLocationDistance(self.monitoredRegions[index].radius) {
216216
if let onEnterMonitoredRegion = self.parent.onEnterMonitoredRegion {
217-
onEnterMonitoredRegion(self.monitoredRegions[i].id)
217+
onEnterMonitoredRegion(self.monitoredRegions[index].id)
218218
}
219-
self.monitoredRegions[i].isInside = true
219+
self.monitoredRegions[index].isInside = true
220220
}
221221
}
222222
}
@@ -233,7 +233,7 @@ public struct MapView: UIViewRepresentable {
233233

234234
public func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
235235

236-
if let index = self.overlays.firstIndex(where: { o in o.shape.hash == overlay.hash }) {
236+
if let index = self.overlays.firstIndex(where: { overlay_ in overlay_.shape.hash == overlay.hash }) {
237237

238238
let unwrappedOverlay = self.overlays[index]
239239

@@ -397,8 +397,6 @@ public struct MapView: UIViewRepresentable {
397397

398398
// MARK: End of implementation
399399

400-
401-
402400
// MARK: Demonstration
403401

404402
public struct MapViewDemo: View {

0 commit comments

Comments
 (0)