|
@@ -5,13 +5,27 @@
|
|
|
// Created by 100Years on 2025/4/26.
|
|
|
//
|
|
|
|
|
|
-
|
|
|
-
|
|
|
import UIKit
|
|
|
|
|
|
class TSPTPHistoryVC: TSBaseVC {
|
|
|
var listModelArray: [TSActionInfoModel] = []
|
|
|
var dataChangedBlock:(()->Void)?
|
|
|
+
|
|
|
+
|
|
|
+ enum Style {
|
|
|
+ case ptp
|
|
|
+ case ttp
|
|
|
+ }
|
|
|
+
|
|
|
+ var style:Style
|
|
|
+ init(style: Style) {
|
|
|
+ self.style = style
|
|
|
+ super.init()
|
|
|
+ }
|
|
|
+ @MainActor required init?(coder: NSCoder) {
|
|
|
+ fatalError("init(coder:) has not been implemented")
|
|
|
+ }
|
|
|
+
|
|
|
//###################################### 集合视图 ######################################
|
|
|
let collectionViewBtootm:CGFloat = 80
|
|
|
lazy var collectionView: TSSimpleCollectionView = {
|
|
@@ -20,20 +34,15 @@ class TSPTPHistoryVC: TSBaseVC {
|
|
|
|
|
|
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.layout.headerReferenceSize = CGSizeMake(k_ScreenWidth, kSectionTitleViewH)
|
|
|
cp.collectionView.contentInset = UIEdgeInsets(top: 16, left: 16, bottom: collectionViewBtootm, right: 16)
|
|
|
cp.registerCell(TSGenmojiItemCell.self,identifier:identifier)
|
|
|
-// cp.registerSectionHeader(TSGenmojiColSectionView.self, identifier: headerIdentifier)
|
|
|
cp.cellIdentifierForItem = { data in
|
|
|
return identifier
|
|
|
}
|
|
@@ -80,7 +89,7 @@ class TSPTPHistoryVC: TSBaseVC {
|
|
|
}
|
|
|
|
|
|
func updateDataView(){
|
|
|
- TSRMShared.ptpDBHistory.getModelList { [weak self] array in
|
|
|
+ dbHistory.getModelList { [weak self] array in
|
|
|
guard let self = self else { return }
|
|
|
listModelArray = array
|
|
|
updateView()
|
|
@@ -98,12 +107,9 @@ class TSPTPHistoryVC: TSBaseVC {
|
|
|
showCustomAlert(message: "Are you sure to delete".localized, deleteHandler: {
|
|
|
self.removeAllHistoryList()
|
|
|
self.updateDataView()
|
|
|
+ self.dataChangedNotification()
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
- deinit {
|
|
|
- NotificationCenter.default.post(name: .kPTPDataChanged, object: nil)
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
extension TSPTPHistoryVC: TSSimpleCollectionViewDelegate {
|
|
@@ -118,16 +124,18 @@ extension TSPTPHistoryVC: TSSimpleCollectionViewDelegate {
|
|
|
browseVC.currentIndex = dataModelArray.firstIndex(of: selectedModel) ?? 0
|
|
|
browseVC.deleteComplete = { [weak self] deleteModel in
|
|
|
guard let self = self else { return }
|
|
|
- TSRMShared.ptpDBHistory.deleteListModel(id: deleteModel.id)
|
|
|
+ dbHistory.deleteListModel(id: deleteModel.id)
|
|
|
updateDataView()
|
|
|
+ dataChangedNotification()
|
|
|
}
|
|
|
kPresentModalVC(target: self, modelVC: browseVC,transitionStyle: .crossDissolve)
|
|
|
|
|
|
case .buttonTapped(let string):
|
|
|
if string == "delete_task_expired" {
|
|
|
if let model = event.data as? TSActionInfoModel{
|
|
|
- TSRMShared.ptpDBHistory.deleteListModel(id: model.id)
|
|
|
+ dbHistory.deleteListModel(id: model.id)
|
|
|
updateDataView()
|
|
|
+ dataChangedNotification()
|
|
|
}
|
|
|
}
|
|
|
default:
|
|
@@ -140,6 +148,28 @@ extension TSPTPHistoryVC: TSSimpleCollectionViewDelegate {
|
|
|
extension TSPTPHistoryVC{
|
|
|
func removeAllHistoryList(){
|
|
|
TSGeneratePTPOperationQueue.shared.cancelAllOperations()
|
|
|
- TSRMShared.ptpDBHistory.delete()
|
|
|
+ dbHistory.delete()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+extension TSPTPHistoryVC{
|
|
|
+
|
|
|
+ var dbHistory:TSDBHistory{
|
|
|
+ switch style {
|
|
|
+ case .ptp:
|
|
|
+ return TSRMShared.ptpDBHistory
|
|
|
+ case .ttp:
|
|
|
+ return TSRMShared.ttpDBHistory
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func dataChangedNotification(){
|
|
|
+ switch style {
|
|
|
+ case .ptp:
|
|
|
+ NotificationCenter.default.post(name: .kPTPDataChanged, object: nil)
|
|
|
+ case .ttp:
|
|
|
+ NotificationCenter.default.post(name: .kTTPDataChanged, object: nil)
|
|
|
+ }
|
|
|
}
|
|
|
}
|