|
@@ -6,7 +6,6 @@
|
|
|
//
|
|
|
|
|
|
class TSAIListHistoryBaseVC: TSBaseVC {
|
|
|
-
|
|
|
var generatorStyle:TSGeneratorImageStyle
|
|
|
var titleString:String?
|
|
|
init(titleString:String? = nil,generatorStyle:TSGeneratorImageStyle) {
|
|
@@ -18,51 +17,26 @@ class TSAIListHistoryBaseVC: TSBaseVC {
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
}
|
|
|
|
|
|
- lazy var viewModel: TSAIListHistoryBaseVM = {
|
|
|
- let viewModel = TSAIListHistoryBaseVM(generatorStyle: generatorStyle)
|
|
|
- return viewModel
|
|
|
- }()
|
|
|
+ private let kPTPHistoryW = (k_ScreenWidth-32.0-12.0-2)/2.0
|
|
|
|
|
|
//###################################### 集合视图 ######################################
|
|
|
let collectionViewBtootm:CGFloat = 80
|
|
|
- lazy var collectionComponent: TSCollectionViewComponent = {
|
|
|
- let layout = UICollectionViewFlowLayout()
|
|
|
- let cp = TSCollectionViewComponent(frame: CGRect.zero, layout: layout, attributes: [:])
|
|
|
- cp.collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: collectionViewBtootm, right: 0)
|
|
|
-
|
|
|
+ lazy var collectionView: TSSimpleCollectionView = {
|
|
|
+ let identifier = "TSAIListHistoryBaseCell"
|
|
|
|
|
|
- // 禁用自动 contentInset 调整
|
|
|
- if #available(iOS 11.0, *) {
|
|
|
- cp.collectionView.contentInsetAdjustmentBehavior = .never
|
|
|
- } else {
|
|
|
- automaticallyAdjustsScrollViewInsets = false
|
|
|
- }
|
|
|
-
|
|
|
- cp.sectionActionHandler = { [weak self] cellCp, indexPath in
|
|
|
- guard let self = self else { return }
|
|
|
- if let cmd = cellCp as? String, cmd == "delete" {
|
|
|
- showCustomAlert(message: "Are you sure to delete".localized, deleteHandler: {
|
|
|
- self.viewModel.removeAllHistoryList()
|
|
|
- self.collectionComponent.clear()
|
|
|
- self.collectionComponent.reloadView(with: self.viewModel.colDataArray)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ let itemW = (k_ScreenWidth-32.0-12.0-2.0)/2.0
|
|
|
+ let itemH = kGetScaleHeight(originalSize: CGSize(width: 165.0, height: 293.0), width: itemW)
|
|
|
|
|
|
- cp.itemDidSelectedHandler = { [weak self] (object, indexPath) in
|
|
|
- guard let self = self else { return }
|
|
|
-
|
|
|
- if let sections = viewModel.colDataArray.safeObj(At: indexPath.section) as? TSGenmojiCoLSectionModel{
|
|
|
- var dataModelArray:[TSActionInfoModel] = []
|
|
|
- for itemModel in sections.items {
|
|
|
- dataModelArray.append(itemModel.dataModel)
|
|
|
- }
|
|
|
-
|
|
|
- let browseVC = TSAIPhotoBrowseVC()
|
|
|
- browseVC.dataModelArray = dataModelArray
|
|
|
- browseVC.currentIndex = indexPath.item
|
|
|
- kPresentModalVC(target: self, modelVC: browseVC,transitionStyle: .crossDissolve)
|
|
|
- }
|
|
|
+ let layout = UICollectionViewFlowLayout()
|
|
|
+ let cp = TSSimpleCollectionView()
|
|
|
+ cp.layout.itemSize = CGSize(width: itemW, height: itemH)
|
|
|
+ cp.layout.minimumLineSpacing = 12
|
|
|
+ cp.layout.minimumInteritemSpacing = 12
|
|
|
+ cp.delegate = self
|
|
|
+ cp.collectionView.contentInset = UIEdgeInsets(top: 16, left: 16, bottom: collectionViewBtootm, right: 16)
|
|
|
+ cp.registerCell(TSAIListHistoryBaseCell.self,identifier:identifier)
|
|
|
+ cp.cellIdentifierForItem = { data in
|
|
|
+ return identifier
|
|
|
}
|
|
|
|
|
|
return cp
|
|
@@ -90,29 +64,89 @@ class TSAIListHistoryBaseVC: TSBaseVC {
|
|
|
navRightBtn = setNavigationItem("", imageName: "delete", direction: .right, action: #selector(clickNavRight))
|
|
|
|
|
|
contentView.addSubview(pageNullView)
|
|
|
- contentView.addSubview(collectionComponent.collectionView)
|
|
|
- collectionComponent.collectionView.snp.makeConstraints { make in
|
|
|
+ contentView.addSubview(collectionView)
|
|
|
+ collectionView.snp.makeConstraints { make in
|
|
|
make.edges.equalToSuperview()
|
|
|
}
|
|
|
- debugPrint("777")
|
|
|
- updateView()
|
|
|
- debugPrint("788")
|
|
|
}
|
|
|
|
|
|
+ override func dealThings() {
|
|
|
+ DispatchQueue.global(qos: .userInitiated).async {
|
|
|
+ _ = self.listModelArray
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ self.updateView()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
func updateView() {
|
|
|
- collectionComponent.clear()
|
|
|
- collectionComponent.reloadView(with:viewModel.colDataArray)
|
|
|
+ collectionView.reload(with: [listModelArray])
|
|
|
|
|
|
- navRightBtn.isHidden = viewModel.colDataArray.count <= 0
|
|
|
- pageNullView.isHidden = viewModel.colDataArray.count > 0
|
|
|
+ navRightBtn.isHidden = listModelArray.count <= 0
|
|
|
+ pageNullView.isHidden = listModelArray.count > 0
|
|
|
}
|
|
|
|
|
|
@objc func clickNavRight() {
|
|
|
showCustomAlert(message: "Are you sure to delete".localized, deleteHandler: {
|
|
|
- self.viewModel.removeAllHistoryList()
|
|
|
+ self.removeAllHistoryList()
|
|
|
self.updateView()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+extension TSAIListHistoryBaseVC: TSSimpleCollectionViewDelegate {
|
|
|
+
|
|
|
+ func collectionView(didTrigger event: TSSmalCoacopods.TSSimpleCellEvent) {
|
|
|
+ switch event.action {
|
|
|
+ case .tap:
|
|
|
+ let browseVC = TSAIPhotoBrowseVC()
|
|
|
+ browseVC.dataModelArray = listModelArray
|
|
|
+ browseVC.currentIndex = event.indexPath.item
|
|
|
+ kPresentModalVC(target: self, modelVC: browseVC,transitionStyle: .crossDissolve)
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+extension TSAIListHistoryBaseVC{
|
|
|
+ func removeAllHistoryList(){
|
|
|
+ switch generatorStyle {
|
|
|
+ case .ageOld:
|
|
|
+ TSChangeOldAgeHistory.shared.removeALLModel()
|
|
|
+ case .ageChild:
|
|
|
+ TSChangeBabyAgeHistory.shared.removeALLModel()
|
|
|
+ case .oldPhoto:
|
|
|
+ TSChangeOldPhotoHistory.shared.removeALLModel()
|
|
|
+ case .eyeOpen:
|
|
|
+ TSAIEyeOpenHistory.shared.removeALLModel()
|
|
|
+ case .pretty:
|
|
|
+ TSAIPhotoPrettyHistory.shared.removeALLModel()
|
|
|
+ case .photoLive:
|
|
|
+ TSAIPhotoLiveHistory.shared.removeALLModel()
|
|
|
+ case .photoExpand:
|
|
|
+ TSAIPhotoExpandHistory.shared.removeALLModel()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var listModelArray:[TSActionInfoModel]{
|
|
|
+ switch generatorStyle {
|
|
|
+ case .ageOld:
|
|
|
+ TSChangeOldAgeHistory.shared.listModels
|
|
|
+ case .ageChild:
|
|
|
+ TSChangeBabyAgeHistory.shared.listModels
|
|
|
+ case .oldPhoto:
|
|
|
+ TSChangeOldPhotoHistory.shared.listModels
|
|
|
+ case .eyeOpen:
|
|
|
+ TSAIEyeOpenHistory.shared.listModels
|
|
|
+ case .pretty:
|
|
|
+ TSAIPhotoPrettyHistory.shared.listModels
|
|
|
+ case .photoLive:
|
|
|
+ TSAIPhotoLiveHistory.shared.listModels
|
|
|
+ case .photoExpand:
|
|
|
+ TSAIPhotoExpandHistory.shared.listModels
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|