Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
natsuk4ze committed Aug 11, 2023
1 parent b5f0180 commit fb164d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
flutter test integration_test/integration_test.dart
android:
needs: ios
needs: set-up
timeout-minutes: 60
runs-on: macos-latest
strategy:
Expand Down
34 changes: 16 additions & 18 deletions ios/Classes/GalPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class GalPlugin: NSObject, FlutterPlugin {
open { result(nil) }
case "hasAccess":
let args = call.arguments as! [String: Bool]
result(hasAccess(toAlbum: args["toAlbum"] as! Bool))
result(hasAccess(toAlbum: args["toAlbum"]!))
case "requestAccess":
let args = call.arguments as! [String: Bool]
let toAlbum = args["toAlbum"] as! Bool
let toAlbum = args["toAlbum"]!

hasAccess(toAlbum: toAlbum)
? result(true)
Expand Down Expand Up @@ -93,7 +93,7 @@ public class GalPlugin: NSObject, FlutterPlugin {
}
return
}
PHPhotoLibrary.shared().performChanges({ assetChangeRequest() }, completionHandler: completion)
PHPhotoLibrary.shared().performChanges({ _ = assetChangeRequest() }, completionHandler: completion)
}

private func getAlbum(album: String, completion: @escaping (PHAssetCollection?, Error?) -> Void) {
Expand Down Expand Up @@ -147,26 +147,24 @@ public class GalPlugin: NSObject, FlutterPlugin {
}

private func handleError(error: Error) -> FlutterError {
if let error = error as? NSError {
let message = error.localizedDescription
let details = Thread.callStackSymbols
let error = error as NSError
let message = error.localizedDescription
let details = Thread.callStackSymbols

switch PHErrorCode(rawValue: error.code) {
case .accessRestricted, .accessUserDenied:
return FlutterError(code: "ACCESS_DENIED", message: message, details: details)
switch PHErrorCode(rawValue: error.code) {
case .accessRestricted, .accessUserDenied:
return FlutterError(code: "ACCESS_DENIED", message: message, details: details)

case .identifierNotFound, .multipleIdentifiersFound, .requestNotSupportedForAsset,
.videoConversionFailed, .unsupportedVideoCodec:
return FlutterError(code: "NOT_SUPPORTED_FORMAT", message: message, details: details)
case .identifierNotFound, .multipleIdentifiersFound, .requestNotSupportedForAsset,
.videoConversionFailed, .unsupportedVideoCodec:
return FlutterError(code: "NOT_SUPPORTED_FORMAT", message: message, details: details)

case .notEnoughSpace:
return FlutterError(code: "NOT_ENOUGH_SPACE", message: message, details: details)
case .notEnoughSpace:
return FlutterError(code: "NOT_ENOUGH_SPACE", message: message, details: details)

default:
return FlutterError(code: "UNEXPECTED", message: message, details: details)
}
default:
return FlutterError(code: "UNEXPECTED", message: message, details: details)
}
return FlutterError(code: "UNEXPECTED", message: "Did not NSError.", details: nil)
}
}

Expand Down

0 comments on commit fb164d9

Please sign in to comment.