|
@@ -48,20 +48,15 @@ class PublishEditController: BaseViewController {
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
|
// imageUrlArray每次进入页面需置空
|
|
|
imageUrlArray = []
|
|
|
+ rightButton.isEnabled = false
|
|
|
+ rightButton.backgroundColor = kd8d8d8Color
|
|
|
+ uploadAllImages(totalTimes: 0)
|
|
|
}
|
|
|
|
|
|
override func setupViews() {
|
|
|
self.view.backgroundColor = kffffffColor
|
|
|
|
|
|
navigationBar.title = ""
|
|
|
- navigationBar.wr_setRightButton(title: "发布", titleColor: k333333Color)
|
|
|
- navigationBar.onClickRightButton = {
|
|
|
- [weak self] in
|
|
|
- print("----点击了发布")
|
|
|
-
|
|
|
- self?.uploadAllImages(totalTimes: 0)
|
|
|
- }
|
|
|
-
|
|
|
navigationBar.wr_setLeftButton(image: kImage(name: "navbar_back_black")!)
|
|
|
navigationBar.onClickLeftButton = {
|
|
|
[weak self] in
|
|
@@ -73,9 +68,36 @@ class PublishEditController: BaseViewController {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ view.addSubview(rightButton)
|
|
|
+ rightButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalToSuperview().offset(kSafeStatusBarHeight+8)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.width.equalTo(64)
|
|
|
+ make.height.equalTo(26)
|
|
|
+ }
|
|
|
+
|
|
|
+ view.addSubview(progressBackView)
|
|
|
+ progressBackView.addSubview(progressView)
|
|
|
+ progressBackView.addSubview(subLabel)
|
|
|
+
|
|
|
+ progressBackView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalToSuperview().offset(kNavBarTotalHeight)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(38)
|
|
|
+ }
|
|
|
+ progressView.snp.makeConstraints { (make) in
|
|
|
+ make.top.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(3)
|
|
|
+ }
|
|
|
+ subLabel.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.height.equalTo(20)
|
|
|
+ }
|
|
|
+
|
|
|
view.addSubview(tableView)
|
|
|
tableView.snp.makeConstraints { (make) in
|
|
|
- make.top.equalToSuperview().offset(kNavBarTotalHeight)
|
|
|
+ make.top.equalTo(progressBackView.snp_bottom)
|
|
|
make.left.right.bottom.equalToSuperview()
|
|
|
}
|
|
|
}
|
|
@@ -96,6 +118,46 @@ class PublishEditController: BaseViewController {
|
|
|
return tableView
|
|
|
}()
|
|
|
|
|
|
+ private lazy var rightButton: UIButton = {
|
|
|
+ let rightButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ rightButton.setTitle("发布", for: UIControl.State.normal)
|
|
|
+ rightButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
+ rightButton.titleLabel?.font = kMediumFont13
|
|
|
+ rightButton.cornerRadius = 16
|
|
|
+ rightButton.masksToBounds = true
|
|
|
+ rightButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ self?.communityPublishApi()
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return rightButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var progressBackView: UIView = {
|
|
|
+ let progressBackView = UIView()
|
|
|
+ progressBackView.backgroundColor = kffffffColor
|
|
|
+ return progressBackView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var progressView: UIProgressView = {
|
|
|
+ let progressView = UIProgressView(progressViewStyle: .default)
|
|
|
+// progressView.frame = CGRect(x: 0, y: 0, width: 200, height: 10)
|
|
|
+// progressView.layer.position = CGPoint(x: self.view.frame.width/2, y: 90)
|
|
|
+ progressView.setProgress(0, animated: false)
|
|
|
+ progressView.progressTintColor = k62CC74Color //进度颜色
|
|
|
+ progressView.trackTintColor = kd8d8d8Color //剩余进度颜色
|
|
|
+ //通过改变进度条高度(宽度不变,高度变为默认的2倍)
|
|
|
+// progressView.transform = CGAffineTransform(scaleX: 1.0, y: 2.0)
|
|
|
+ return progressView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var subLabel: UILabel = {
|
|
|
+ let subLabel = UILabel()
|
|
|
+ subLabel.text = "图片正在上传中(0/\(imageArr?.count ?? 0))..."
|
|
|
+ subLabel.textColor = k333333Color
|
|
|
+ subLabel.font = kRegularFont14
|
|
|
+ subLabel.textAlignment = .left
|
|
|
+ return subLabel
|
|
|
+ }()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// MARK: - tableView dataSource && delegate
|
|
@@ -122,6 +184,7 @@ extension PublishEditController : UITableViewDelegate, UITableViewDataSource {
|
|
|
picCell.delPicTransBlock = {
|
|
|
[weak self] (picIdx) in
|
|
|
self?.imageArr?.remove(at: picIdx!)
|
|
|
+ self?.imageUrlArray.remove(at: picIdx!)
|
|
|
self?.tableView.reloadData()
|
|
|
}
|
|
|
return picCell
|
|
@@ -209,12 +272,22 @@ extension PublishEditController {
|
|
|
// 设置主图
|
|
|
self?.majorImageUrl = urlStr
|
|
|
}
|
|
|
+
|
|
|
print("-----FinishUpload,Times == \(curTimes)")
|
|
|
curTimes += 1
|
|
|
+ // 更新进度
|
|
|
+ self?.progressView.setProgress(Float(curTimes/(self?.imageArr!.count)!), animated: true)
|
|
|
+ if curTimes == self?.imageArr!.count {
|
|
|
+ self?.subLabel.text = "图片上传成功!"
|
|
|
+ } else {
|
|
|
+ self?.subLabel.text = "图片正在上传中(\(curTimes)/\(self?.imageArr?.count ?? 0))..."
|
|
|
+ }
|
|
|
+
|
|
|
if curTimes < self?.imageArr?.count ?? 0 {
|
|
|
self?.uploadAllImages(totalTimes: curTimes)
|
|
|
} else {
|
|
|
- self?.communityPublishApi()
|
|
|
+ self?.rightButton.isEnabled = true
|
|
|
+ self?.rightButton.backgroundColor = k62CC74Color
|
|
|
}
|
|
|
}
|
|
|
}
|