Ver Fonte

add codeformat(swiftformat)

wenweiwei há 3 anos atrás
pai
commit
c86632a7fb
27 ficheiros alterados com 370 adições e 255 exclusões
  1. 65 0
      .swiftformat
  2. 3 3
      BFCommonKit/Classes/BFCategorys/BFBundle+Ext.swift
  3. 12 12
      BFCommonKit/Classes/BFCategorys/BFColor+Ext.swift
  4. 9 8
      BFCommonKit/Classes/BFCategorys/BFNumber+Ext.swift
  5. 14 14
      BFCommonKit/Classes/BFCategorys/BFString+Ext.swift
  6. 44 49
      BFCommonKit/Classes/BFCategorys/BFUIImage+Ext.swift
  7. 2 1
      BFCommonKit/Classes/BFCategorys/Date+Ext.swift
  8. 5 5
      BFCommonKit/Classes/BFCategorys/NXFundation+Ext.swift
  9. 18 18
      BFCommonKit/Classes/BFConfig/BFConfig.swift
  10. 0 4
      BFCommonKit/Classes/BFEnv/PQRequestURLUtil.swift
  11. 4 3
      BFCommonKit/Classes/BFEnv/PQSingletonEnvUtil.swift
  12. 20 21
      BFCommonKit/Classes/BFModels/BFBaseModel.swift
  13. 14 14
      BFCommonKit/Classes/BFModels/PQLoginUserInfo.swift
  14. 18 18
      BFCommonKit/Classes/BFModels/PQReCreateModel.swift
  15. 5 5
      BFCommonKit/Classes/BFModels/PQUserInfoModel.swift
  16. 1 2
      BFCommonKit/Classes/BFProtocols/BFProtocols.swift
  17. 21 21
      BFCommonKit/Classes/BFUtility/PQCommonMethodUtil.swift
  18. 2 2
      BFCommonKit/Classes/BFUtility/PQConstant.swift
  19. 2 3
      BFCommonKit/Classes/BFUtility/PQCreateEmptyWAV.swift
  20. 12 12
      BFCommonKit/Classes/BFUtility/PQLZStringUtil.swift
  21. 4 4
      BFCommonKit/Classes/BFUtility/PQPHAssetVideoParaseUtil.swift
  22. 11 9
      BFCommonKit/Classes/BFUtility/PQSingletoMemoryUtil.swift
  23. 3 3
      BFCommonKit/Classes/BFUtility/PQVideoSnapshotUtil.swift
  24. 6 11
      Example/BFCommonKit/AppDelegate.swift
  25. 3 6
      Example/BFCommonKit/ViewController.swift
  26. 5 7
      Example/Tests/Tests.swift
  27. 67 0
      rules.swiftformat

+ 65 - 0
.swiftformat

@@ -0,0 +1,65 @@
+--allman false
+--assetliterals visual-width
+--beforemarks 
+--binarygrouping none
+--categorymark "MARK: %c"
+--classthreshold 0
+--closingparen balanced
+--commas always
+--conflictmarkers reject
+--decimalgrouping none
+--elseposition same-line
+--enumthreshold 0
+--exponentcase lowercase
+--exponentgrouping disabled
+--extensionacl on-extension
+--extensionlength 0
+--extensionmark "MARK: - %t + %c"
+--fractiongrouping disabled
+--fragment false
+--funcattributes preserve
+--groupedextension "MARK: %c"
+--guardelse auto
+--header ignore
+--hexgrouping 4,8
+--hexliteralcase uppercase
+--ifdef indent
+--importgrouping alphabetized
+--indent 4
+--indentcase false
+--lifecycle 
+--linebreaks lf
+--markextensions always
+--marktypes always
+--maxwidth none
+--modifierorder 
+--nevertrailing 
+--nospaceoperators ...,..<
+--nowrapoperators 
+--octalgrouping none
+--operatorfunc spaced
+--organizetypes class,enum,struct
+--patternlet hoist
+--ranges spaced
+--redundanttype inferred
+--self remove
+--selfrequired 
+--semicolons inline
+--shortoptionals always
+--smarttabs enabled
+--stripunusedargs closure-only
+--structthreshold 0
+--tabwidth unspecified
+--trailingclosures 
+--trimwhitespace always
+--typeattributes preserve
+--typemark "MARK: - %t"
+--varattributes preserve
+--voidtype void
+--wraparguments preserve
+--wrapcollections preserve
+--wrapconditions preserve
+--wrapparameters preserve
+--wrapreturntype preserve
+--xcodeindentation disabled
+--yodaswap always

+ 3 - 3
BFCommonKit/Classes/BFCategorys/BFBundle+Ext.swift

@@ -20,7 +20,7 @@ public extension Bundle {
         return Bundle(url: BF_mainbundle_URL())!
     }
 
-    private class func bundleURL(moduleName: String,isAssets: Bool = true) -> URL? {
+    private class func bundleURL(moduleName: String, isAssets: Bool = true) -> URL? {
         if isAssets {
             var bundleURL = Bundle.main.url(forResource: "Frameworks", withExtension: nil)
             bundleURL = bundleURL?.appendingPathComponent(moduleName).appendingPathExtension("framework").appendingPathComponent("\(moduleName)_Resources").appendingPathExtension("bundle")
@@ -30,8 +30,8 @@ public extension Bundle {
         }
     }
 
-    class func current(moduleName: String,isAssets: Bool = true) -> Bundle? {
-        guard let url = bundleURL(moduleName: moduleName,isAssets: isAssets) else {
+    class func current(moduleName: String, isAssets: Bool = true) -> Bundle? {
+        guard let url = bundleURL(moduleName: moduleName, isAssets: isAssets) else {
             return nil
         }
         return Bundle(url: url)

+ 12 - 12
BFCommonKit/Classes/BFCategorys/BFColor+Ext.swift

@@ -10,7 +10,7 @@ import Foundation
 import UIKit
 
 public extension UIColor {
-    public class func hexColor(hexadecimal: String, alpha:CGFloat = 1) -> UIColor {
+    class func hexColor(hexadecimal: String, alpha: CGFloat = 1) -> UIColor {
         var cstr = hexadecimal.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased() as NSString
         if cstr.length < 6 {
             return UIColor.clear
@@ -43,7 +43,7 @@ public extension UIColor {
         Scanner(string: bStr).scanHexInt32(&b)
         return UIColor(red: CGFloat(r) / 255.0, green: CGFloat(g) / 255.0, blue: CGFloat(b) / 255.0, alpha: alpha)
     }
-    
+
     // MARK: - hex (0x000000) -> UIColor
 
     ///
@@ -61,7 +61,7 @@ public extension UIColor {
     }
 
     private class func colorComponent(hex: String, start: Int, length: Int) -> CGFloat {
-        let subString = hex.sliceString(start ..< (start + length))
+        let subString = hex.sliceString(start..<(start + length))
         let fullHex = length == 2 ? subString : (subString + subString)
         var val: CUnsignedInt = 0
         Scanner(string: fullHex).scanHexInt32(&val)
@@ -101,14 +101,14 @@ public extension UIColor {
         getRed(&red, green: &green, blue: &blue, alpha: &alpha)
         return [Int(red * 255.0), Int(green * 255.0), Int(blue * 255.0), Int(alpha)]
     }
-    
+
     var rgbaf: [CGFloat] {
         var red: CGFloat = 0
         var green: CGFloat = 0
         var blue: CGFloat = 0
         var alpha: CGFloat = 0
         getRed(&red, green: &green, blue: &blue, alpha: &alpha)
-        return [ red, green, blue,alpha]
+        return [red, green, blue, alpha]
     }
 
     class func randomColor() -> UIColor {
@@ -118,18 +118,18 @@ public extension UIColor {
         let color = UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: 1.0)
         return color
     }
-    
-    func getColor(lightColor:UIColor = .white, darkColor:UIColor = .darkGray) -> UIColor{
+
+    func getColor(lightColor: UIColor = .white, darkColor: UIColor = .darkGray) -> UIColor {
         if #available(iOS 13.0, *) {
             return UIColor(dynamicProvider: { traitCollection in
-                if (traitCollection.userInterfaceStyle == .dark) {
-                    return darkColor;
-                }else {
-                    return lightColor;
+                if traitCollection.userInterfaceStyle == .dark {
+                    return darkColor
+                } else {
+                    return lightColor
                 }
             })
         } else {
-            return lightColor;
+            return lightColor
         }
     }
 }

+ 9 - 8
BFCommonKit/Classes/BFCategorys/BFNumber+Ext.swift

@@ -48,25 +48,26 @@ public extension Int {
 
 // MARK: - Float double类型扩展
 
-extension Float {
+public extension Float {
     /// 准确的小数尾截取 - 没有进位
     /*
      // 11.999003  -> 12.0
      var pp = 11.999003
      String(format: "%.1f", pp)  这个方法会进行四舍五入
      */
-    public func decimalString(_ base: Self = 1) -> String {
-       return "\(self.decimalNumber(base))"
+    func decimalString(_ base: Self = 1) -> String {
+        return "\(decimalNumber(base))"
     }
-    public func decimalNumber(_ base: Self = 1) -> Float {
+
+    func decimalNumber(_ base: Self = 1) -> Float {
         let tempCount: Self = pow(10, base)
-        let temp = self*tempCount
-        
+        let temp = self * tempCount
+
         let target = Self(Int(temp))
-        let stepone = target/tempCount
+        let stepone = target / tempCount
         if stepone.truncatingRemainder(dividingBy: 1) == 0 {
             return Float(String(format: "%.0f", stepone)) ?? 0.0
-        }else{
+        } else {
             return stepone
         }
     }

+ 14 - 14
BFCommonKit/Classes/BFCategorys/BFString+Ext.swift

@@ -19,7 +19,7 @@ public extension String {
         let result = UnsafeMutablePointer<CUnsignedChar>.allocate(capacity: digestLen)
         CC_MD5(str!, strLen, result)
         let hash = NSMutableString()
-        for i in 0 ..< digestLen {
+        for i in 0..<digestLen {
             hash.appendFormat("%02x", result[i])
         }
         result.deallocate()
@@ -136,12 +136,12 @@ public extension String {
     internal var isContainsEmoji: Bool {
         for scalar in unicodeScalars {
             switch scalar.value {
-            case 0x1F600 ... 0x1F64F, // Emoticons
-                 0x1F300 ... 0x1F5FF, // Misc Symbols and Pictographs
-                 0x1F680 ... 0x1F6FF, // Transport and Map
-                 0x2600 ... 0x26FF, // Misc symbols
-                 0x2700 ... 0x27BF, // Dingbats
-                 0xFE00 ... 0xFE0F: // Variation Selectors
+            case 0x1F600...0x1F64F, // Emoticons
+                 0x1F300...0x1F5FF, // Misc Symbols and Pictographs
+                 0x1F680...0x1F6FF, // Transport and Map
+                 0x2600...0x26FF, // Misc symbols
+                 0x2700...0x27BF, // Dingbats
+                 0xFE00...0xFE0F: // Variation Selectors
                 return true
             default:
                 continue
@@ -155,12 +155,12 @@ public extension String {
         for scalar in unicodeScalars {
             switch scalar.value {
             case
-                0x00A0 ... 0x00AF,
-                0x2030 ... 0x204F,
-                0x2120 ... 0x213F,
-                0x2190 ... 0x21AF,
-                0x2310 ... 0x329F,
-                0x1F000 ... 0x1F9CF:
+                0x00A0...0x00AF,
+                0x2030...0x204F,
+                0x2120...0x213F,
+                0x2190...0x21AF,
+                0x2310...0x329F,
+                0x1F000...0x1F9CF:
                 return true
             default:
                 continue
@@ -180,7 +180,7 @@ public extension String {
         if !isMatch {
             let other = "➋➌➍➎➏➐➑➒"
             let len = str.count
-            for i in 0 ..< len {
+            for i in 0..<len {
                 let tmpStr = str as NSString
                 let tmpOther = other as NSString
                 let c = tmpStr.character(at: i)

+ 44 - 49
BFCommonKit/Classes/BFCategorys/BFUIImage+Ext.swift

@@ -9,7 +9,7 @@
 import Foundation
 
 /// 滑动方向
-public  enum  moveDirection {
+public enum moveDirection {
     case moveDirectionNormal
     case moveDirectionUp
     case moveDirectionDown
@@ -20,48 +20,45 @@ public  enum  moveDirection {
 public extension UIImage {
     // 从BFframwork bundle 中取图片
     static func mc_loadImage(_ imageName: String, from bundleName: String, in podName: String) -> UIImage? {
-            
-            var associateBundleURL = Bundle.main.url(forResource: "Frameworks", withExtension: nil)
-            associateBundleURL = associateBundleURL?.appendingPathComponent(podName)
-            associateBundleURL = associateBundleURL?.appendingPathExtension("framework")
-            
-            
-            if associateBundleURL == nil {
+        var associateBundleURL = Bundle.main.url(forResource: "Frameworks", withExtension: nil)
+        associateBundleURL = associateBundleURL?.appendingPathComponent(podName)
+        associateBundleURL = associateBundleURL?.appendingPathExtension("framework")
+
+        if associateBundleURL == nil {
+            print("获取bundle失败")
+            return nil
+        }
+
+        let associateBunle = Bundle(url: associateBundleURL!)
+        associateBundleURL = associateBunle?.url(forResource: bundleName, withExtension: "bundle")
+
+        if associateBundleURL != nil {
+            let bundle = Bundle(url: associateBundleURL!)
+            let scale = Int(UIScreen.main.scale)
+
+            // 适配2x还是3x图片
+            let name = imageName + "@" + String(scale) + "x"
+            let path = bundle?.path(forResource: name, ofType: "png")
+
+            if path == nil {
                 print("获取bundle失败")
                 return nil
             }
-            
-            let associateBunle = Bundle.init(url: associateBundleURL!)
-            associateBundleURL = associateBunle?.url(forResource: bundleName, withExtension: "bundle")
-            
-            if associateBundleURL != nil {
-                let bundle = Bundle.init(url: associateBundleURL!)
-                let scale = Int(UIScreen.main.scale)
-                
-                // 适配2x还是3x图片
-                let name = imageName + "@" + String(scale) + "x"
-                let path = bundle?.path(forResource: name, ofType: "png")
-                
-                if path == nil {
-                    print("获取bundle失败")
-                    return nil
-                }
-                let image1 = UIImage.init(contentsOfFile: path!)
-                return image1
+            let image1 = UIImage(contentsOfFile: path!)
+            return image1
 
-            } else {
-                return nil
-            }
+        } else {
+            return nil
         }
-    
-    
+    }
+
     func BF_Image(named: String) -> UIImage {
         let image: UIImage = UIImage(named: named, in: Bundle().BF_mainbundle(), compatibleWith: nil) ?? UIImage()
         return image
     }
 
-    class func moduleImage(named: String, moduleName: String,isAssets:Bool = true) -> UIImage? {
-        let image: UIImage? = UIImage(named: named, in: Bundle.current(moduleName: moduleName,isAssets: isAssets), compatibleWith: nil)
+    class func moduleImage(named: String, moduleName: String, isAssets: Bool = true) -> UIImage? {
+        let image: UIImage? = UIImage(named: named, in: Bundle.current(moduleName: moduleName, isAssets: isAssets), compatibleWith: nil)
         return image
     }
 
@@ -167,9 +164,8 @@ public extension UIImage {
         UIGraphicsEndImageContext()
         return image
     }
-    
-    func nx_scaleWithMaxLength(maxLength: CGFloat,completion: @escaping ( _ image: UIImage) -> Void)  {
-        
+
+    func nx_scaleWithMaxLength(maxLength: CGFloat, completion: @escaping (_ image: UIImage) -> Void) {
         var maxWidth: CGFloat = maxLength
         var maxHeight: CGFloat = maxLength
 
@@ -185,9 +181,9 @@ public extension UIImage {
                 maxWidth = size.width * imageScale
             }
         }
-       self.processImage(image: self, size:  CGSize(width: maxWidth, height: maxHeight)) { newImage in
+        processImage(image: self, size: CGSize(width: maxWidth, height: maxHeight)) { newImage in
             completion(newImage)
-       }
+        }
     }
 
     /// 按照最短边缩放  add by ak
@@ -216,8 +212,8 @@ public extension UIImage {
 
         return self
     }
-    
-    func processImage(image: UIImage, size: CGSize,completion: @escaping ( _ image: UIImage) -> Void) {
+
+    func processImage(image: UIImage, size: CGSize, completion: @escaping (_ image: UIImage) -> Void) {
         DispatchQueue.global().async {
             var width: CGFloat = CGFloat(image.cgImage?.width ?? 0)
             var height: CGFloat = CGFloat(image.cgImage?.height ?? 0)
@@ -253,12 +249,11 @@ public extension UIImage {
 
             // 从当前context中创建一个改变大小后的图片
             let scaledImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
-            
+
             // 使当前的context出堆栈
             UIGraphicsEndImageContext()
             completion(scaledImage)
         }
-     
     }
 
     /// 缩放到指定大小 add by ak
@@ -298,10 +293,10 @@ public extension UIImage {
 
         // 从当前context中创建一个改变大小后的图片
         let scaledImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
-        
+
         // 使当前的context出堆栈
         UIGraphicsEndImageContext()
-        
+
         // 返回新的改变大小后的图片
         return scaledImage
     }
@@ -347,13 +342,13 @@ public extension UIImage {
         UIGraphicsEndImageContext()
         return tintedImage
     }
-    
+
     /// 保存图片文件到指定目录, 如果目录已经存在会先删除老文件
     /// - Parameters:
     ///   - currentImage: 图片数据
     ///   - persent: 质量
     ///   - outFilePath: 输出目录
-    class func saveImage(currentImage: UIImage,outFilePath: String) {
+    class func saveImage(currentImage: UIImage, outFilePath: String) {
         // 文件存在先删除老文件
         if FileManager.default.fileExists(atPath: outFilePath) {
             do {
@@ -362,13 +357,13 @@ public extension UIImage {
                 BFLog(message: "删除文件出错 == \(error) \(outFilePath)")
             }
         }
-        
+
         if let imageData = currentImage.pngData() {
             try? imageData.write(to: URL(fileURLWithPath: outFilePath))
             print("保存图片成功到:filePath=\(outFilePath)")
         }
     }
-    
+
     convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) {
         let rect = CGRect(origin: .zero, size: size)
         UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0)
@@ -376,7 +371,7 @@ public extension UIImage {
         UIRectFill(rect)
         let image = UIGraphicsGetImageFromCurrentImageContext()
         UIGraphicsEndImageContext()
-        
+
         guard let cgImage = image?.cgImage else { return nil }
         self.init(cgImage: cgImage)
     }

+ 2 - 1
BFCommonKit/Classes/BFCategorys/Date+Ext.swift

@@ -7,7 +7,8 @@
 
 import Foundation
 
-//MARK: 转换为时间格式
+// MARK: 转换为时间格式
+
 public extension Double {
     /// 时长转化为分秒 62'52"
     /// - Returns: <#description#>

+ 5 - 5
BFCommonKit/Classes/BFCategorys/NXFundation+Ext.swift

@@ -68,7 +68,7 @@ public extension String {
         guard let end_Index = validEndIndex(original: index) else {
             return self
         }
-        return String(self[startIndex ..< end_Index])
+        return String(self[startIndex..<end_Index])
     }
 
     ///
@@ -76,7 +76,7 @@ public extension String {
         guard let start_index = validStartIndex(original: index) else {
             return self
         }
-        return String(self[start_index ..< endIndex])
+        return String(self[start_index..<endIndex])
     }
 
     ///
@@ -88,7 +88,7 @@ public extension String {
         else {
             return ""
         }
-        return String(self[startIndex ..< endIndex])
+        return String(self[startIndex..<endIndex])
     }
 
     ///
@@ -101,9 +101,9 @@ public extension String {
             return ""
         }
         if endIndex.encodedOffset <= end_Index.encodedOffset {
-            return String(self[start_Index ..< endIndex])
+            return String(self[start_Index..<endIndex])
         }
-        return String(self[start_Index ... end_Index])
+        return String(self[start_Index...end_Index])
     }
 
     private func validIndex(original: Int) -> String.Index {

+ 18 - 18
BFCommonKit/Classes/BFConfig/BFConfig.swift

@@ -50,31 +50,31 @@ public class BFConfig: NSObject {
     // 裁剪主题色
     public var hiddenMusicMask: Bool = true
     public var otherTintColor: UIColor = UIColor(red: 242.0 / 255.0, green: 242.0 / 255.0, blue: 242.0 / 255.0, alpha: 1)
-    
-    //划块使用的图片名 add by ak
+
+    // 划块使用的图片名 add by ak
     public var silderPinUsedImageName = "sliderTHBPin"
-    //闪音卡点编辑区未选择中状态颜色 add by ak
-    public var pointEditNamalBackgroundColor = UIColor.init(red: 249 / 255, green: 249 / 255, blue: 249 / 255, alpha: 1)
-    
-    //三个模式 btn 高亮和默认图的文件名
+    // 闪音卡点编辑区未选择中状态颜色 add by ak
+    public var pointEditNamalBackgroundColor = UIColor(red: 249 / 255, green: 249 / 255, blue: 249 / 255, alpha: 1)
+
+    // 三个模式 btn 高亮和默认图的文件名
     public var onlyMusicBtnImage_N = "onlyMusic_n"
     public var onlyMusicBtnImage_H = "onlyMusic_h"
     public var jumpPointBtnImage_N = "jumpPoint_n"
     public var jumpPointBtnImage_H = "jumpPoint_h"
     public var speedStuckBtnImage_N = "speedstuck_n"
     public var speedStuckBtnImage_H = "speedstuck_h"
-    
-    //add by ak 保存到的系统相册是否带水印+片尾,要求票圈视频要带水印, 乐活圈不带水印
-    public var enableWatermarkMovie:Bool = true
-    
-    //闪音卡点发布分享朋友圈使用图片名
+
+    // add by ak 保存到的系统相册是否带水印+片尾,要求票圈视频要带水印, 乐活圈不带水印
+    public var enableWatermarkMovie: Bool = true
+
+    // 闪音卡点发布分享朋友圈使用图片名
     public var shareFriendBtnImage = "reCreate_opration_friend"
-    //从系统相册选择图片名
+    // 从系统相册选择图片名
     public var editCoverimageSelectImage = "editCoverimageSelect"
-    //选择对勾图片名
+    // 选择对勾图片名
     public var editCoverimageSelectedImage = "editCoverimageSelected"
-    //系统相册背景色
-    public var editCoverimageSelectedbackgroundColor:UIColor = .white
+    // 系统相册背景色
+    public var editCoverimageSelectedbackgroundColor: UIColor = .white
     // 微信登陆信息
 //    public var appInfo: WXApiInfo?
     // 渠道
@@ -91,10 +91,10 @@ public class BFConfig: NSObject {
     public var appId: String = "1570572849"
     /// 腾讯兔小巢反馈 AppId 票圈视频:275642     乐活圈:351068
     public var txFeedbackAppId: String = "351068"
-    
+
     // 是否可打印 LOG
     public var enableBFLog: Bool = false
-    
+
     // 业务需求-先下沉
     public var sessionId: String = ""
     public var subSessionId: String?
@@ -102,7 +102,7 @@ public class BFConfig: NSObject {
     public var token: String?
     public var loginUid: String?
     public var uid: String?
-    
+
     override private init() {
         super.init()
     }

+ 0 - 4
BFCommonKit/Classes/BFEnv/PQRequestURLUtil.swift

@@ -23,7 +23,6 @@ public let onlineMessageApi = "https://messageapi.piaoquantv.com/"
 // 票圈Api-线上环境
 public let onlinePQTvApi = "https://api.piaoquantv.com/"
 
-
 // 票圈视频主域名-预发布环境
 public let preLongvideoapi = "https://prespeed.piaoquantv.com/longvideoapi/"
 // 票圈视频域名(热榜)-预发布环境
@@ -410,7 +409,6 @@ public let feedbackUrl = "https://support.qq.com/product/"
 // 意见反馈主页 https://support.qq.com/embed/phone/\(BFConfig.shared.txFeedbackAppId)
 public let feedbackPageUrl = "https://support.qq.com/embed/phone/"
 
-
 // ***************** 激励相关地址 **********************//
 
 public let applyCheckUrl = "incentive/creator/applyCheck"
@@ -424,7 +422,6 @@ public let invitedCheckUrl = "incentive/sharer/invitedCheck"
 // 是否已无有效分享
 public let invitedShareStatusUrl = "incentive/sharer/shareCheck"
 
-
 // ***************** 评论相关地址 **********************//
 
 // 评论列表
@@ -442,7 +439,6 @@ public let commentDeleteUrl = "comment/delete"
 // 评论举报
 public let commentReportUrl = "comment/report"
 
-
 // ***************** 话题相关地址 **********************//
 public let communityInitUrl = "community/init/feed"
 // 首页推荐Feed流

+ 4 - 3
BFCommonKit/Classes/BFEnv/PQSingletonEnvUtil.swift

@@ -25,7 +25,7 @@ public class PQENVUtil {
         return ENVMode(rawValue: enStr)!
     }
 
-     static public let shared: PQENVUtil = {
+    public static let shared: PQENVUtil = {
         let instance = PQENVUtil()
         // setup code
 
@@ -33,7 +33,7 @@ public class PQENVUtil {
     }()
 
     // 票圈视频主域名
-   public var longvideoapi: String {
+    public var longvideoapi: String {
         switch envMode {
         case .ENVModeTest:
             return testLongvideoapi
@@ -47,7 +47,7 @@ public class PQENVUtil {
     }
 
     // 票圈视频域名(热榜)
-   public var distribution: String {
+    public var distribution: String {
         switch envMode {
         case .ENVModeTest:
             return testDistributionApi
@@ -109,6 +109,7 @@ public class PQENVUtil {
             return onlineMessageApi
         }
     }
+
     // 票圈Api域名
     public var pqTvApi: String {
         switch envMode {

+ 20 - 21
BFCommonKit/Classes/BFModels/BFBaseModel.swift

@@ -6,32 +6,32 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import RealmSwift
+import UIKit
 
 open class BFBaseModel: Object {
-    @objc dynamic public var uniqueId: String? // 唯一ID
-    @objc dynamic public var videoId: Int = 0 // 视频ID
-    @objc dynamic public var eventId: String? // 事件ID
-    @objc dynamic public var title: String? // 标题
-    @objc dynamic public var attributedTitle: NSMutableAttributedString? // 富文本标题
-    @objc dynamic public var summary: String? // 描述
-    @objc dynamic public var imageUrl: String = "" // 图片地址
-    @objc dynamic public var selectedImage: String = "" // 图片地址
-    @objc dynamic public var isSelected: Bool = false
-    @objc dynamic public var recommendLogVO: String? // 推荐日志对象
-    @objc dynamic public var abInfoData: String? // AB
-    @objc dynamic public var pageCategoryId: Int = 0 // 页面分类ID
-    @objc dynamic public var version: String = versionName // 版本号
-    @objc dynamic public var mid = getMachineCode() // 设备ID
-    @objc dynamic public var date: Int = 0 // 当前时间戳  CGFloat(Date.init().timeIntervalSince1970) * 1000
-    @objc dynamic public var itemWidth: Float = 0 // cell宽
-    @objc dynamic public var primaryKeys: String? // 区分存储唯一值
-    override class public func primaryKey() -> String? {
+    @objc public dynamic var uniqueId: String? // 唯一ID
+    @objc public dynamic var videoId: Int = 0 // 视频ID
+    @objc public dynamic var eventId: String? // 事件ID
+    @objc public dynamic var title: String? // 标题
+    @objc public dynamic var attributedTitle: NSMutableAttributedString? // 富文本标题
+    @objc public dynamic var summary: String? // 描述
+    @objc public dynamic var imageUrl: String = "" // 图片地址
+    @objc public dynamic var selectedImage: String = "" // 图片地址
+    @objc public dynamic var isSelected: Bool = false
+    @objc public dynamic var recommendLogVO: String? // 推荐日志对象
+    @objc public dynamic var abInfoData: String? // AB
+    @objc public dynamic var pageCategoryId: Int = 0 // 页面分类ID
+    @objc public dynamic var version: String = versionName // 版本号
+    @objc public dynamic var mid = getMachineCode() // 设备ID
+    @objc public dynamic var date: Int = 0 // 当前时间戳  CGFloat(Date.init().timeIntervalSince1970) * 1000
+    @objc public dynamic var itemWidth: Float = 0 // cell宽
+    @objc public dynamic var primaryKeys: String? // 区分存储唯一值
+    override public class func primaryKey() -> String? {
         return "uniqueId"
     }
 
-    public override required  init() {
+    override public required init() {
         super.init()
         uniqueId = getUniqueId(desc: "uniqueId")
     }
@@ -110,4 +110,3 @@ open class BFBaseModel: Object {
         }
     }
 }
-

+ 14 - 14
BFCommonKit/Classes/BFModels/PQLoginUserInfo.swift

@@ -6,35 +6,35 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
+import UIKit
 
 // MARK: - 登录用户信息
 
 /// 登录用户信息s
 public class BFLoginUserInfo: NSObject {
-    static public let shared = BFLoginUserInfo()
+    public static let shared = BFLoginUserInfo()
     public var uid: String = "" // 账号
-    public  var userCode: String = "" // 账号
+    public var userCode: String = "" // 账号
     public var accessToken: String = "" // token
     public var avatarUrl: String = "" // 头像
     public var city: String = "" // 城市
     public var province: String = "" // 省市
-    public  var country: String = "" // 国家
-    public  var phoneNumber: String = "" // 电话
+    public var country: String = "" // 国家
+    public var phoneNumber: String = "" // 电话
     public var openId: String = "" // 微信openId
     public var nickName: String = "" // 昵称
     public var gender: String = "" // 性别
     public var expiredTime: String = "" // 过期时间
     public var videos: String = "0" // 视频数
-    public  var idols: String = "0" // 关注数
+    public var idols: String = "0" // 关注数
     public var fans: String = "0" // 粉丝数
     public var otherSubscribes: String = "0" // 别人订阅我的数量
-    public  var userStatus: String = "1" // 1有效,2 已删除,3 已屏蔽,4 敏感
+    public var userStatus: String = "1" // 1有效,2 已删除,3 已屏蔽,4 敏感
     public var isVirtualUser: Bool = false // 是否是虚拟账号
-    public  var mid = getMachineCode() // 设备ID
+    public var mid = getMachineCode() // 设备ID
 
-    @objc  public  func toString() -> String {
+    @objc public func toString() -> String {
         let json: [String: Any] = [
             "accessToken": accessToken,
             "avatarUrl": avatarUrl,
@@ -81,7 +81,7 @@ public class BFLoginUserInfo: NSObject {
         }
     }
 
-    @objc  public  func resetData(isClear: Bool) {
+    @objc public func resetData(isClear: Bool) {
         if isClear {
             UserDefaults.standard.removeObject(forKey: cUserInfoStorageKey)
             UserDefaults.standard.removeObject(forKey: cMineVideos)
@@ -116,7 +116,7 @@ public class BFLoginUserInfo: NSObject {
         updateData(userInfo: userInfo)
     }
 
-    public  func updateData(userInfo: [String: Any]?) {
+    public func updateData(userInfo: [String: Any]?) {
         if userInfo != nil, userInfo?.count ?? 0 > 0 {
             accessToken = "\(userInfo?["accessToken"] ?? "")"
             if userInfo?.keys.contains("token") ?? false {
@@ -168,15 +168,15 @@ public class BFLoginUserInfo: NSObject {
         }
     }
 
-    public  func isLogin() -> Bool {
+    public func isLogin() -> Bool {
         return accessToken.count > 0
     }
 
-    public override func copy() -> Any {
+    override public func copy() -> Any {
         return self
     }
 
-    public override func mutableCopy() -> Any {
+    override public func mutableCopy() -> Any {
         return self
     }
 }

+ 18 - 18
BFCommonKit/Classes/BFModels/PQReCreateModel.swift

@@ -10,28 +10,28 @@ import RealmSwift
 import UIKit
 
 public class PQReCreateModel: Object {
-    @objc dynamic public var canReproduce: Int = 0 // 是否可以被再创作,1:是,0:否
-    @objc dynamic public var draftboxId: String? // 草稿ID
-    @objc dynamic public var parentProjectId: String? // 父项目ID
-    @objc dynamic public var rootProjectId: String? // 根项目ID
-    @objc dynamic public var projectId: String? // 项目ID
-    @objc dynamic public var projectLinkUrl: String? // 项目链接
-    @objc dynamic public var reProduceCount: Int = 0 // 被再创作次数
-    @objc dynamic public var reProduceVideoFlag: Int = 0 //  再创作视频标记,1:是,0:否
-    @objc dynamic public var videoId: String? // 视频id
-    @objc dynamic public var parentVideoId: String? // 父视频id
-    @objc dynamic public var rootVideoId: String? // 根视频id
-    @objc dynamic public var rhythmMusicFlag: Int = 0 // 是否有卡点音乐标记 1:是,0:否
-    @objc dynamic public var rhythmMusicName: String? // 卡点音乐歌名
+    @objc public dynamic var canReproduce: Int = 0 // 是否可以被再创作,1:是,0:否
+    @objc public dynamic var draftboxId: String? // 草稿ID
+    @objc public dynamic var parentProjectId: String? // 父项目ID
+    @objc public dynamic var rootProjectId: String? // 根项目ID
+    @objc public dynamic var projectId: String? // 项目ID
+    @objc public dynamic var projectLinkUrl: String? // 项目链接
+    @objc public dynamic var reProduceCount: Int = 0 // 被再创作次数
+    @objc public dynamic var reProduceVideoFlag: Int = 0 //  再创作视频标记,1:是,0:否
+    @objc public dynamic var videoId: String? // 视频id
+    @objc public dynamic var parentVideoId: String? // 父视频id
+    @objc public dynamic var rootVideoId: String? // 根视频id
+    @objc public dynamic var rhythmMusicFlag: Int = 0 // 是否有卡点音乐标记 1:是,0:否
+    @objc public dynamic var rhythmMusicName: String? // 卡点音乐歌名
     var rhythmMusicNameWidth: CGFloat = 0 // 卡点音乐显示宽度
-    
+
     // add by ak 卡点模式(1:跳跃卡点,2:快慢速,3:仅配乐)
-    @objc dynamic public var rhythmMode:Int = 0
+    @objc public dynamic var rhythmMode: Int = 0
     override public required init() {
         super.init()
     }
 
-   public init(jsonDict: [String: Any]) {
+    public init(jsonDict: [String: Any]) {
         super.init()
         if jsonDict.keys.contains("canReproduce") {
             canReproduce = Int("\(jsonDict["canReproduce"] ?? "0")") ?? 0
@@ -57,8 +57,8 @@ public class PQReCreateModel: Object {
         if jsonDict.keys.contains("reProduceVideoFlag") {
             reProduceVideoFlag = Int("\(jsonDict["reProduceVideoFlag"] ?? "0")") ?? 0
         }
-        
-        if jsonDict.keys.contains("rhythmMode"){
+
+        if jsonDict.keys.contains("rhythmMode") {
             rhythmMode = Int("\(jsonDict["rhythmMode"] ?? "0")") ?? 0
         }
         if jsonDict.keys.contains("parentVideoId"), "\(jsonDict["parentVideoId"] ?? "")" != "<null>" {

+ 5 - 5
BFCommonKit/Classes/BFModels/PQUserInfoModel.swift

@@ -6,11 +6,11 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
+import UIKit
 
 open class PQUserInfoModel: BFBaseModel {
-    public  var avatarUrl: String? // 头像地址
+    public var avatarUrl: String? // 头像地址
     public var backgroundImage: String? // 背景图
 
     public var bothFollow: Bool = false // 是否相互关注
@@ -50,11 +50,11 @@ open class PQUserInfoModel: BFBaseModel {
     public var isBanned: Bool = false // 是否被拉黑
     public var tab_pageType: TAB_PAGETYPE = .TAB_PAGETYPE_NORMAL // 0-推荐 1-关注
 
-    required public init() {
+    public required init() {
         super.init()
     }
 
-    public override init(jsonDict: [String: Any]) {
+    override public init(jsonDict: [String: Any]) {
         super.init()
         if jsonDict.keys.contains("avatarUrl") {
             avatarUrl = "\(jsonDict["avatarUrl"] ?? "")"
@@ -162,7 +162,7 @@ open class PQUserInfoModel: BFBaseModel {
 
     /// 创建虚拟用户数据
     /// - Parameter virtual: <#virtual description#>
-   public init(avatarIcon: String?, userName: String?) {
+    public init(avatarIcon: String?, userName: String?) {
         super.init()
         avatarUrl = avatarIcon
         nickName = userName

+ 1 - 2
BFCommonKit/Classes/BFProtocols/BFProtocols.swift

@@ -113,9 +113,8 @@ public protocol BFVideoItemProtocol {
     // 发布视频来源类型
     var videoFromScene: videoFromScene { get set }
     // extParams: 额外参数-传入发布页 - 主要中秋红包塞活动使用
-    var extParams:String { get set }
+    var extParams: String { get set }
     // 话题信息
     var topicData: [String: Any]? { get set }
     var uplpadImage: UIImage? { get set } // 上传的图片封面
 }
-

+ 21 - 21
BFCommonKit/Classes/BFUtility/PQCommonMethodUtil.swift

@@ -14,7 +14,7 @@ import Kingfisher
 import KingfisherWebP
 import Photos
 import Toast_Swift
-//import RealmSwift
+// import RealmSwift
 import UIKit
 
 /// Home文件地址
@@ -100,17 +100,17 @@ public func bf_getCurrentViewController() -> UIViewController? {
     if currentVC == nil {
         return nil
     }
-    
+
     let runloopFind = true
     while runloopFind {
         if let vc = currentVC!.presentedViewController {
             currentVC = vc
-        }else {
+        } else {
             if currentVC is UINavigationController {
                 currentVC = (currentVC as! UINavigationController).visibleViewController
-            }else if currentVC is UITabBarController {
+            } else if currentVC is UITabBarController {
                 currentVC = (currentVC as! UITabBarController).selectedViewController
-            }else {
+            } else {
                 break
             }
         }
@@ -122,16 +122,16 @@ public func bf_getCurrentViewController() -> UIViewController? {
    type = 1 : 胡志强
    type = 2 :王成
    type = 3 : 文伟伟
- 
+
  */
-public func BFLog<T>( _ type : Int = 0, _ file:String = #file, _ line:Int = #line, message: T) {
+public func BFLog<T>(_: Int = 0, _ file: String = #file, _ line: Int = #line, message: T) {
 //    if type == 0{
-////        BuglyLog.level(.warn, logs: msg)
+    ////        BuglyLog.level(.warn, logs: msg)
     let dateFmt = DateFormatter()
     let msg = "\(file) (L:\(line)) \(message)"
-        print("\(dateFmt.string(from: Date())) \(msg)")
+    print("\(dateFmt.string(from: Date())) \(msg)")
 //    }
-#if DEBUG
+    #if DEBUG
 //    let dateFmt = DateFormatter()
 //    dateFmt.dateFormat = "HH:mm:ss:SSSS"
 //    let file = (file as NSString).lastPathComponent;
@@ -144,7 +144,7 @@ public func BFLog<T>( _ type : Int = 0, _ file:String = #file, _ line:Int = #lin
 //        print("ww-\(dateFmt.string(from: Date())) \(msg)");
 //     }
 //
-#endif
+    #endif
 }
 
 // MARK: 获取公共参数
@@ -416,7 +416,7 @@ public func getMachineCode() -> String {
 ///   - msg: <#msg description#>
 /// - Returns: <#description#>
 public func cShowHUB(superView: UIView?, msg: String?) {
-    var sty : ToastStyle = ToastManager.shared.style
+    var sty: ToastStyle = ToastManager.shared.style
     sty.messageAlignment = .center
     DispatchQueue.main.async {
         if superView == nil {
@@ -429,7 +429,7 @@ public func cShowHUB(superView: UIView?, msg: String?) {
             if msg == nil {
                 superView!.makeToastActivity(.center)
             } else {
-                superView!.makeToast(msg, duration: 3.0, position: .center,style: sty)
+                superView!.makeToast(msg, duration: 3.0, position: .center, style: sty)
             }
         }
     }
@@ -671,10 +671,10 @@ public func timeIntervalToDateString(timeInterval: TimeInterval) -> String {
 }
 
 public func updateTimeToCurrenTime(timeInterval: TimeInterval) -> String {
-      //获取当前的时间戳
-      let currentTime = Date().timeIntervalSince1970
+    // 获取当前的时间戳
+    let currentTime = Date().timeIntervalSince1970
 //      print(currentTime,   timeInterval, "sdsss")
-      //时间戳为毫秒级要 / 1000, 秒就不用除1000,参数带没带000
+    // 时间戳为毫秒级要 / 1000, 秒就不用除1000,参数带没带000
 //      let timeSta:TimeInterval = TimeInterval(timeInterval / 1000)
     // 时间差
     let reduceTime: TimeInterval = currentTime - timeInterval
@@ -773,7 +773,7 @@ public func contentMD5(path: String? = nil, data _: Data? = nil) -> String? {
         BFLog(message: "生成内容md5值:文件大小为0\(size)")
         return ""
     }
-    
+
     let hash: String = PQBridgeObject.base64Md5(forFilePath: path ?? "")
     BFLog(message: "生成内容md5值:contentMD5 = \(hash)")
     return hash
@@ -811,7 +811,7 @@ public var avAssertOptions: [String: Any]? = {
 /// 播放动画图
 public var playGifImages: [UIImage] = {
     var gifImages = Array<UIImage>.init()
-    for i in 0 ... 44 {
+    for i in 0...44 {
         gifImages.append(UIImage(named: "\(i).png")!)
     }
 
@@ -849,7 +849,7 @@ public func zipImageQuality(image: UIImage, maxLength: NSInteger, cyles: Int = 6
     var max: CGFloat = 1
     var min: CGFloat = 0
     var bestData: Data = data
-    for _ in 0 ..< cyles {
+    for _ in 0..<cyles {
         compression = (max + min) / 2
         data = image.jpegData(compressionQuality: compression)!
         if Double(data.count) < Double(maxLength) * 0.9 {
@@ -921,7 +921,7 @@ public func getLaunchImage() -> UIImage {
     return lauchImg
 }
 
-public func currentBundlePath() -> Bundle?{
+public func currentBundlePath() -> Bundle? {
 //    var associateBundleURL = Bundle.main.url(forResource: "Frameworks", withExtension: nil)
 //    associateBundleURL = associateBundleURL?.appendingPathComponent("BFFramework")
 //    associateBundleURL = associateBundleURL?.appendingPathExtension("framework")
@@ -938,7 +938,7 @@ public func currentBundlePath() -> Bundle?{
     return Bundle(url: associateBundleURL!)
 }
 
-public func synced(_ lock: Any, closure: () -> ()) {
+public func synced(_ lock: Any, closure: () -> Void) {
     objc_sync_enter(lock)
     closure()
     objc_sync_exit(lock)

+ 2 - 2
BFCommonKit/Classes/BFUtility/PQConstant.swift

@@ -13,8 +13,8 @@ import UIKit
 /// 通知
 public let PQNotification: NotificationCenter = NotificationCenter.default
 
-///** 默认间隔 */
-//public let cDefaultMargin: CGFloat = 10
+/// ** 默认间隔 */
+// public let cDefaultMargin: CGFloat = 10
 // 时间精度
 public let playerTimescale: Float64 = 1000.0
 // 时间精度Ints

+ 2 - 3
BFCommonKit/Classes/BFUtility/PQCreateEmptyWAV.swift

@@ -15,11 +15,10 @@
     //输出文件目录
     let outputPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! as String
      outputPath.append("/test.wav")
- 
+
     //同步创建方法
     tool.createEmptyWAVFile(url: URL(fileURLWithPath: outputPath))
-    
-    
+
  */
 
 import UIKit

+ 12 - 12
BFCommonKit/Classes/BFUtility/PQLZStringUtil.swift

@@ -80,7 +80,7 @@ public func compressToUInt8Array(input: String) -> [UInt8] {
     let compressed: Data = compress(input: input)
     var buffer = [UInt8](repeating: 0, count: compressed.count)
 
-    for i in 0 ..< (compressed.count / 2) {
+    for i in 0..<(compressed.count / 2) {
         buffer[i * 2] = compressed[i * 2 + 1]
         buffer[i * 2 + 1] = compressed[i * 2]
     }
@@ -166,7 +166,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
         } else {
             if context.dictCreate.index(forKey: w) != nil {
                 if let scalar = w.unicodeScalars.first, scalar.value < 256 {
-                    for _ in 0 ..< numBits {
+                    for _ in 0..<numBits {
                         context.val <<= 1
 
                         if context.position == bitPerChar - 1 {
@@ -180,7 +180,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
 
                     value = Int(w.unicodeScalars.first!.value)
 
-                    for _ in 0 ..< 8 {
+                    for _ in 0..<8 {
                         context.val = (context.val << 1) | (value & 1)
 
                         if context.position == bitPerChar - 1 {
@@ -196,7 +196,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
                 } else {
                     value = 1
 
-                    for _ in 0 ..< numBits {
+                    for _ in 0..<numBits {
                         context.val = (context.val << 1) | value
 
                         if context.position == bitPerChar - 1 {
@@ -211,7 +211,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
 
                     value = Int(w.unicodeScalars.first!.value)
 
-                    for _ in 0 ..< 16 {
+                    for _ in 0..<16 {
                         context.val = (context.val << 1) | (value & 1)
 
                         if context.position == bitPerChar - 1 {
@@ -237,7 +237,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
             } else {
                 value = context.dict[w]!
 
-                for _ in 0 ..< numBits {
+                for _ in 0..<numBits {
                     context.val = (context.val << 1) | (value & 1)
 
                     if context.position == bitPerChar - 1 {
@@ -266,7 +266,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
     if w != "" {
         if context.dictCreate.index(forKey: w) != nil {
             if let scalar = w.unicodeScalars.first, scalar.value < 256 {
-                for _ in 0 ..< numBits {
+                for _ in 0..<numBits {
                     context.val <<= 1
 
                     if context.position == bitPerChar - 1 {
@@ -280,7 +280,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
 
                 value = Int(w.unicodeScalars.first!.value)
 
-                for _ in 0 ..< 8 {
+                for _ in 0..<8 {
                     context.val = (context.val << 1) | (value & 1)
 
                     if context.position == bitPerChar - 1 {
@@ -296,7 +296,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
             } else {
                 value = 1
 
-                for _ in 0 ..< numBits {
+                for _ in 0..<numBits {
                     context.val = (context.val << 1) | value
 
                     if context.position == bitPerChar - 1 {
@@ -312,7 +312,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
 
                 value = Int(w.unicodeScalars.first!.value)
 
-                for _ in 0 ..< 16 {
+                for _ in 0..<16 {
                     context.val = (context.val << 1) | (value & 1)
 
                     if context.position == bitPerChar - 1 {
@@ -338,7 +338,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
         } else {
             value = context.dict[w]!
 
-            for _ in 0 ..< numBits {
+            for _ in 0..<numBits {
                 context.val = (context.val << 1) | (value & 1)
 
                 if context.position == bitPerChar - 1 {
@@ -362,7 +362,7 @@ private func _compress<T: RangeReplaceableCollection>(input: String, bitPerChar:
     }
     value = 2
 
-    for _ in 0 ..< numBits {
+    for _ in 0..<numBits {
         context.val = (context.val << 1) | (value & 1)
 
         if context.position == bitPerChar - 1 {

+ 4 - 4
BFCommonKit/Classes/BFUtility/PQPHAssetVideoParaseUtil.swift

@@ -611,7 +611,7 @@ open class PQPHAssetVideoParaseUtil: NSObject {
         let frameCount = CGImageSourceGetCount(imageSource)
         var gifDuration = 0.0
         var images = [UIImage]()
-        for i in 0 ..< frameCount {
+        for i in 0..<frameCount {
             // 取出索引对应的图片
             guard let imageRef = CGImageSourceCreateImageAtIndex(imageSource, i, info as CFDictionary) else {
                 BFLog(message: "取出对应的图片失败")
@@ -648,7 +648,7 @@ open class PQPHAssetVideoParaseUtil: NSObject {
                 gifDuration += gifFrameDuration
                 // 2.图片
                 var frameImage: UIImage? = UIImage(cgImage: imageRef, scale: 1.0, orientation: .up)
-                if isRenderingColor != nil && frameImage != nil {
+                if isRenderingColor != nil, frameImage != nil {
                     frameImage = tintImage(image: frameImage!, color: isRenderingColor!, blendMode: .destinationIn)
                 }
                 if frameImage != nil {
@@ -658,13 +658,13 @@ open class PQPHAssetVideoParaseUtil: NSObject {
         }
         resultHandler(data, images, gifDuration)
     }
-    
+
     /// 改变图片主题颜色
     /// - Parameters:
     ///   - color: <#color description#>
     ///   - blendMode: <#blendMode description#>
     /// - Returns: <#description#>
-    public class func tintImage(image:UIImage,color: UIColor, blendMode: CGBlendMode) -> UIImage? {
+    public class func tintImage(image: UIImage, color: UIColor, blendMode: CGBlendMode) -> UIImage? {
         let rect = CGRect(origin: CGPoint.zero, size: image.size)
         UIGraphicsBeginImageContextWithOptions(image.size, false, image.scale)
         color.setFill()

+ 11 - 9
BFCommonKit/Classes/BFUtility/PQSingletoMemoryUtil.swift

@@ -6,8 +6,8 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import Photos
+import UIKit
 
 // MARK: - 内存缓存数据
 
@@ -28,7 +28,7 @@ public class PQSingletoMemoryUtil: NSObject {
     public var isShowNoWiFiRemind: Bool = false // 是否提示过非WiFi提示
     public var isNeedRefreshAttend: Bool = false // 是否需要刷新关注
     public var isNeedRefreshJoinTopic: Bool = false // 是否需要刷新加入的话题
-    
+
     // 剪切板content是否为空,如果为空走承接逻辑,冷启动不再加载缓存
     public var isEmptyPasteContent: Bool = false {
         didSet {
@@ -42,12 +42,14 @@ public class PQSingletoMemoryUtil: NSObject {
             BFLog(message: "isShowPasteNoServeView = \(isShowPasteNoServeView)")
         }
     }
+
     /// 是否正在展示广告view
     public var isLoadingSplashAdView: Bool = false {
         didSet {
             BFLog(message: "isLoadingSplashAdView = \(isLoadingSplashAdView)")
         }
     }
+
     public var cutBoardInfo: String? // 剪切板信息
     public var cutBoard: String? // 剪切板来源cutBoardInfo
     public var isPushLoading: Bool = false // 是否正在加载推送数据
@@ -56,7 +58,7 @@ public class PQSingletoMemoryUtil: NSObject {
     public var isColdLaunch: Bool = false // 冷启动
     public var coldLaunchStatus: Int = 0 // 1-请求中 2-请求成功 3-请求失败
     public var deviceToken: String = "" // 推送deviceToken
-    public var activityData: Dictionary<String,Any>? // 活动数据信息
+    public var activityData: [String: Any]? // 活动数据信息
     public var isShowTodaySuccess: Bool = false // 是否已经展示过今日已完成
     public var sessionId: String = getUniqueId(desc: "sessionId")
     public var subSessionid: String?
@@ -76,22 +78,22 @@ public class PQSingletoMemoryUtil: NSObject {
     public var coverUrl: String?
 
     // 未读数字
-    public var unReadInfo: Dictionary<String,Any>?
+    public var unReadInfo: [String: Any]?
     public var abInfoData: [String: Any] = Dictionary<String, Any>.init() // 实验数据
-    public var allExportSession: [PHAsset:AVAssetExportSession] = [PHAsset:AVAssetExportSession].init()
+    public var allExportSession: [PHAsset: AVAssetExportSession] = [PHAsset: AVAssetExportSession].init()
     public func updateTabPoint() {
 //        let tabBar =
 //            rootViewController()?.tabBar
 //        if isShowAttendPoint {
 //            tabBar?.showPoint(index: 1)
 //        } else {
-////          tabBar.removePoint(index: 1)
+        ////          tabBar.removePoint(index: 1)
 //        }
     }
 
     /// 创建sessionId
     /// - Returns: <#description#>
-   public func createSesstionId() {
+    public func createSesstionId() {
         sessionId = getUniqueId(desc: "sessionId")
         subSessionid = sessionId
         BFLog(message: "生成的sessionId = \(sessionId)")
@@ -133,11 +135,11 @@ public class PQSingletoMemoryUtil: NSObject {
         }
     }
 
-    public override func copy() -> Any {
+    override public func copy() -> Any {
         return self
     }
 
-    public override func mutableCopy() -> Any {
+    override public func mutableCopy() -> Any {
         return self
     }
 }

+ 3 - 3
BFCommonKit/Classes/BFUtility/PQVideoSnapshotUtil.swift

@@ -14,7 +14,7 @@ public class PQVideoSnapshotUtil: NSObject {
     /// AVPlayer截屏
     /// - Parameter playerItem: <#playerItem description#>
     /// - Returns: <#description#>
-    class public  func snapshotImage(avPlayer: AVPlayer, complateHandle: @escaping (_ image: UIImage?) -> Void) {
+    public class func snapshotImage(avPlayer: AVPlayer, complateHandle: @escaping (_ image: UIImage?) -> Void) {
         guard let playerItem = avPlayer.currentItem else { // playerItem is AVPlayerItem
             complateHandle(nil)
             return
@@ -44,7 +44,7 @@ public class PQVideoSnapshotUtil: NSObject {
     ///   - videoURL: 视频地址
     ///   - time: 视频某个时间点
     /// - Returns: <#description#>
-    class public  func videoSnapshot(videoURL: URL, time: TimeInterval) -> UIImage? {
+    public class func videoSnapshot(videoURL: URL, time: TimeInterval) -> UIImage? {
         let asset = AVURLAsset(url: videoURL, options: avAssertOptions)
         let assetImageGenerator = AVAssetImageGenerator(asset: asset)
         assetImageGenerator.appliesPreferredTrackTransform = true
@@ -69,7 +69,7 @@ public class PQVideoSnapshotUtil: NSObject {
     ///   - duration: 视频时长
     ///   - count: 截取数量
     /// - Returns: <#description#>
-    class public  func videoSnapshot(videoURL: URL, duration: TimeInterval, count: Int, complateHandle: @escaping ([UIImage]?) -> Void) {
+    public class func videoSnapshot(videoURL: URL, duration: TimeInterval, count: Int, complateHandle: @escaping ([UIImage]?) -> Void) {
         DispatchQueue.global().async {
             var images: [UIImage]? = Array()
             let asset = AVURLAsset(url: videoURL, options: avAssertOptions)

+ 6 - 11
Example/BFCommonKit/AppDelegate.swift

@@ -10,37 +10,32 @@ import UIKit
 
 @UIApplicationMain
 class AppDelegate: UIResponder, UIApplicationDelegate {
-
     var window: UIWindow?
 
-
-    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
+    func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
         // Override point for customization after application launch.
         return true
     }
 
-    func applicationWillResignActive(_ application: UIApplication) {
+    func applicationWillResignActive(_: UIApplication) {
         // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
         // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     }
 
-    func applicationDidEnterBackground(_ application: UIApplication) {
+    func applicationDidEnterBackground(_: UIApplication) {
         // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
         // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     }
 
-    func applicationWillEnterForeground(_ application: UIApplication) {
+    func applicationWillEnterForeground(_: UIApplication) {
         // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
     }
 
-    func applicationDidBecomeActive(_ application: UIApplication) {
+    func applicationDidBecomeActive(_: UIApplication) {
         // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     }
 
-    func applicationWillTerminate(_ application: UIApplication) {
+    func applicationWillTerminate(_: UIApplication) {
         // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
     }
-
-
 }
-

+ 3 - 6
Example/BFCommonKit/ViewController.swift

@@ -6,15 +6,14 @@
 //  Copyright (c) 2021 wenweiwei. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
+import UIKit
 class ViewController: UIViewController {
-
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do any additional setup after loading the view, typically from a nib.
-        let btn = UIButton.init(type: .contactAdd)
-        btn.frame = CGRect.init(x: 100, y: 100, width: 100, height: 100)
+        let btn = UIButton(type: .contactAdd)
+        btn.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
         btn.backgroundColor = UIColor.hexColor(hexadecimal: "#3DC1C1")
         view.addSubview(btn)
     }
@@ -23,6 +22,4 @@ class ViewController: UIViewController {
         super.didReceiveMemoryWarning()
         // Dispose of any resources that can be recreated.
     }
-
 }
-

+ 5 - 7
Example/Tests/Tests.swift

@@ -1,28 +1,26 @@
-import XCTest
 import BFCommonKit
+import XCTest
 
 class Tests: XCTestCase {
-    
     override func setUp() {
         super.setUp()
         // Put setup code here. This method is called before the invocation of each test method in the class.
     }
-    
+
     override func tearDown() {
         // Put teardown code here. This method is called after the invocation of each test method in the class.
         super.tearDown()
     }
-    
+
     func testExample() {
         // This is an example of a functional test case.
         XCTAssert(true, "Pass")
     }
-    
+
     func testPerformanceExample() {
         // This is an example of a performance test case.
-        self.measure() {
+        measure {
             // Put the code you want to measure the time of here.
         }
     }
-    
 }

+ 67 - 0
rules.swiftformat

@@ -0,0 +1,67 @@
+--allman false
+--assetliterals visual-width
+--beforemarks 
+--binarygrouping 4,8
+--categorymark "MARK: %c"
+--classthreshold 0
+--closingparen balanced
+--commas always
+--conflictmarkers reject
+--decimalgrouping 3,6
+--elseposition same-line
+--enumthreshold 0
+--exponentcase lowercase
+--exponentgrouping disabled
+--extensionacl on-extension
+--extensionlength 0
+--extensionmark "MARK: - %t + %c"
+--fractiongrouping disabled
+--fragment false
+--funcattributes preserve
+--groupedextension "MARK: %c"
+--guardelse auto
+--header ignore
+--hexgrouping 4,8
+--hexliteralcase uppercase
+--ifdef indent
+--importgrouping alphabetized
+--indent 4
+--indentcase false
+--lifecycle 
+--linebreaks lf
+--markextensions always
+--marktypes always
+--maxwidth none
+--modifierorder 
+--nevertrailing 
+--nospaceoperators 
+--nowrapoperators 
+--octalgrouping 4,8
+--operatorfunc spaced
+--organizetypes class,enum,struct
+--patternlet hoist
+--ranges spaced
+--redundanttype inferred
+--self remove
+--selfrequired 
+--semicolons inline
+--shortoptionals always
+--smarttabs enabled
+--stripunusedargs always
+--structthreshold 0
+--swiftversion 4.0
+--tabwidth unspecified
+--trailingclosures 
+--trimwhitespace always
+--typeattributes preserve
+--typemark "MARK: - %t"
+--varattributes preserve
+--voidtype void
+--wraparguments preserve
+--wrapcollections preserve
+--wrapconditions preserve
+--wrapparameters preserve
+--wrapreturntype preserve
+--xcodeindentation disabled
+--yodaswap always
+--disable initCoderUnavailable,redundantType