Skip to content

Commit

Permalink
[various] Run swift-format on example app Swift files (#5931)
Browse files Browse the repository at this point in the history
Run `swift-format` linter/formatter on Swift files in example apps.  This doesn't touch any Swift files in non-example code.

Part of turning on swift-format CI formatting #5928
  • Loading branch information
jmagman committed Jan 19, 2024
1 parent 1ccc0e1 commit 4dd91ce
Show file tree
Hide file tree
Showing 22 changed files with 54 additions and 62 deletions.
2 changes: 1 addition & 1 deletion packages/animations/example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -13,12 +13,12 @@ import Flutter
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

weak var registrar = self.registrar(forPlugin: "DummyPlatform");
weak var registrar = self.registrar(forPlugin: "DummyPlatform")

let factory = DummyPlatformViewFactory(messenger: registrar!.messenger())
self.registrar(forPlugin: "<DummyPlatform>")!.register(
factory,
withId: "dummy_platform_view")
factory,
withId: "dummy_platform_view")

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import Flutter
import UIKit

/**
* A simple factory that creates a dummy platform view for testing.
*/
/// A simple factory that creates a dummy platform view for testing.
public class DummyPlatformViewFactory: NSObject, FlutterPlatformViewFactory {
private var messenger: FlutterBinaryMessenger

Expand All @@ -33,38 +31,34 @@ public class DummyPlatformViewFactory: NSObject, FlutterPlatformViewFactory {
}
}

/**
* A native view that will remove it's tag if clicked.
*/
/// A native view that will remove it's tag if clicked.
public class CustomView: UIView {

var timesClicked = 0;
var timesClicked = 0
var nativeLabel = UILabel()

override public func hitTest(
_ point: CGPoint,
with event: UIEvent?
) -> UIView? {
if (viewWithTag(1) != nil) {
viewWithTag(1)?.removeFromSuperview();
createNativeView(view: self);
if viewWithTag(1) != nil {
viewWithTag(1)?.removeFromSuperview()
createNativeView(view: self)
}
timesClicked += 1;
timesClicked += 1
nativeLabel.text = "Traversed \(timesClicked) subviews"
return super.hitTest(point, with: event)
}

func createNativeView(view _view: CustomView){
func createNativeView(view _view: CustomView) {
nativeLabel.text = "Traversed \(timesClicked) subviews"
nativeLabel.frame = CGRect(x: 0, y: 0, width: 180, height: 48.0)
_view.addSubview(nativeLabel)
}
}
/**
* A flutter platform view that displays a simple native view.
*/
/// A flutter platform view that displays a simple native view.
class DummyPlatformView: NSObject, FlutterPlatformView {
private var _view: CustomView;
private var _view: CustomView

init(
frame: CGRect,
Expand All @@ -81,9 +75,9 @@ class DummyPlatformView: NSObject, FlutterPlatformView {
return _view
}

func createNativeView(view _view: CustomView){
func createNativeView(view _view: CustomView) {
let nativeLabel = UILabel()
nativeLabel.tag = 1;
nativeLabel.tag = 1
nativeLabel.text = "Native View Not Clicked"
nativeLabel.frame = CGRect(x: 0, y: 0, width: 180, height: 48.0)
_view.addSubview(nativeLabel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -13,12 +13,12 @@ import Flutter
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

weak var registrar = self.registrar(forPlugin: "DummyPlatform");
weak var registrar = self.registrar(forPlugin: "DummyPlatform")

let factory = DummyPlatformViewFactory(messenger: registrar!.messenger())
self.registrar(forPlugin: "<DummyPlatform>")!.register(
factory,
withId: "dummy_platform_view")
factory,
withId: "dummy_platform_view")

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import Flutter
import UIKit

/**
* A simple factory that creates a dummy platform view for testing.
*/
/// A simple factory that creates a dummy platform view for testing.
public class DummyPlatformViewFactory: NSObject, FlutterPlatformViewFactory {
private var messenger: FlutterBinaryMessenger

Expand All @@ -33,25 +31,21 @@ public class DummyPlatformViewFactory: NSObject, FlutterPlatformViewFactory {
}
}

/**
* A native view that will remove its tag if clicked.
*/
/// A native view that will remove its tag if clicked.
public class CustomView: UIView {

override public func hitTest(
_ point: CGPoint,
with event: UIEvent?
) -> UIView? {
viewWithTag(1)?.removeFromSuperview();
viewWithTag(1)?.removeFromSuperview()
return super.hitTest(point, with: event)
}
}

/**
* A flutter platform view that displays a simple native view.
*/
/// A flutter platform view that displays a simple native view.
class DummyPlatformView: NSObject, FlutterPlatformView {
private var _view: CustomView;
private var _view: CustomView

init(
frame: CGRect,
Expand All @@ -68,10 +62,10 @@ class DummyPlatformView: NSObject, FlutterPlatformView {
return _view
}

func createNativeView(view _view: CustomView){
func createNativeView(view _view: CustomView) {
let nativeLabel = UILabel()
_view.isUserInteractionEnabled = true
nativeLabel.tag = 1;
nativeLabel.tag = 1
nativeLabel.text = "Not Clicked"
nativeLabel.frame = CGRect(x: 0, y: 0, width: 180, height: 48.0)
_view.addSubview(nativeLabel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private let pressDurationRetryAdjustment: TimeInterval = 0.2
// This is to deflake a situation where the quick action menu is not present after
// the long press.
// See: https://github.com/flutter/flutter/issues/125509
private let quickActionMaxRetries: Int = 4;
private let quickActionMaxRetries: Int = 4

class RunnerUITests: XCTestCase {

Expand All @@ -40,7 +40,8 @@ class RunnerUITests: XCTestCase {
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let quickActionsAppIcon = springboard.icons["quick_actions_example"]

findAndTapQuickActionButton(buttonName: "Action two", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard);
findAndTapQuickActionButton(
buttonName: "Action two", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard)

let actionTwoConfirmation = exampleApp.otherElements["action_two"]
if !actionTwoConfirmation.waitForExistence(timeout: elementWaitingTime) {
Expand Down Expand Up @@ -73,7 +74,8 @@ class RunnerUITests: XCTestCase {
)
}

findAndTapQuickActionButton(buttonName: "Action one", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard);
findAndTapQuickActionButton(
buttonName: "Action one", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard)

let actionOneConfirmation = exampleApp.otherElements["action_one"]
if !actionOneConfirmation.waitForExistence(timeout: elementWaitingTime) {
Expand All @@ -85,7 +87,9 @@ class RunnerUITests: XCTestCase {
XCTAssert(actionOneConfirmation.exists)
}

private func findAndTapQuickActionButton(buttonName: String, quickActionsAppIcon: XCUIElement, springboard: XCUIElement) {
private func findAndTapQuickActionButton(
buttonName: String, quickActionsAppIcon: XCUIElement, springboard: XCUIElement
) {
var actionButton: XCUIElement?
var pressDuration = quickActionPressDuration
for _ in 1...quickActionMaxRetries {
Expand All @@ -111,12 +115,12 @@ class RunnerUITests: XCTestCase {
// Reset to previous state.
XCUIDevice.shared.press(XCUIDevice.Button.home)
}
if (!actionButton!.exists) {
if !actionButton!.exists {
XCTFail(
"Failed due to not able to find the \(buttonName) button from springboard with \(elementWaitingTime) seconds. Springboard debug description: \(springboard.debugDescription)"
)
}

actionButton!.tap();
actionButton!.tap()
}
}
2 changes: 1 addition & 1 deletion packages/rfw/example/hello/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
2 changes: 1 addition & 1 deletion packages/rfw/example/local/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
2 changes: 1 addition & 1 deletion packages/rfw/example/remote/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand Down

0 comments on commit 4dd91ce

Please sign in to comment.