Browse Source

1.merge master

wenweiwei 3 years ago
parent
commit
422bf9b5ff

+ 1 - 1
BFCommonKit/Classes/BFBase/Model/PQBaseModel.swift

@@ -187,7 +187,7 @@ public class PQEmptyModel: NSObject {
     public var emptyImageName: String? // 空白提示图
     public var emptySoureImage: UIImage? // 空白提示图
     public var isRefreshHidden: Bool = true // 是否隐藏刷新按钮
-    public var refreshImage: String? // 刷新按钮图片
+    public var refreshImageName: String? // 刷新按钮图片
     public var refreshTitle: NSMutableAttributedString? // 刷新按钮文字
     public var refreshBgColor: UIColor? // 刷新按钮背景颜色
     public var netemptyDisImage: UIImage? // 无网空白提示图

+ 2 - 2
BFCommonKit/Classes/BFBase/View/PQRemindView.swift

@@ -327,8 +327,8 @@ extension PQEmptyRemindView {
             remindLab.text = emptyData?.title
             remindSubLab.text = emptyData?.summary
             refreshBtn.isHidden = emptyData?.isRefreshHidden ?? true
-            if emptyData?.refreshImage != nil, (emptyData?.refreshImage?.count ?? 0) > 0 {
-                refreshBtn.setImage(UIImage.moduleImage(named: emptyData?.refreshImage ?? "", moduleName: "BFCommonKit"), for: .normal)
+            if emptyData?.refreshImageName != nil, (emptyData?.refreshImageName?.count ?? 0) > 0 {
+                refreshBtn.setImage(UIImage.moduleImage(named: emptyData?.refreshImageName ?? "", moduleName: "BFCommonKit"), for: .normal)
             } else {
                 refreshBtn.setImage(nil, for: .normal)
             }

+ 6 - 1
BFCommonKit/Classes/BFConfig/PQBFConfig.swift

@@ -68,7 +68,12 @@ public class PQBFConfig: NSObject {
     
     //闪音卡点发布分享朋友圈使用图片名
     public var shareFriendBtnImage = "reCreate_opration_friend"
-
+    //从系统相册选择图片名
+    public var editCoverimageSelectImage = "editCoverimageSelect"
+    //选择对勾图片名
+    public var editCoverimageSelectedImage = "editCoverimageSelected"
+    //系统相册背景色
+    public var editCoverimageSelectedbackgroundColor:UIColor = .white
     // 微信登陆信息
 //    public var appInfo: WXApiInfo?
     // 渠道

+ 3 - 0
BFCommonKit/Classes/BFUtility/PQBridgeObject.h

@@ -17,6 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
 + (NSString *)getByteRate;
 + (long long) getInterfaceBytes;
 + (NSString *)formatNetWork:(long long int)rate;
+
+
++ (NSString *)base64Md5ForFilePath:(NSString *)filePath;
 @end
 
 NS_ASSUME_NONNULL_END

+ 45 - 0
BFCommonKit/Classes/BFUtility/PQBridgeObject.m

@@ -7,6 +7,14 @@
 //
 
 #import "PQBridgeObject.h"
+#import "CommonCrypto/CommonDigest.h"
+#import "CommonCrypto/CommonHMAC.h"
+int32_t const CHUNK_SIZE = 8 * 1024;
+
+#define CC_MD5_DIGEST_LENGTH    16          /* digest length in bytes */
+#define CC_MD5_BLOCK_BYTES      64          /* block size in bytes */
+#define CC_MD5_BLOCK_LONG       (CC_MD5_BLOCK_BYTES / sizeof(CC_LONG))
+
 
 @implementation PQBridgeObject
 + (NSString *)getByteRate {
@@ -53,4 +61,41 @@
         return @"0B/s";
     };
 }
+
++ (NSString*)base64ForData:(uint8_t *)input length:(int32_t)length {
+    if (input == nil) {
+        return nil;
+    }
+    NSData * data = [NSData dataWithBytes:input length:length];
+    return [data base64EncodedStringWithOptions: NSDataBase64Encoding64CharacterLineLength];
+}
+
+
++ (NSString *)base64Md5ForFilePath:(NSString *)filePath {
+    uint8_t * bytes = (uint8_t *)[[self fileMD5:filePath] bytes];
+    return [self base64ForData:bytes length:CC_MD5_DIGEST_LENGTH];
+}
+
++ (NSData *)fileMD5:(NSString*)path {
+    NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
+    if(handle == nil) {
+        return nil;
+    }
+    CC_MD5_CTX md5;
+    CC_MD5_Init(&md5);
+    BOOL done = NO;
+    while(!done) {
+        @autoreleasepool{
+            NSData* fileData = [handle readDataOfLength: CHUNK_SIZE];
+            CC_MD5_Update(&md5, [fileData bytes], (CC_LONG)[fileData length]);
+            if([fileData length] == 0) {
+                done = YES;
+            }
+        }
+    }
+    unsigned char digestResult[CC_MD5_DIGEST_LENGTH * sizeof(unsigned char)];
+    CC_MD5_Final(digestResult, &md5);
+    return [NSData dataWithBytes:(const void *)digestResult length:CC_MD5_DIGEST_LENGTH * sizeof(unsigned char)];
+}
+
 @end

+ 33 - 2
BFCommonKit/Classes/BFUtility/PQCommonMethodUtil.swift

@@ -15,6 +15,7 @@ import KingfisherWebP
 import Photos
 import Toast_Swift
 import RealmSwift
+import UIKit
 
 /// Home文件地址
 public let homeDirectory = NSHomeDirectory()
@@ -132,6 +133,36 @@ public func kf_imageCacheImage(originUrl: String, completeHandle: @escaping (_ i
     }
 }
 
+public func bf_getRootViewController() -> UIViewController? {
+    guard let window = UIApplication.shared.delegate?.window else {
+        return nil
+    }
+    return window!.rootViewController
+}
+
+public func bf_getCurrentViewController() -> UIViewController? {
+    var currentVC = bf_getRootViewController()
+    if currentVC == nil {
+        return nil
+    }
+    
+    let runloopFind = true
+    while runloopFind {
+        if let vc = currentVC!.presentedViewController {
+            currentVC = vc
+        }else {
+            if currentVC is UINavigationController {
+                currentVC = (currentVC as! UINavigationController).visibleViewController
+            }else if currentVC is UITabBarController {
+                currentVC = (currentVC as! UITabBarController).selectedViewController
+            }else {
+                break
+            }
+        }
+    }
+    return currentVC
+}
+
 
 /** 打印
    type = 1 : 胡志强
@@ -787,8 +818,8 @@ public func contentMD5(path: String? = nil, data _: Data? = nil) -> String? {
         BFLog(message: "生成内容md5值:文件大小为0\(size)")
         return ""
     }
-//    let hash: String = OSSUtil.base64Md5(forFilePath: path)
-    let hash: String = ""
+    
+    let hash: String = PQBridgeObject.base64Md5(forFilePath: path ?? "")
     BFLog(message: "生成内容md5值:contentMD5 = \(hash)")
     return hash
 }