|
@@ -23,9 +23,8 @@ class CirclePublishMessageViewController: BaseViewController {
|
|
|
var circleId : Int?
|
|
|
var content : String = ""
|
|
|
var imgs : String = ""
|
|
|
- var maxImageCount: Int = 9
|
|
|
- var images = Array<UIImage>()
|
|
|
-
|
|
|
+ var maxImageCount: Int = 3
|
|
|
+ var selectedAssets = Array<TLPHAsset>()
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
@@ -92,7 +91,7 @@ class CirclePublishMessageViewController: BaseViewController {
|
|
|
/// 发布
|
|
|
func communityCircleMessagePostApi() {
|
|
|
SwiftMoyaNetWorkServiceCommunity.shared().communityCircleMessagePostApi(circleId: circleId ?? 0, content: content ,imgs: imgs) { [weak self] _ in
|
|
|
- self?.navigationController?.popToRootViewController(animated: true)
|
|
|
+ self?.navigationController?.popViewController(animated: true)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -107,8 +106,8 @@ extension CirclePublishMessageViewController: UICollectionViewDelegateFlowLayout
|
|
|
case 0:
|
|
|
return 1
|
|
|
default:
|
|
|
- if images.count < maxImageCount {
|
|
|
- return images.count + 1
|
|
|
+ if selectedAssets.count < maxImageCount {
|
|
|
+ return selectedAssets.count + 1
|
|
|
} else {
|
|
|
return maxImageCount
|
|
|
}
|
|
@@ -121,9 +120,13 @@ extension CirclePublishMessageViewController: UICollectionViewDelegateFlowLayout
|
|
|
switch indexPath.section {
|
|
|
case 0:
|
|
|
let cell = CirclePublishMessageTitleCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
+ cell.titleTextViewChangedClosure = {
|
|
|
+ [weak self] content in
|
|
|
+ self?.content = content
|
|
|
+ }
|
|
|
return cell
|
|
|
default:
|
|
|
- if images.count < maxImageCount && indexPath.row == images.count {
|
|
|
+ if selectedAssets.count < maxImageCount && indexPath.row == selectedAssets.count {
|
|
|
// 添加图片
|
|
|
let cell = PublishEditDefaultCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
cell.noteStr = "添加图片"
|
|
@@ -132,12 +135,13 @@ extension CirclePublishMessageViewController: UICollectionViewDelegateFlowLayout
|
|
|
// 展示图片
|
|
|
let cell = PublishEditAddImgCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
cell.mediaType = .image
|
|
|
- if indexPath.row < images.count {
|
|
|
- cell.showImage = images[indexPath.row]
|
|
|
+ if indexPath.row < selectedAssets.count {
|
|
|
+ let image = selectedAssets[indexPath.row].fullResolutionImage
|
|
|
+ cell.showImage = image
|
|
|
}
|
|
|
cell.delPicBlock = {
|
|
|
[weak self] (index) in
|
|
|
- self?.images.remove(at: index!)
|
|
|
+ self?.selectedAssets.remove(at: index!)
|
|
|
self?.collectionView.reloadSections([1])
|
|
|
}
|
|
|
return cell
|
|
@@ -179,11 +183,17 @@ extension CirclePublishMessageViewController: UICollectionViewDelegateFlowLayout
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
- if images.count < maxImageCount && indexPath.row == images.count {
|
|
|
+ if selectedAssets.count < maxImageCount && indexPath.row == selectedAssets.count {
|
|
|
let vc = CustomTLPhotoPickerViewController()
|
|
|
vc.mediaType = .image
|
|
|
vc.numberOfColumn = 4
|
|
|
- vc.maxSelectedAssets = 3
|
|
|
+ vc.maxSelectedAssets = maxImageCount
|
|
|
+ vc.selectedAssets = selectedAssets
|
|
|
+ vc.finishClosure = {
|
|
|
+ [weak self] selectedAssets in
|
|
|
+ self?.selectedAssets = selectedAssets
|
|
|
+ self?.collectionView.reloadSections([1])
|
|
|
+ }
|
|
|
self.navigationController?.pushViewController(vc, animated: true)
|
|
|
}
|
|
|
}
|