From 7f8cda1a44004c483cb51bff71d12a5d054091d5 Mon Sep 17 00:00:00 2001 From: Mikhail Akopov Date: Tue, 4 Oct 2022 19:12:23 +0300 Subject: [PATCH 1/3] Add .swiftformat --- .swiftformat | 1 + 1 file changed, 1 insertion(+) create mode 100644 .swiftformat diff --git a/.swiftformat b/.swiftformat new file mode 100644 index 0000000..2ff2e98 --- /dev/null +++ b/.swiftformat @@ -0,0 +1 @@ +--ifdef no-indent From ca84997df09b93158f9c8d28e9e20c809d11022b Mon Sep 17 00:00:00 2001 From: Mikhail Akopov Date: Tue, 4 Oct 2022 19:14:08 +0300 Subject: [PATCH 2/3] Apply SwiftFormat rules --- Package.swift | 15 ++++++++------- .../ViewModel/AssetDetailViewModel.swift | 2 +- .../Views/AssetDetailCell.swift | 2 +- .../MosaiqueAssetsPicker/Views/GradientView.swift | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Package.swift b/Package.swift index 50ab2b9..73fb774 100644 --- a/Package.swift +++ b/Package.swift @@ -5,14 +5,15 @@ import PackageDescription let package = Package( name: "MosaiqueAssetsPicker", - platforms: [ - .iOS(.v10) + platforms: [ + .iOS(.v10), ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "MosaiqueAssetsPicker", - targets: ["MosaiqueAssetsPicker"]), + targets: ["MosaiqueAssetsPicker"] + ), ], dependencies: [ // Dependencies declare other packages that this package depends on. @@ -25,14 +26,14 @@ let package = Package( name: "MosaiqueAssetsPicker", dependencies: [], path: "Sources/MosaiqueAssetsPicker", - exclude:["Info.plist"] - ), + exclude: ["Info.plist"] + ), .testTarget( name: "MosaiqueAssetsPickerTests", dependencies: ["MosaiqueAssetsPicker"], path: "Tests/AssetsPickerTests", - exclude:["Info.plist"] - ), + exclude: ["Info.plist"] + ), ], swiftLanguageVersions: [.v5] ) diff --git a/Sources/MosaiqueAssetsPicker/ViewModel/AssetDetailViewModel.swift b/Sources/MosaiqueAssetsPicker/ViewModel/AssetDetailViewModel.swift index 6aa630d..bcc00c8 100644 --- a/Sources/MosaiqueAssetsPicker/ViewModel/AssetDetailViewModel.swift +++ b/Sources/MosaiqueAssetsPicker/ViewModel/AssetDetailViewModel.swift @@ -64,7 +64,7 @@ public final class AssetDetailViewModel: NSObject { let dispatchGroup = DispatchGroup() var images: [UIImage] = [] - let assetsDownloads = selectionContainer.selectedItems.map { (cellViewModel) -> AssetFuture in + let assetsDownloads = selectionContainer.selectedItems.map { cellViewModel -> AssetFuture in dispatchGroup.enter() return cellViewModel.download(onNext: { image in DispatchQueue.main.async { diff --git a/Sources/MosaiqueAssetsPicker/Views/AssetDetailCell.swift b/Sources/MosaiqueAssetsPicker/Views/AssetDetailCell.swift index 3286881..f6c777a 100755 --- a/Sources/MosaiqueAssetsPicker/Views/AssetDetailCell.swift +++ b/Sources/MosaiqueAssetsPicker/Views/AssetDetailCell.swift @@ -130,7 +130,7 @@ final class AssetDetailCell: UICollectionViewCell, AssetDetailCellBindable { func setDownloading(_ isDownloading: Bool) { if isDownloading { - let spinner = self.spinner ?? { + let spinner = spinner ?? { let spinner = UIActivityIndicatorView(style: .whiteLarge) self.spinner = spinner return spinner diff --git a/Sources/MosaiqueAssetsPicker/Views/GradientView.swift b/Sources/MosaiqueAssetsPicker/Views/GradientView.swift index 6ce796d..463bbda 100644 --- a/Sources/MosaiqueAssetsPicker/Views/GradientView.swift +++ b/Sources/MosaiqueAssetsPicker/Views/GradientView.swift @@ -16,7 +16,7 @@ final class GradiantView: UIView { required init(colors: [CGColor], startPoint: CGPoint, endPoint: CGPoint, type: CAGradientLayerType, locations: [NSNumber]?) { super.init(frame: .zero) - guard let layer = self.layer as? CAGradientLayer else { + guard let layer = layer as? CAGradientLayer else { assertionFailure("should be of CAGradientLayer") return } From 6e652a62b59cda5fcaab072ab66282e9b5b706dd Mon Sep 17 00:00:00 2001 From: Mikhail Akopov Date: Tue, 4 Oct 2022 19:17:15 +0300 Subject: [PATCH 3/3] Check formatting on PR or push to master --- .github/workflows/swiftformat.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/swiftformat.yml diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml new file mode 100644 index 0000000..ee960d0 --- /dev/null +++ b/.github/workflows/swiftformat.yml @@ -0,0 +1,23 @@ +name: swiftformat + +on: + push: + branches: ["master"] + + pull_request: + branches: ["master"] + +jobs: + swiftformat: + name: swiftformat + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install SwiftFormat + uses: Cyberbeni/install-swift-tool@v2 + with: + url: https://github.com/nicklockwood/SwiftFormat + version: 0.49.2 + - name: Check formatting + run: swiftformat --lint .