Skip to content

Commit 1f9f9ee

Browse files
authored
chore: update swift-format package (#327)
* chore: change swift-format package * chore: format swift code
1 parent 71ad280 commit 1f9f9ee

28 files changed

+960
-617
lines changed

.github/workflows/analyze.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,24 @@ jobs:
7070
with:
7171
path: /home/linuxbrew/.linuxbrew
7272
key: ${{ runner.os }}-linuxbrew
73-
- name: Install swiftformat 0.54.6
73+
- name: Install swift-format 600.0.0
7474
if: steps.cache.outputs.cache-hit != 'true'
7575
run: |
7676
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
7777
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
78-
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/4564fbc21a326c4eb349327ce327cbe983bf302a/Formula/s/swiftformat.rb
79-
echo 'brew "swiftformat.rb"' > Brewfile
78+
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/402e262f48947bad849ea7793752ff16b7038406/Formula/s/swift-format.rb
79+
echo 'brew "swift-format.rb"' > Brewfile
8080
brew bundle
8181
- name: Save Cache
8282
uses: actions/cache/save@v4
8383
if: steps.cache.outputs.cache-hit != 'true'
8484
with:
8585
path: /home/linuxbrew/.linuxbrew
8686
key: ${{ runner.os }}-linuxbrew
87-
- name: Formatter version
87+
- name: Print swift-format version
8888
run: |
8989
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
90-
swiftformat --version
90+
swift-format --version
9191
- name: Run format
9292
if: ${{ success() || failure() }}
9393
run: |

.swiftformat

Lines changed: 0 additions & 6 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ _See also: [Flutter's code of conduct](https://flutter.io/design-principles/#cod
77
- **Operating System:** Linux, macOS, or Windows.
88
- **Version Control:** [git](https://git-scm.com).
99
- **Development Environment:** An IDE such as [Android Studio](https://developer.android.com/studio) or [Visual Studio Code](https://code.visualstudio.com/).
10-
- **Code Formatting:** [`swiftformat`](https://github.com/nicklockwood/SwiftFormat) (available via brew on macOS, on Windows install Swift toolchain and build SwiftFormat from git sources).
10+
- **Code Formatting:** [`swift-format`](https://formulae.brew.sh/formula/swift-formatt).
1111

12-
### 1.1. Installing swiftformat
13-
The CI is locked to swiftformat 0.54.6 version which you can install with the command below:
12+
### 1.1. Installing swift-format
13+
The CI is locked to swift-format 600.0.0 version which you can install with the command below:
1414
```bash
15-
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/4564fbc21a326c4eb349327ce327cbe983bf302a/Formula/s/swiftformat.rb
16-
brew install swiftformat.rb
15+
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/402e262f48947bad849ea7793752ff16b7038406/Formula/s/swift-format.rb
16+
brew install swift-format.rb
1717
```
1818

1919
## 2. Setting Up Your Local Repository

example/ios/Runner/AppDelegate.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import UIKit
1615
import Flutter
1716
import GoogleMaps
1817
import GoogleNavigation
18+
import UIKit
1919

2020
@objc class AppDelegate: FlutterAppDelegate {
2121
override func application(
@@ -25,8 +25,10 @@ import GoogleNavigation
2525
// 1. Try to find the Maps API key from the environment variables.
2626
// 2. Try to find the Maps API key from the Dart defines.
2727
// 3. Use the default Maps API key "YOUR_API_KEY".
28-
var mapsApiKey = ProcessInfo.processInfo.environment["MAPS_API_KEY"] ?? findMapApiKeyFromDartDefines("MAPS_API_KEY") ?? ""
29-
if (mapsApiKey.isEmpty) {
28+
var mapsApiKey =
29+
ProcessInfo.processInfo.environment["MAPS_API_KEY"] ?? findMapApiKeyFromDartDefines(
30+
"MAPS_API_KEY") ?? ""
31+
if mapsApiKey.isEmpty {
3032
mapsApiKey = "YOUR_API_KEY"
3133
}
3234
GMSServices.provideAPIKey(mapsApiKey)
@@ -36,7 +38,7 @@ import GoogleNavigation
3638

3739
// Helper function to find the Maps API key from the Dart defines
3840
private func findMapApiKeyFromDartDefines(_ defineKey: String) -> String? {
39-
if (Bundle.main.infoDictionary!["DART_DEFINES"] == nil) {
41+
if Bundle.main.infoDictionary!["DART_DEFINES"] == nil {
4042
return nil
4143
}
4244

@@ -45,7 +47,7 @@ import GoogleNavigation
4547
for base64EncodedDartDefine in base64EncodedDartDefines {
4648
let decoded = String(data: Data(base64Encoded: base64EncodedDartDefine)!, encoding: .utf8)!
4749
let values = decoded.components(separatedBy: "=")
48-
if (values[0] == defineKey && values.count == 2) {
50+
if values[0] == defineKey && values.count == 2 {
4951
return values[1]
5052
}
5153
}

example/ios/Runner/AppDelegateCarPlay.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ import GoogleNavigation
1919
import UIKit
2020

2121
@objc class AppDelegateCarPlay: FlutterAppDelegate {
22-
override func application(_ application: UIApplication,
23-
didFinishLaunchingWithOptions launchOptions: [
24-
UIApplication.LaunchOptionsKey: Any
25-
]?) -> Bool {
22+
override func application(
23+
_ application: UIApplication,
24+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
25+
) -> Bool {
2626
// 1. Try to find the Maps API key from the environment variables.
2727
// 2. Try to find the Maps API key from the Dart defines.
2828
// 3. Use the default Maps API key "YOUR_API_KEY".
29-
var mapsApiKey = ProcessInfo.processInfo
29+
var mapsApiKey =
30+
ProcessInfo.processInfo
3031
.environment["MAPS_API_KEY"] ?? findMapApiKeyFromDartDefines("MAPS_API_KEY") ?? ""
3132
if mapsApiKey.isEmpty {
3233
mapsApiKey = "YOUR_API_KEY"
@@ -35,9 +36,11 @@ import UIKit
3536
return true
3637
}
3738

38-
override func application(_ application: UIApplication,
39-
configurationForConnecting connectingSceneSession: UISceneSession,
40-
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
39+
override func application(
40+
_ application: UIApplication,
41+
configurationForConnecting connectingSceneSession: UISceneSession,
42+
options: UIScene.ConnectionOptions
43+
) -> UISceneConfiguration {
4144
if connectingSceneSession.role == .carTemplateApplication {
4245
let scene = UISceneConfiguration(name: "CarPlay", sessionRole: connectingSceneSession.role)
4346
scene.delegateClass = CarSceneDelegate.self

example/ios/Runner/CarSceneDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// limitations under the License.
1414

1515
import CarPlay
16-
import google_navigation_flutter
1716
import GoogleNavigation
1817
import UIKit
18+
import google_navigation_flutter
1919

2020
class CarSceneDelegate: BaseCarSceneDelegate {
2121
override func getTemplate() -> CPMapTemplate {

example/ios/Runner/PhoneSceneDelegate.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import UIKit
1717
class PhoneSceneDelegate: UIResponder, UIWindowSceneDelegate {
1818
var window: UIWindow?
1919

20-
func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
21-
options connectionOptions: UIScene.ConnectionOptions) {
20+
func scene(
21+
_ scene: UIScene, willConnectTo session: UISceneSession,
22+
options connectionOptions: UIScene.ConnectionOptions
23+
) {
2224
if let windowScene = scene as? UIWindowScene {
2325
window = UIWindow(windowScene: windowScene)
2426
let flutterEngine = FlutterEngine(name: "PhoneSceneDelegateEngine")

example/ios/RunnerTests/ConvertTests.swift

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class ConvertTests: XCTestCase {
114114
latitude: 55.0,
115115
longitude: 44.0
116116
)
117-
),
117+
)
118118
],
119119
displayOptions: NavigationDisplayOptionsDto()
120120
)
@@ -129,7 +129,7 @@ class ConvertTests: XCTestCase {
129129
.init(
130130
title: "test",
131131
placeID: "id"
132-
),
132+
)
133133
],
134134
displayOptions: NavigationDisplayOptionsDto()
135135
)
@@ -173,8 +173,9 @@ class ConvertTests: XCTestCase {
173173
XCTAssertTrue(Convert.convertRouteStatus(.waypointError) == .waypointError)
174174
XCTAssertTrue(Convert.convertRouteStatus(.apiKeyNotAuthorized) == .apiKeyNotAuthorized)
175175
XCTAssertTrue(Convert.convertRouteStatus(.canceled) == .statusCanceled)
176-
XCTAssertTrue(Convert
177-
.convertRouteStatus(.duplicateWaypointsError) == .duplicateWaypointsError)
176+
XCTAssertTrue(
177+
Convert
178+
.convertRouteStatus(.duplicateWaypointsError) == .duplicateWaypointsError)
178179
XCTAssertTrue(Convert.convertRouteStatus(.internalError) == .internalError)
179180
XCTAssertTrue(Convert.convertRouteStatus(.locationUnavailable) == .locationUnavailable)
180181
XCTAssertTrue(Convert.convertRouteStatus(.OK) == .statusOk)
@@ -197,25 +198,28 @@ class ConvertTests: XCTestCase {
197198

198199
func testConvertGMSSpeedAlertSeverity() {
199200
XCTAssertTrue(Convert.convertSpeedAlertSeverity(gmsSpeedAlertSeverity: .unknown) == .unknown)
200-
XCTAssertTrue(Convert
201-
.convertSpeedAlertSeverity(gmsSpeedAlertSeverity: .notSpeeding) == .notSpeeding)
201+
XCTAssertTrue(
202+
Convert
203+
.convertSpeedAlertSeverity(gmsSpeedAlertSeverity: .notSpeeding) == .notSpeeding)
202204
XCTAssertTrue(Convert.convertSpeedAlertSeverity(gmsSpeedAlertSeverity: .minor) == .minor)
203205
XCTAssertTrue(Convert.convertSpeedAlertSeverity(gmsSpeedAlertSeverity: .major) == .major)
204206
}
205207

206208
func testConvertSpeedAlertSeverity() {
207209
XCTAssertTrue(Convert.convertSpeedAlertSeverity(speedAlertSeverity: .unknown) == .unknown)
208-
XCTAssertTrue(Convert
209-
.convertSpeedAlertSeverity(speedAlertSeverity: .notSpeeding) == .notSpeeding)
210+
XCTAssertTrue(
211+
Convert
212+
.convertSpeedAlertSeverity(speedAlertSeverity: .notSpeeding) == .notSpeeding)
210213
XCTAssertTrue(Convert.convertSpeedAlertSeverity(speedAlertSeverity: .minor) == .minor)
211214
XCTAssertTrue(Convert.convertSpeedAlertSeverity(speedAlertSeverity: .major) == .major)
212215
}
213216

214217
func testConvertNavigationAudioGuidanceType() {
215218
XCTAssertTrue(Convert.convertNavigationAudioGuidanceType(.silent) == .silent)
216219
XCTAssertTrue(Convert.convertNavigationAudioGuidanceType(.alertsOnly) == .alertsOnly)
217-
XCTAssertTrue(Convert
218-
.convertNavigationAudioGuidanceType(.alertsAndGuidance) == .alertsAndGuidance)
220+
XCTAssertTrue(
221+
Convert
222+
.convertNavigationAudioGuidanceType(.alertsAndGuidance) == .alertsAndGuidance)
219223
}
220224

221225
func testMarkerDtoToGMSMarkerAndBack() {
@@ -365,12 +369,16 @@ class ConvertTests: XCTestCase {
365369
let polygon = PolygonDto(
366370
polygonId: "Polygon_0",
367371
options: .init(
368-
points: [LatLngDto(latitude: 10.0, longitude: 20.0),
369-
LatLngDto(latitude: 30.0, longitude: 40.0)],
370-
holes: [PolygonHoleDto(points: [
371-
LatLngDto(latitude: 50.0, longitude: 60.0),
372-
LatLngDto(latitude: 70.0, longitude: 80.0),
373-
])],
372+
points: [
373+
LatLngDto(latitude: 10.0, longitude: 20.0),
374+
LatLngDto(latitude: 30.0, longitude: 40.0),
375+
],
376+
holes: [
377+
PolygonHoleDto(points: [
378+
LatLngDto(latitude: 50.0, longitude: 60.0),
379+
LatLngDto(latitude: 70.0, longitude: 80.0),
380+
])
381+
],
374382
clickable: true,
375383
fillColor: UIColor.red.toRgb()!,
376384
geodesic: true,
@@ -404,12 +412,16 @@ class ConvertTests: XCTestCase {
404412
let polygon = PolygonDto(
405413
polygonId: "Polygon_0",
406414
options: .init(
407-
points: [LatLngDto(latitude: 10.0, longitude: 20.0),
408-
LatLngDto(latitude: 30.0, longitude: 40.0)],
409-
holes: [PolygonHoleDto(points: [
410-
LatLngDto(latitude: 50.0, longitude: 60.0),
411-
LatLngDto(latitude: 70.0, longitude: 80.0),
412-
])],
415+
points: [
416+
LatLngDto(latitude: 10.0, longitude: 20.0),
417+
LatLngDto(latitude: 30.0, longitude: 40.0),
418+
],
419+
holes: [
420+
PolygonHoleDto(points: [
421+
LatLngDto(latitude: 50.0, longitude: 60.0),
422+
LatLngDto(latitude: 70.0, longitude: 80.0),
423+
])
424+
],
413425
clickable: true,
414426
fillColor: UIColor.red.toRgb()!,
415427
geodesic: true,
@@ -543,8 +555,9 @@ class ConvertTests: XCTestCase {
543555
)
544556

545557
let navigationViewOptions =
546-
NavigationViewOptionsDto(navigationUIEnabledPreference: NavigationUIEnabledPreferenceDto
547-
.automatic)
558+
NavigationViewOptionsDto(
559+
navigationUIEnabledPreference: NavigationUIEnabledPreferenceDto
560+
.automatic)
548561

549562
let configuration = Convert.convertMapOptions(mapOptions)
550563

ios/google_navigation_flutter/Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import PackageDescription
2020
let package = Package(
2121
name: "google_navigation_flutter",
2222
platforms: [
23-
.iOS("15.0"),
23+
.iOS("15.0")
2424
],
2525
products: [
26-
.library(name: "google-navigation-flutter", targets: ["google_navigation_flutter"]),
26+
.library(name: "google-navigation-flutter", targets: ["google_navigation_flutter"])
2727
],
2828
dependencies: [
2929
.package(
@@ -49,8 +49,8 @@ let package = Package(
4949
),
5050
],
5151
resources: [
52-
.process("PrivacyInfo.xcprivacy"),
52+
.process("PrivacyInfo.xcprivacy")
5353
]
54-
),
54+
)
5555
]
5656
)

ios/google_navigation_flutter/Sources/google_navigation_flutter/BaseCarSceneDelegate.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import Foundation
1717
import GoogleMaps
1818

1919
open class BaseCarSceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate,
20-
CPMapTemplateDelegate {
20+
CPMapTemplateDelegate
21+
{
2122
private var interfaceController: CPInterfaceController?
2223
private var carWindow: CPWindow?
2324
private var mapTemplate: CPMapTemplate?
@@ -31,9 +32,11 @@ open class BaseCarSceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate
3132
navView
3233
}
3334

34-
public func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
35-
didConnect interfaceController: CPInterfaceController,
36-
to window: CPWindow) {
35+
public func templateApplicationScene(
36+
_ templateApplicationScene: CPTemplateApplicationScene,
37+
didConnect interfaceController: CPInterfaceController,
38+
to window: CPWindow
39+
) {
3740
self.interfaceController = interfaceController
3841
carWindow = window
3942
mapTemplate = getTemplate()
@@ -48,9 +51,11 @@ open class BaseCarSceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate
4851
return template
4952
}
5053

51-
open func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
52-
didDisconnect interfaceController: CPInterfaceController,
53-
from window: CPWindow) {
54+
open func templateApplicationScene(
55+
_ templateApplicationScene: CPTemplateApplicationScene,
56+
didDisconnect interfaceController: CPInterfaceController,
57+
from window: CPWindow
58+
) {
5459
self.interfaceController = nil
5560
carWindow?.rootViewController = nil
5661
carWindow = nil
@@ -110,8 +115,10 @@ open class BaseCarSceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate
110115
}
111116

112117
// CPMapTemplateDelegate
113-
open func mapTemplate(_ mapTemplate: CPMapTemplate,
114-
panWith direction: CPMapTemplate.PanDirection) {
118+
open func mapTemplate(
119+
_ mapTemplate: CPMapTemplate,
120+
panWith direction: CPMapTemplate.PanDirection
121+
) {
115122
let scrollAmount = scrollAmount(for: direction)
116123
navView?.animateCameraByScroll(dx: scrollAmount.x, dy: scrollAmount.y)
117124
}

ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert+MapConfiguration.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import GoogleMaps
1717

1818
extension Convert {
1919
static func convertNavigationUIEnabledPreference(preference: NavigationUIEnabledPreferenceDto?)
20-
-> NavigationUIEnabledPreference {
20+
-> NavigationUIEnabledPreference
21+
{
2122
switch preference {
2223
case .automatic:
2324
return .automatic
@@ -29,7 +30,8 @@ extension Convert {
2930
}
3031

3132
static func convertMapOptions(_ mapOptions: MapOptionsDto)
32-
-> MapConfiguration {
33+
-> MapConfiguration
34+
{
3335
let cameraTargetBounds: GMSCoordinateBounds?
3436
if let bounds = mapOptions.cameraTargetBounds {
3537
cameraTargetBounds = convertLatLngBounds(bounds: bounds)

0 commit comments

Comments
 (0)