Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ios/.swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--swiftversion 5.10
--disable conditionalAssignment
--disable redundantType
--disable unusedArguments
--binary-grouping none
--decimal-grouping none
--hex-literal-case lowercase
--indent 2
--no-space-operators
--semicolons never
--trailing-commas never
--rules braces,indent
--wrap-arguments preserve
--wrap-parameters preserve
--wrap-collections preserve
--closing-paren same-line
--xcode-indentation enabled
40 changes: 20 additions & 20 deletions ios/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ extension UIColor {
private static func fromRGBFunction(_ s: String) -> UIColor? {
let nums =
s
.replacingOccurrences(of: "rgba", with: "")
.replacingOccurrences(of: "rgb", with: "")
.replacingOccurrences(of: "(", with: "")
.replacingOccurrences(of: ")", with: "")
.split(separator: ",")
.map { $0.trimmingCharacters(in: .whitespaces) }
.replacingOccurrences(of: "rgba", with: "")
.replacingOccurrences(of: "rgb", with: "")
.replacingOccurrences(of: "(", with: "")
.replacingOccurrences(of: ")", with: "")
.split(separator: ",")
.map { $0.trimmingCharacters(in: .whitespaces) }

guard nums.count == 3 || nums.count == 4,
let r = Double(nums[0]),
let g = Double(nums[1]),
let b = Double(nums[2])
let r = Double(nums[0]),
let g = Double(nums[1]),
let b = Double(nums[2])
else { return nil }
let a = (nums.count == 4) ? (Double(nums[3]) ?? 1.0) : 1.0
return UIColor(
Expand All @@ -65,18 +65,18 @@ extension UIColor {
private static func fromHSLFunction(_ s: String) -> UIColor? {
let parts =
s
.replacingOccurrences(of: "hsla", with: "")
.replacingOccurrences(of: "hsl", with: "")
.replacingOccurrences(of: "(", with: "")
.replacingOccurrences(of: ")", with: "")
.replacingOccurrences(of: "%", with: "")
.split(separator: ",")
.map { $0.trimmingCharacters(in: .whitespaces) }
.replacingOccurrences(of: "hsla", with: "")
.replacingOccurrences(of: "hsl", with: "")
.replacingOccurrences(of: "(", with: "")
.replacingOccurrences(of: ")", with: "")
.replacingOccurrences(of: "%", with: "")
.split(separator: ",")
.map { $0.trimmingCharacters(in: .whitespaces) }

guard parts.count == 3 || parts.count == 4,
let h = Double(parts[0]),
let sPerc = Double(parts[1]),
let lPerc = Double(parts[2])
let h = Double(parts[0]),
let sPerc = Double(parts[1]),
let lPerc = Double(parts[2])
else { return nil }

let a = (parts.count == 4) ? (Double(parts[3]) ?? 1.0) : 1.0
Expand All @@ -87,7 +87,7 @@ extension UIColor {
let x = c * (1 - Swift.abs((h / 60).truncatingRemainder(dividingBy: 2) - 1))
let m = l - c / 2

// swiftlint:disable:next large_tuple
// swiftlint:disable:next large_tuple
let (r1, g1, b1): (Double, Double, Double)
switch h {
case 0..<60: (r1, g1, b1) = (c, x, 0)
Expand Down
54 changes: 27 additions & 27 deletions ios/GoogleMapViewImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
if self.lastSubmittedLocation?.coordinate.latitude
!= loc.coordinate.latitude
|| self.lastSubmittedLocation?.coordinate.longitude
!= loc.coordinate.longitude {
!= loc.coordinate.longitude {
self.onLocationUpdate?(
RNLocation(
RNLatLng(
Expand All @@ -120,36 +120,36 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
private func applyPending() {

if let padding = pendingMapPadding {
mapView.padding = UIEdgeInsets(
top: padding.top,
left: padding.left,
bottom: padding.bottom,
right: padding.right
)
mapView.padding = UIEdgeInsets(
top: padding.top,
left: padding.left,
bottom: padding.bottom,
right: padding.right
)
}

if let style = pendingCustomMapStyle {
mapView.mapStyle = style
mapView.mapStyle = style
}

if let mapType = pendingMapType {
mapView.mapType = mapType
mapView.mapType = mapType
}

if let buildings = pendingBuildingEnabled {
mapView.isBuildingsEnabled = buildings
mapView.isBuildingsEnabled = buildings
}

if let traffic = pendingTrafficEnabled {
mapView.isTrafficEnabled = traffic
mapView.isTrafficEnabled = traffic
}

if let uiStyle = pendingUserInterfaceStyle {
mapView.overrideUserInterfaceStyle = uiStyle
mapView.overrideUserInterfaceStyle = uiStyle
}

if let minZoom = pendingMinZoomLevel, let maxZoom = pendingMaxZoomLevel {
mapView.setMinZoom(Float(minZoom), maxZoom: Float(maxZoom))
mapView.setMinZoom(Float(minZoom), maxZoom: Float(maxZoom))
}

if !pendingMarkers.isEmpty {
Expand Down Expand Up @@ -260,10 +260,10 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
pendingMapPadding = newValue
if let padding = newValue {
mapView.padding = UIEdgeInsets(
top: padding.top,
left: padding.left,
bottom: padding.bottom,
right: padding.right
top: padding.top,
left: padding.left,
bottom: padding.bottom,
right: padding.right
)
} else {
mapView.padding = .zero
Expand Down Expand Up @@ -494,7 +494,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
super.didMoveToWindow()
if window != nil {
if mapView != nil && mapReady {
onMapReady?(true)
onMapReady?(true)
}
locationHandler.start()
} else {
Expand Down Expand Up @@ -541,11 +541,11 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {

func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
if let last = lastSubmittedCameraPosition,
last.target.latitude == position.target.latitude,
last.target.longitude == position.target.longitude,
last.zoom == position.zoom,
last.bearing == position.bearing,
last.viewingAngle == position.viewingAngle {
last.target.latitude == position.target.latitude,
last.target.longitude == position.target.longitude,
last.zoom == position.zoom,
last.bearing == position.bearing,
last.viewingAngle == position.viewingAngle {
return
}
let visibleRegion = mapView.projection.visibleRegion()
Expand Down Expand Up @@ -613,10 +613,10 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
didTapAt coordinate: CLLocationCoordinate2D
) {
onMapPress?(
RNLatLng(
latitude: coordinate.latitude,
longitude: coordinate.longitude
))
RNLatLng(
latitude: coordinate.latitude,
longitude: coordinate.longitude
))
}

func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
Expand Down
8 changes: 4 additions & 4 deletions ios/MapPolygon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ extension RNPolygon {

func polygonEquals(_ b: RNPolygon) -> Bool {
guard zIndex == b.zIndex,
strokeWidth == b.strokeWidth,
fillColor == b.fillColor,
strokeColor == b.strokeColor,
coordinates.count == b.coordinates.count
strokeWidth == b.strokeWidth,
fillColor == b.fillColor,
strokeColor == b.strokeColor,
coordinates.count == b.coordinates.count
else { return false }
for i in 0..<coordinates.count {
if coordinates[i].latitude != b.coordinates[i].latitude
Expand Down
10 changes: 5 additions & 5 deletions ios/MapPolyline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ extension RNPolyline {

func polylineEquals(_ b: RNPolyline) -> Bool {
guard zIndex == b.zIndex,
(width ?? 0) == (b.width ?? 0),
lineCap == b.lineCap,
lineJoin == b.lineJoin,
color == b.color,
coordinates.count == b.coordinates.count
(width ?? 0) == (b.width ?? 0),
lineCap == b.lineCap,
lineJoin == b.lineJoin,
color == b.color,
coordinates.count == b.coordinates.count
else { return false }
for i in 0..<coordinates.count {
if coordinates[i].latitude != b.coordinates[i].latitude
Expand Down
2 changes: 1 addition & 1 deletion ios/PermissionHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class PermissionHandler: NSObject, CLLocationManagerDelegate {
}

func requestLocationPermission()
-> NitroModules.Promise<RNLocationPermissionResult> {
-> NitroModules.Promise<RNLocationPermissionResult> {
let promise = NitroModules.Promise<RNLocationPermissionResult>()

let status = manager.authorizationStatus
Expand Down
2 changes: 1 addition & 1 deletion ios/RNGoogleMapsPlusModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class RNGoogleMapsPlusModule: HybridRNGoogleMapsPlusModuleSpec {
}

func requestLocationPermission()
-> NitroModules.Promise<RNLocationPermissionResult> {
-> NitroModules.Promise<RNLocationPermissionResult> {
return permissionHandler.requestLocationPermission()
}

Expand Down
54 changes: 27 additions & 27 deletions ios/RNGoogleMapsPlusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
}

func requestLocationPermission()
-> NitroModules.Promise<RNLocationPermissionResult> {
-> NitroModules.Promise<RNLocationPermissionResult> {
return permissionHandler.requestLocationPermission()
}

Expand Down Expand Up @@ -298,8 +298,8 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
}

private func mapCameraPositionToCamera(_ cp: GMSCameraPosition?)
-> RNCamera? {
guard let cp = cp else { return nil }
-> RNCamera? {
guard let cp = cp else { return nil }

return RNCamera(
center: RNLatLng(
Expand All @@ -313,35 +313,35 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
}

func mapUserInterfaceStyleToUIUserInterfaceStyle(
_ style: RNUserInterfaceStyle?
_ style: RNUserInterfaceStyle?
) -> UIUserInterfaceStyle? {
guard let style = style else { return nil }

switch style {
case .light:
return .light
case .dark:
return .dark
case .default:
return .unspecified
}
guard let style = style else { return nil }

switch style {
case .light:
return .light
case .dark:
return .dark
case .default:
return .unspecified
}
}

func mapUIUserInterfaceStyleToUserInterfaceStyle(
_ uiStyle: UIUserInterfaceStyle?
_ uiStyle: UIUserInterfaceStyle?
) -> RNUserInterfaceStyle? {
guard let uiStyle = uiStyle else { return nil }

switch uiStyle {
case .light:
return .light
case .dark:
return .dark
case .unspecified:
return .default
@unknown default:
return .default
}
guard let uiStyle = uiStyle else { return nil }

switch uiStyle {
case .light:
return .light
case .dark:
return .dark
case .unspecified:
return .default
@unknown default:
return .default
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"lint": "yarn lint:js && yarn lint:android && yarn lint:ios",
"lint:js": "eslint . --max-warnings 0 && yarn prettier --check .",
"lint:android": "cd android && ktlint -F ./**/*.kt*",
"lint:ios": "cd ios && swiftlint --quiet",
"lint:ios": "cd ios && swiftlint --quiet && swiftformat . --lint",
"format": "yarn format:js && yarn format:ios && yarn format:android",
"format:js": "prettier --write .",
"format:android": "cd android && ktlint --format ./**/*.kt*",
"format:ios": "cd ios && swiftlint --quiet --fix",
"format:ios": "cd ios && swiftformat .",
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
"test": "jest",
"git:clean": "git clean -dfX",
Expand Down
Loading