swiftlint autocorrect
This commit is contained in:
parent
c6a501b4cb
commit
dac1bba0cb
|
|
@ -0,0 +1,47 @@
|
|||
disabled_rules: # rule identifiers to exclude from running
|
||||
- todo
|
||||
# - colon
|
||||
# - comma
|
||||
# - control_statement
|
||||
- file_length
|
||||
- force_cast
|
||||
- force_try
|
||||
- function_body_length
|
||||
# - leading_whitespace
|
||||
- line_length
|
||||
- legacy_constructor
|
||||
- nesting
|
||||
# - opening_brace
|
||||
# - operator_whitespace
|
||||
# - return_arrow_whitespace
|
||||
# - statement_position
|
||||
# - todo
|
||||
# - trailing_newline
|
||||
# - trailing_semicolon
|
||||
# - trailing_whitespace
|
||||
- type_body_length
|
||||
- type_name
|
||||
- variable_name_max_length
|
||||
- variable_name_min_length
|
||||
- variable_name
|
||||
- valid_docs
|
||||
- function_parameter_count
|
||||
- cyclomatic_complexity
|
||||
excluded: # paths to ignore during linting.
|
||||
- Carthage
|
||||
- Pods
|
||||
- .git
|
||||
# parameterized rules can be customized from this configuration file
|
||||
line_length: 300 # default 100
|
||||
type_body_length:
|
||||
- 200 # warning default 200
|
||||
- 650 # error default 350
|
||||
function_body_length:
|
||||
- 80 # warning default 40
|
||||
- 250 # error default 100
|
||||
file_length:
|
||||
- 400 # warning default 400
|
||||
- 1300 # error default 1000
|
||||
variable_name_min_length:
|
||||
- 1 # warning default 3
|
||||
- 0 # error default 2
|
||||
|
|
@ -51,4 +51,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController
|
|||
func checkIfAuthorizedToAccessPhotos(_ handler: @escaping (_ isAuthorized: Bool) -> Void) {
|
||||
switch PHPhotoLibrary.authorizationStatus() {
|
||||
case .notDetermined:
|
||||
PHPhotoLibrary.requestAuthorization{ status in
|
||||
PHPhotoLibrary.requestAuthorization { status in
|
||||
switch status {
|
||||
case .authorized:
|
||||
handler(true)
|
||||
|
|
@ -120,7 +120,7 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController
|
|||
func showDisableToPickAssetsPicker() {
|
||||
let picker = NohanaImagePickerController()
|
||||
picker.delegate = self
|
||||
picker.canPickAsset = { (asset:Asset) -> Bool in
|
||||
picker.canPickAsset = { (asset: Asset) -> Bool in
|
||||
return asset.identifier % 2 == 0
|
||||
}
|
||||
present(picker, animated: true, completion: nil)
|
||||
|
|
@ -145,7 +145,7 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController
|
|||
picker.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
func nohanaImagePicker(_ picker: NohanaImagePickerController, didFinishPickingPhotoKitAssets pickedAssts :[PHAsset]) {
|
||||
func nohanaImagePicker(_ picker: NohanaImagePickerController, didFinishPickingPhotoKitAssets pickedAssts: [PHAsset]) {
|
||||
print("🐷Completed🙆\n\tpickedAssets = \(pickedAssts)")
|
||||
picker.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity
|
|||
view.backgroundColor = nohanaImagePickerController.config.color.background ?? .white
|
||||
title = nohanaImagePickerController.config.strings.albumListTitle ?? NSLocalizedString("albumlist.title", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: "")
|
||||
setUpToolbarItems()
|
||||
navigationController?.setToolbarHidden(nohanaImagePickerController.toolbarHidden ,animated: false)
|
||||
navigationController?.setToolbarHidden(nohanaImagePickerController.toolbarHidden, animated: false)
|
||||
}
|
||||
setUpEmptyIndicator()
|
||||
setUpActivityIndicator()
|
||||
|
|
@ -265,7 +265,7 @@ extension UIViewController {
|
|||
self.toolbarItems = [leftSpace, infoButton, rightSpace]
|
||||
}
|
||||
|
||||
func setToolbarTitle(_ nohanaImagePickerController:NohanaImagePickerController) {
|
||||
func setToolbarTitle(_ nohanaImagePickerController: NohanaImagePickerController) {
|
||||
let count: Int? = toolbarItems?.count
|
||||
guard count != nil && count! >= 2 else {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class AssetDetailCell: UICollectionViewCell, UIScrollViewDelegate {
|
|||
|
||||
@IBOutlet weak var imageViewHeightConstraint: NSLayoutConstraint!
|
||||
@IBOutlet weak var imageViewWidthConstraint: NSLayoutConstraint!
|
||||
let doubleTapGestureRecognizer :UITapGestureRecognizer = UITapGestureRecognizer()
|
||||
let doubleTapGestureRecognizer: UITapGestureRecognizer = UITapGestureRecognizer()
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class AssetDetailListViewController: AssetListViewController {
|
|||
self.title = ""
|
||||
}
|
||||
|
||||
func didChangeAssetDetailPage(_ indexPath:IndexPath) {
|
||||
func didChangeAssetDetailPage(_ indexPath: IndexPath) {
|
||||
guard let nohanaImagePickerController = nohanaImagePickerController else {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class AssetListViewController: UICollectionViewController {
|
|||
if UIInterfaceOrientationIsPortrait(UIApplication.shared.statusBarOrientation) {
|
||||
numberOfColumns = nohanaImagePickerController.numberOfColumnsInPortrait
|
||||
}
|
||||
let cellMargin:CGFloat = 2
|
||||
let cellMargin: CGFloat = 2
|
||||
let cellWidth = (view.frame.width - cellMargin * (CGFloat(numberOfColumns) - 1)) / CGFloat(numberOfColumns)
|
||||
return CGSize(width: cellWidth, height: cellWidth)
|
||||
}
|
||||
|
|
@ -155,9 +155,7 @@ class AssetListViewController: UICollectionViewController {
|
|||
|
||||
// MARK: - IBAction
|
||||
@IBAction func didPushDone(_ sender: AnyObject) {
|
||||
let pickedPhotoKitAssets = nohanaImagePickerController!.pickedAssetList.map{ ($0 as! PhotoKitAsset).originalAsset }
|
||||
let pickedPhotoKitAssets = nohanaImagePickerController!.pickedAssetList.map { ($0 as! PhotoKitAsset).originalAsset }
|
||||
nohanaImagePickerController!.delegate?.nohanaImagePicker(nohanaImagePickerController!, didFinishPickingPhotoKitAssets: pickedPhotoKitAssets )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public protocol EmptyIndicatable {
|
|||
|
||||
public extension EmptyIndicatable where Self: UIViewController {
|
||||
func updateVisibilityOfEmptyIndicator(_ emptyIndicator: UIView) {
|
||||
if isEmpty(){
|
||||
if isEmpty() {
|
||||
if !view.subviews.contains(emptyIndicator) {
|
||||
view.addSubview(emptyIndicator)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ extension Size {
|
|||
return CGRect(origin: origin, size: fromCell.frame.size)
|
||||
}
|
||||
|
||||
static func expandingAnimationToCellRect(_ fromVC: UIViewController, toSize:CGSize) -> CGRect {
|
||||
static func expandingAnimationToCellRect(_ fromVC: UIViewController, toSize: CGSize) -> CGRect {
|
||||
return AVMakeRect(aspectRatio: toSize, insideRect: Size.screenRectWithoutAppBar(fromVC))
|
||||
}
|
||||
}
|
||||
|
|
@ -77,4 +77,3 @@ class ExpandingAnimationController: NSObject, UIViewControllerAnimatedTransition
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
public protocol ItemList: Collection {
|
||||
associatedtype Item
|
||||
var title:String { get }
|
||||
var title: String { get }
|
||||
func update(_ handler:(() -> Void)?)
|
||||
subscript (index: Int) -> Item { get }
|
||||
}
|
||||
|
|
@ -28,8 +28,8 @@ extension ItemList {
|
|||
}
|
||||
|
||||
public protocol Asset {
|
||||
var identifier:Int { get }
|
||||
func image(targetSize:CGSize, handler: @escaping (ImageData?) -> Void)
|
||||
var identifier: Int { get }
|
||||
func image(targetSize: CGSize, handler: @escaping (ImageData?) -> Void)
|
||||
}
|
||||
|
||||
public struct ImageData {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public enum MediaType: Int {
|
|||
|
||||
@objc public protocol NohanaImagePickerControllerDelegate {
|
||||
func nohanaImagePickerDidCancel(_ picker: NohanaImagePickerController)
|
||||
func nohanaImagePicker(_ picker: NohanaImagePickerController, didFinishPickingPhotoKitAssets pickedAssts :[PHAsset])
|
||||
func nohanaImagePicker(_ picker: NohanaImagePickerController, didFinishPickingPhotoKitAssets pickedAssts: [PHAsset])
|
||||
@objc optional func nohanaImagePicker(_ picker: NohanaImagePickerController, willPickPhotoKitAsset asset: PHAsset, pickedAssetsCount: Int) -> Bool
|
||||
@objc optional func nohanaImagePicker(_ picker: NohanaImagePickerController, didPickPhotoKitAsset asset: PHAsset, pickedAssetsCount: Int)
|
||||
@objc optional func nohanaImagePicker(_ picker: NohanaImagePickerController, willDropPhotoKitAsset asset: PHAsset, pickedAssetsCount: Int) -> Bool
|
||||
|
|
@ -46,12 +46,12 @@ open class NohanaImagePickerController: UIViewController {
|
|||
open var shouldShowMoment: Bool = true
|
||||
open var shouldShowEmptyAlbum: Bool = false
|
||||
open var toolbarHidden: Bool = false
|
||||
open var canPickAsset = { (asset:Asset) -> Bool in
|
||||
open var canPickAsset = { (asset: Asset) -> Bool in
|
||||
return true
|
||||
}
|
||||
open var config: Config = Config()
|
||||
|
||||
lazy var assetBundle:Bundle = {
|
||||
lazy var assetBundle: Bundle = {
|
||||
let bundle = Bundle(for: type(of: self))
|
||||
if let path = bundle.path(forResource: "NohanaImagePicker", ofType: "bundle") {
|
||||
return Bundle(path: path)!
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import Photos
|
|||
|
||||
public class PhotoKitAlbumList: ItemList {
|
||||
|
||||
private var albumList:[Item] = []
|
||||
private var albumList: [Item] = []
|
||||
private let assetCollectionTypes: [PHAssetCollectionType]
|
||||
private let assetCollectionSubtypes: [PHAssetCollectionSubtype]
|
||||
private let mediaType: MediaType
|
||||
|
|
@ -41,7 +41,7 @@ public class PhotoKitAlbumList: ItemList {
|
|||
|
||||
public typealias Item = PhotoKitAssetList
|
||||
|
||||
open var title:String {
|
||||
open var title: String {
|
||||
return "PhotoKit"
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public class PhotoKitAlbumList: ItemList {
|
|||
}
|
||||
|
||||
self.albumList = []
|
||||
var tmpAlbumList:[Item] = []
|
||||
var tmpAlbumList: [Item] = []
|
||||
let isAssetCollectionSubtypeAny = self.assetCollectionSubtypes.contains(.any)
|
||||
for fetchResult in albumListFetchResult {
|
||||
fetchResult.enumerateObjects({ (album, index, stop) in
|
||||
|
|
@ -65,7 +65,7 @@ public class PhotoKitAlbumList: ItemList {
|
|||
})
|
||||
}
|
||||
if self.assetCollectionTypes == [.moment] {
|
||||
self.albumList = tmpAlbumList.sorted{ $0.date!.timeIntervalSince1970 < $1.date!.timeIntervalSince1970 }
|
||||
self.albumList = tmpAlbumList.sorted { $0.date!.timeIntervalSince1970 < $1.date!.timeIntervalSince1970 }
|
||||
} else {
|
||||
self.albumList = tmpAlbumList
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
import Photos
|
||||
|
||||
public class PhotoKitAsset :Asset {
|
||||
public class PhotoKitAsset: Asset {
|
||||
|
||||
let asset: PHAsset
|
||||
|
||||
|
|
@ -29,11 +29,11 @@ public class PhotoKitAsset :Asset {
|
|||
|
||||
// MARK: - Asset
|
||||
|
||||
public var identifier:Int {
|
||||
public var identifier: Int {
|
||||
return asset.localIdentifier.hash
|
||||
}
|
||||
|
||||
public func image(targetSize:CGSize, handler: @escaping (ImageData?) -> Void) {
|
||||
public func image(targetSize: CGSize, handler: @escaping (ImageData?) -> Void) {
|
||||
let option = PHImageRequestOptions()
|
||||
option.isNetworkAccessAllowed = true
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
import Photos
|
||||
|
||||
open class PhotoKitAssetList :ItemList {
|
||||
open class PhotoKitAssetList: ItemList {
|
||||
|
||||
fileprivate let mediaType: MediaType
|
||||
open let assetList: PHAssetCollection
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ class PickedAssetList: ItemList {
|
|||
}
|
||||
let assetsCountBeforePicking = self.count
|
||||
if asset is PhotoKitAsset {
|
||||
if let canPick = nohanaImagePickerController!.delegate?.nohanaImagePicker?(nohanaImagePickerController!, willPickPhotoKitAsset: (asset as! PhotoKitAsset).originalAsset, pickedAssetsCount: assetsCountBeforePicking)
|
||||
, !canPick {
|
||||
if let canPick = nohanaImagePickerController!.delegate?.nohanaImagePicker?(nohanaImagePickerController!, willPickPhotoKitAsset: (asset as! PhotoKitAsset).originalAsset, pickedAssetsCount: assetsCountBeforePicking), !canPick {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
@ -86,11 +85,11 @@ class PickedAssetList: ItemList {
|
|||
func drop(asset: Asset) -> Bool {
|
||||
let assetsCountBeforeDropping = self.count
|
||||
if asset is PhotoKitAsset {
|
||||
if let canDrop = nohanaImagePickerController!.delegate?.nohanaImagePicker?(nohanaImagePickerController!, willDropPhotoKitAsset: (asset as! PhotoKitAsset).originalAsset, pickedAssetsCount: assetsCountBeforeDropping) , !canDrop {
|
||||
if let canDrop = nohanaImagePickerController!.delegate?.nohanaImagePicker?(nohanaImagePickerController!, willDropPhotoKitAsset: (asset as! PhotoKitAsset).originalAsset, pickedAssetsCount: assetsCountBeforeDropping), !canDrop {
|
||||
return false
|
||||
}
|
||||
}
|
||||
assetlist = assetlist.filter{ $0.identifier != asset.identifier }
|
||||
assetlist = assetlist.filter { $0.identifier != asset.identifier }
|
||||
let assetsCountAfterDropping = self.count
|
||||
if asset is PhotoKitAsset {
|
||||
let originalAsset = (asset as! PhotoKitAsset).originalAsset
|
||||
|
|
@ -110,7 +109,7 @@ class PickedAssetList: ItemList {
|
|||
}
|
||||
|
||||
func isPicked(_ asset: Asset) -> Bool {
|
||||
return assetlist.contains{ $0.identifier == asset.identifier }
|
||||
return assetlist.contains { $0.identifier == asset.identifier }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue