Skip to content

[various] Run swift-format on ungenerated Swift files #5929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
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 @@ -5,62 +5,63 @@
import Foundation

#if os(iOS)
import Flutter
import Flutter
#elseif os(macOS)
import FlutterMacOS
import FlutterMacOS
#endif

public class PathProviderPlugin: NSObject, FlutterPlugin, PathProviderApi {
public static func register(with registrar: FlutterPluginRegistrar) {
let instance = PathProviderPlugin()
// Workaround for https://github.com/flutter/flutter/issues/118103.
#if os(iOS)
let messenger = registrar.messenger()
#else
let messenger = registrar.messenger
#endif
#if os(iOS)
let messenger = registrar.messenger()
#else
let messenger = registrar.messenger
#endif
PathProviderApiSetup.setUp(binaryMessenger: messenger, api: instance)
}

func getDirectoryPath(type: DirectoryType) -> String? {
var path = getDirectory(ofType: fileManagerDirectoryForType(type))
#if os(macOS)
// In a non-sandboxed app, these are shared directories where applications are
// expected to use its bundle ID as a subdirectory. (For non-sandboxed apps,
// adding the extra path is harmless).
// This is not done for iOS, for compatibility with older versions of the
// plugin.
if type == .applicationSupport || type == .applicationCache {
if let basePath = path {
let basePathURL = URL.init(fileURLWithPath: basePath)
path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path
#if os(macOS)
// In a non-sandboxed app, these are shared directories where applications are
// expected to use its bundle ID as a subdirectory. (For non-sandboxed apps,
// adding the extra path is harmless).
// This is not done for iOS, for compatibility with older versions of the
// plugin.
if type == .applicationSupport || type == .applicationCache {
if let basePath = path {
let basePathURL = URL.init(fileURLWithPath: basePath)
path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path
}
}
}
#endif
#endif
return path
}

// Returns the path for the container of the specified app group.
func getContainerPath(appGroupIdentifier: String) -> String? {
return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.path
return FileManager.default.containerURL(
forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.path
}
}

/// Returns the FileManager constant corresponding to the given type.
private func fileManagerDirectoryForType(_ type: DirectoryType) -> FileManager.SearchPathDirectory {
switch type {
case .applicationCache:
return FileManager.SearchPathDirectory.cachesDirectory
case .applicationDocuments:
return FileManager.SearchPathDirectory.documentDirectory
case .applicationSupport:
return FileManager.SearchPathDirectory.applicationSupportDirectory
case .downloads:
return FileManager.SearchPathDirectory.downloadsDirectory
case .library:
return FileManager.SearchPathDirectory.libraryDirectory
case .temp:
return FileManager.SearchPathDirectory.cachesDirectory
case .applicationCache:
return FileManager.SearchPathDirectory.cachesDirectory
case .applicationDocuments:
return FileManager.SearchPathDirectory.documentDirectory
case .applicationSupport:
return FileManager.SearchPathDirectory.applicationSupportDirectory
case .downloads:
return FileManager.SearchPathDirectory.downloadsDirectory
case .library:
return FileManager.SearchPathDirectory.libraryDirectory
case .temp:
return FileManager.SearchPathDirectory.cachesDirectory
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// found in the LICENSE file.

import XCTest

@testable import path_provider_foundation

#if os(iOS)
import Flutter
import Flutter
#elseif os(macOS)
import FlutterMacOS
import FlutterMacOS
#endif

class RunnerTests: XCTestCase {
Expand Down Expand Up @@ -39,28 +40,28 @@ class RunnerTests: XCTestCase {
func testGetApplicationSupportDirectory() throws {
let plugin = PathProviderPlugin()
let path = plugin.getDirectoryPath(type: .applicationSupport)
#if os(iOS)
// On iOS, the application support directory path should be just the system application
// support path.
XCTAssertEqual(
path,
NSSearchPathForDirectoriesInDomains(
FileManager.SearchPathDirectory.applicationSupportDirectory,
FileManager.SearchPathDomainMask.userDomainMask,
true
).first)
#else
// On macOS, the application support directory path should be the system application
// support path with an added subdirectory based on the app name.
XCTAssert(
path!.hasPrefix(
#if os(iOS)
// On iOS, the application support directory path should be just the system application
// support path.
XCTAssertEqual(
path,
NSSearchPathForDirectoriesInDomains(
FileManager.SearchPathDirectory.applicationSupportDirectory,
FileManager.SearchPathDomainMask.userDomainMask,
true
).first!))
XCTAssert(path!.hasSuffix("Example"))
#endif
).first)
#else
// On macOS, the application support directory path should be the system application
// support path with an added subdirectory based on the app name.
XCTAssert(
path!.hasPrefix(
NSSearchPathForDirectoriesInDomains(
FileManager.SearchPathDirectory.applicationSupportDirectory,
FileManager.SearchPathDomainMask.userDomainMask,
true
).first!))
XCTAssert(path!.hasSuffix("Example"))
#endif
}

func testGetLibraryDirectory() throws {
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
10 changes: 6 additions & 4 deletions packages/pigeon/example/app/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ private class PigeonApiImplementation: ExampleHostApi {
}

func add(_ a: Int64, to b: Int64) throws -> Int64 {
if (a < 0 || b < 0) {
throw FlutterError(code: "code", message: "message", details: "details");
if a < 0 || b < 0 {
throw FlutterError(code: "code", message: "message", details: "details")
}
return a + b
}

func sendMessage(message: MessageData, completion: @escaping (Result<Bool, Error>) -> Void) {
if (message.code == Code.one) {
if message.code == Code.one {
completion(.failure(FlutterError(code: "code", message: "message", details: "details")))
return
}
Expand All @@ -39,7 +39,9 @@ private class PigeonFlutterApi {
flutterAPI = MessageFlutterApi(binaryMessenger: binaryMessenger)
}

func callFlutterMethod(aString aStringArg: String?, completion: @escaping (Result<String, Error>) -> Void) {
func callFlutterMethod(
aString aStringArg: String?, completion: @escaping (Result<String, Error>) -> Void
) {
flutterAPI.flutterMethod(aString: aStringArg) {
completion(.success($0))
}
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 FlutterMacOS
import Cocoa
import FlutterMacOS
import XCTest

@testable import alternate_language_test_plugin
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
Loading