diff --git a/ios/.swiftformat b/ios/.swiftformat new file mode 100644 index 0000000..a4c1ee5 --- /dev/null +++ b/ios/.swiftformat @@ -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 diff --git a/ios/Color.swift b/ios/Color.swift index 5b1f327..9ea47fd 100644 --- a/ios/Color.swift +++ b/ios/Color.swift @@ -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( @@ -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 @@ -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) diff --git a/ios/GoogleMapViewImpl.swift b/ios/GoogleMapViewImpl.swift index 9e92ca7..185bdd1 100644 --- a/ios/GoogleMapViewImpl.swift +++ b/ios/GoogleMapViewImpl.swift @@ -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( @@ -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 { @@ -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 @@ -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 { @@ -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() @@ -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 { diff --git a/ios/MapPolygon.swift b/ios/MapPolygon.swift index f9cfb6d..7b0036c 100644 --- a/ios/MapPolygon.swift +++ b/ios/MapPolygon.swift @@ -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.. 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.. NitroModules.Promise { + -> NitroModules.Promise { let promise = NitroModules.Promise() let status = manager.authorizationStatus diff --git a/ios/RNGoogleMapsPlusModule.swift b/ios/RNGoogleMapsPlusModule.swift index cae6fef..82c7336 100644 --- a/ios/RNGoogleMapsPlusModule.swift +++ b/ios/RNGoogleMapsPlusModule.swift @@ -16,7 +16,7 @@ final class RNGoogleMapsPlusModule: HybridRNGoogleMapsPlusModuleSpec { } func requestLocationPermission() - -> NitroModules.Promise { + -> NitroModules.Promise { return permissionHandler.requestLocationPermission() } diff --git a/ios/RNGoogleMapsPlusView.swift b/ios/RNGoogleMapsPlusView.swift index 28a3ce0..c9cc5f0 100644 --- a/ios/RNGoogleMapsPlusView.swift +++ b/ios/RNGoogleMapsPlusView.swift @@ -268,7 +268,7 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec { } func requestLocationPermission() - -> NitroModules.Promise { + -> NitroModules.Promise { return permissionHandler.requestLocationPermission() } @@ -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( @@ -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 + } } } diff --git a/package.json b/package.json index c70c93b..5b79780 100644 --- a/package.json +++ b/package.json @@ -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",