|
@@ -0,0 +1,126 @@
|
|
|
+//
|
|
|
+// TSPTPHistoryVC.swift
|
|
|
+// AIEmoji
|
|
|
+//
|
|
|
+// Created by 100Years on 2025/4/26.
|
|
|
+//
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import UIKit
|
|
|
+
|
|
|
+class TSPTPHistoryVC: TSBaseVC {
|
|
|
+ var listModelArray: [TSActionInfoModel] = []
|
|
|
+ var dataChangedBlock:(()->Void)?
|
|
|
+ //###################################### 集合视图 ######################################
|
|
|
+ let collectionViewBtootm:CGFloat = 80
|
|
|
+ lazy var collectionView: TSSimpleCollectionView = {
|
|
|
+ let identifier = "TSGenmojiItemCell"
|
|
|
+
|
|
|
+ let itemW = (k_ScreenWidth-32.0-12.0-2.0)/2.0
|
|
|
+ let itemH = kGetScaleHeight(originalSize: CGSize(width: 165.0, height: 220.0), width: itemW)
|
|
|
+
|
|
|
+// let itemW = kPTPHistoryW
|
|
|
+// let itemH = kPTPHistoryH
|
|
|
+
|
|
|
+ let layout = UICollectionViewFlowLayout()
|
|
|
+ let cp = TSSimpleCollectionView()
|
|
|
+ cp.delegate = self
|
|
|
+ cp.layout.itemSize = CGSize(width: itemW, height: itemH)
|
|
|
+ cp.layout.minimumLineSpacing = 12
|
|
|
+ cp.layout.minimumInteritemSpacing = 12
|
|
|
+ cp.collectionView.contentInset = UIEdgeInsets(top: 16, left: 16, bottom: collectionViewBtootm, right: 16)
|
|
|
+ cp.registerCell(TSGenmojiItemCell.self,identifier:identifier)
|
|
|
+ cp.cellIdentifierForItem = { data in
|
|
|
+ return identifier
|
|
|
+ }
|
|
|
+
|
|
|
+ return cp
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var pageNullView: TSPageNullView = {
|
|
|
+ let pageNullView = TSPageNullView()
|
|
|
+ pageNullView.isHidden = true
|
|
|
+ return pageNullView
|
|
|
+ }()
|
|
|
+
|
|
|
+ override func createData() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var navRightBtn = UIButton()
|
|
|
+ override func createView() {
|
|
|
+
|
|
|
+ addNormalNavBarView()
|
|
|
+ setPageTitle("History".localized)
|
|
|
+ navRightBtn = setNavigationItem("", imageName: "delete", direction: .right, action: #selector(clickNavRight))
|
|
|
+
|
|
|
+ contentView.addSubview(pageNullView)
|
|
|
+ contentView.addSubview(collectionView)
|
|
|
+ collectionView.snp.makeConstraints { make in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override func dealThings() {
|
|
|
+ updateDataView()
|
|
|
+ NotificationCenter.default.addObserver(forName: .kGeneratePTPOperationChanged, object: nil, queue: nil) { [weak self] notification in
|
|
|
+ guard let self = self else { return }
|
|
|
+ if let userInfo = notification.userInfo as? [String: Any],let state = userInfo["state"] as? TSProgressState {
|
|
|
+ dePrint("TSBaseOperation stateDatauPblished 收到 = \(state)")
|
|
|
+ if state.reloadNewData {
|
|
|
+ updateDataView()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func updateDataView(){
|
|
|
+ TSRMShared.ptpDBHistory.getModelList { [weak self] array in
|
|
|
+ guard let self = self else { return }
|
|
|
+ listModelArray = array
|
|
|
+ updateView()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func updateView() {
|
|
|
+ collectionView.reload(with:[TSSimpleSectionData(items: listModelArray)])
|
|
|
+
|
|
|
+ navRightBtn.isHidden = listModelArray.count <= 0
|
|
|
+ pageNullView.isHidden = listModelArray.count > 0
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func clickNavRight() {
|
|
|
+ showCustomAlert(message: "Are you sure to delete".localized, deleteHandler: {
|
|
|
+ self.removeAllHistoryList()
|
|
|
+ self.updateDataView()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ deinit {
|
|
|
+ NotificationCenter.default.post(name: .kPTPDataChanged, object: nil)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension TSPTPHistoryVC: TSSimpleCollectionViewDelegate {
|
|
|
+
|
|
|
+ func collectionView(didTrigger event: TSSmalCoacopods.TSSimpleCellEvent) {
|
|
|
+ switch event.action {
|
|
|
+ case .tap:
|
|
|
+ let browseVC = TSAIPhotoBrowseVC()
|
|
|
+ browseVC.dataModelArray = listModelArray.filter{$0.status == "success"}
|
|
|
+ browseVC.currentIndex = event.indexPath.item
|
|
|
+ kPresentModalVC(target: self, modelVC: browseVC,transitionStyle: .crossDissolve)
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+extension TSPTPHistoryVC{
|
|
|
+ func removeAllHistoryList(){
|
|
|
+ TSRMShared.ptpDBHistory.delete()
|
|
|
+ }
|
|
|
+}
|