소스 검색

上传状态View

Chris 5 년 전
부모
커밋
66ce691f40

+ 12 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -622,6 +622,7 @@
 		BD7AB8452284398A0030646A /* OrderPaySelfPickAddInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7AB8442284398A0030646A /* OrderPaySelfPickAddInfoCell.swift */; };
 		BD929CCE22B904A30098C139 /* PublishViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD929CCD22B904A30098C139 /* PublishViewController.swift */; };
 		BD981A8F22C9FEEF0043D951 /* CommunityPublishModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD981A8E22C9FEEF0043D951 /* CommunityPublishModel.swift */; };
+		BDA45BFF22E45EBC009DE548 /* PublishUploadProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDA45BFE22E45EBC009DE548 /* PublishUploadProgressView.swift */; };
 		BDAA40F7228E947500CF841D /* OrderApplyRefundAccountCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40F6228E947500CF841D /* OrderApplyRefundAccountCell.swift */; };
 		BDAA40F9228E9ADA00CF841D /* OrderApplyRefundReasonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40F8228E9ADA00CF841D /* OrderApplyRefundReasonCell.swift */; };
 		BDAA40FB228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40FA228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift */; };
@@ -1396,6 +1397,7 @@
 		BD9052C044FD3AE4E62D3929 /* Pods-RainbowPlanet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RainbowPlanet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet.debug.xcconfig"; sourceTree = "<group>"; };
 		BD929CCD22B904A30098C139 /* PublishViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishViewController.swift; sourceTree = "<group>"; };
 		BD981A8E22C9FEEF0043D951 /* CommunityPublishModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityPublishModel.swift; sourceTree = "<group>"; };
+		BDA45BFE22E45EBC009DE548 /* PublishUploadProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishUploadProgressView.swift; sourceTree = "<group>"; };
 		BDAA40F6228E947500CF841D /* OrderApplyRefundAccountCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundAccountCell.swift; sourceTree = "<group>"; };
 		BDAA40F8228E9ADA00CF841D /* OrderApplyRefundReasonCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundReasonCell.swift; sourceTree = "<group>"; };
 		BDAA40FA228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundNoteInfoCell.swift; sourceTree = "<group>"; };
@@ -4787,6 +4789,7 @@
 				BD13B69F22B9CE8D008BB323 /* PublishEditController */,
 				BD13B6CF22BA03BB008BB323 /* PublishAddTopic */,
 				BD13B6CB22BA03BB008BB323 /* PublishAddAddress */,
+				BDA45BFD22E45DDD009DE548 /* PublishManager */,
 				BD13B6C822BA03BB008BB323 /* PublishSuccess */,
 			);
 			path = PublishModule;
@@ -5445,6 +5448,14 @@
 			path = AdressCell;
 			sourceTree = "<group>";
 		};
+		BDA45BFD22E45DDD009DE548 /* PublishManager */ = {
+			isa = PBXGroup;
+			children = (
+				BDA45BFE22E45EBC009DE548 /* PublishUploadProgressView.swift */,
+			);
+			path = PublishManager;
+			sourceTree = "<group>";
+		};
 		BDAF83AE22B3B6150004BCC3 /* AllCommentCell */ = {
 			isa = PBXGroup;
 			children = (
@@ -6430,6 +6441,7 @@
 				BD108C9722A60C2100837DAB /* HGImagePickerController.swift in Sources */,
 				BD2E5D4922D87ED900534603 /* MXSlider.m in Sources */,
 				BD09C84122955B480080D5A4 /* PopTopTriangleView.swift in Sources */,
+				BDA45BFF22E45EBC009DE548 /* PublishUploadProgressView.swift in Sources */,
 				A70B2C5A22886ADF00B2449F /* ShopViewController.swift in Sources */,
 				BDF862AE228E57E1000DEF84 /* OrderCommentDefaultCollectionCell.swift in Sources */,
 				BD61229722C3605C00D3F513 /* AliyunEffectPrestoreManager.m in Sources */,

+ 145 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishManager/PublishUploadProgressView.swift

@@ -0,0 +1,145 @@
+//
+//  PublishUploadProgressView.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/7/21.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  发布进度のView
+
+import UIKit
+import RxSwift
+
+/// 跳转方式
+///
+/// - none: 默认
+/// - push: push
+enum UploadStatus{
+    case uploading
+    case success
+    case failure
+}
+
+class PublishUploadProgressView: BaseView {
+    
+    typealias CloseViewClosure = () -> Void
+    var closeViewClosure : CloseViewClosure?
+    
+    var curUploadStatus : UploadStatus? {
+        didSet {
+            judgeShowStatus()
+        }
+    }
+    
+    var uploadProgress: Float? {
+        didSet {
+            progressView.setProgress(self.uploadProgress ?? 0, animated: true)
+        }
+    }
+    
+    
+    override func setupViews() {
+        self.backgroundColor = kffffffColor
+        addSubview(imageView)
+        addSubview(progressLabel)
+        addSubview(progressView)
+        addSubview(failedLabel)
+        addSubview(failedCloseButton)
+    }
+    
+    override func setupLayouts() {
+        imageView.snp.makeConstraints { (make) in
+            make.left.equalTo(14)
+            make.centerY.equalToSuperview()
+            make.size.equalTo(44)
+        }
+        progressLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(imageView.snp_right).offset(10)
+            make.top.equalTo(14)
+            make.height.equalTo(20)
+        }
+        progressView.snp.makeConstraints { (make) in
+            make.top.equalTo(progressLabel.snp_bottom).offset(10)
+            make.left.equalTo(imageView.snp_right).offset(10)
+            make.right.equalTo(-15)
+            make.height.equalTo(4)
+        }
+        failedLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(imageView.snp_right).offset(10)
+            make.centerY.equalToSuperview()
+            make.height.equalTo(20)
+        }
+        failedCloseButton.snp.makeConstraints { (make) in
+            make.right.equalTo(-3)
+            make.centerY.equalToSuperview()
+            make.size.equalTo(44)
+        }
+    }
+    
+    lazy var imageView: UIImageView = {
+        let imageView = UIImageView()
+        imageView.image = kImage(name: "pic_preload")
+        imageView.contentMode =  .scaleAspectFill
+        imageView.clipsToBounds = true
+        return imageView
+    }()
+    
+    private lazy var progressLabel: UILabel = {
+        let progressLabel = UILabel()
+        progressLabel.textColor = k333333Color
+        progressLabel.font = kRegularFont14
+        progressLabel.textAlignment = .left
+        return progressLabel
+    }()
+    
+    private lazy var progressView: UIProgressView = {
+        let progressView = UIProgressView(progressViewStyle: .default)
+        progressView.setProgress(0, animated: false)
+        progressView.progressTintColor = k62CC74Color //进度颜色
+        progressView.trackTintColor = kd8d8d8Color //剩余进度颜色
+        progressView.cornerRadius = 2
+        progressView.masksToBounds = true
+        return progressView
+    }()
+    
+    private lazy var failedLabel: UILabel = {
+        let failedLabel = UILabel()
+        failedLabel.text = "发布失败..."
+        failedLabel.textColor = k333333Color
+        failedLabel.font = kRegularFont14
+        failedLabel.textAlignment = .left
+        return failedLabel
+    }()
+    
+    private lazy var failedCloseButton: UIButton = {
+        let failedCloseButton = UIButton(type: UIButton.ButtonType.custom)
+        failedCloseButton.setImage(kImage(name: "popup_btn_close_black"), for: .normal)
+        failedCloseButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            if let closeViewClosure = self?.closeViewClosure {
+                closeViewClosure()
+            }
+        }).disposed(by: disposeBag)
+        return failedCloseButton
+    }()
+    
+}
+
+extension PublishUploadProgressView {
+    
+    func judgeShowStatus() -> Void {
+        switch curUploadStatus {
+        case .uploading?,
+             .success?:
+            progressLabel.isHidden = false
+            progressView.isHidden = false
+            failedLabel.isHidden = true
+            failedCloseButton.isHidden = true
+        case .failure?:
+            progressLabel.isHidden = true
+            progressView.isHidden = true
+            failedLabel.isHidden = false
+            failedCloseButton.isHidden = false
+        case .none:
+            break
+        }
+    }
+}