|
@@ -120,7 +120,7 @@ class TSAIRintoneVC: TSBaseVC {
|
|
if let userInfo = notification.userInfo as? [String: Any], let uuid = userInfo["uuid"] as? String,let state = userInfo["state"] as? TSProgressState {
|
|
if let userInfo = notification.userInfo as? [String: Any], let uuid = userInfo["uuid"] as? String,let state = userInfo["state"] as? TSProgressState {
|
|
dePrint("TSBaseOperation stateDatauPblished 收到 = \(state)")
|
|
dePrint("TSBaseOperation stateDatauPblished 收到 = \(state)")
|
|
switch state {
|
|
switch state {
|
|
- case .start:
|
|
|
|
|
|
+ case .start, .success(_),.failed(_),.none:
|
|
self.viewModel.updateRecentData()
|
|
self.viewModel.updateRecentData()
|
|
self.updateGeneratedHistory()
|
|
self.updateGeneratedHistory()
|
|
// case .start, .success(_),.failed(_):
|
|
// case .start, .success(_),.failed(_):
|
|
@@ -137,6 +137,7 @@ class TSAIRintoneVC: TSBaseVC {
|
|
func updateListView(){
|
|
func updateListView(){
|
|
collectionView.reloadData()
|
|
collectionView.reloadData()
|
|
}
|
|
}
|
|
|
|
+
|
|
func updateGeneratedHistory(){
|
|
func updateGeneratedHistory(){
|
|
if collectionView.numberOfSections != viewModel.modelList.count {
|
|
if collectionView.numberOfSections != viewModel.modelList.count {
|
|
collectionView.reloadData()
|
|
collectionView.reloadData()
|
|
@@ -147,30 +148,6 @@ class TSAIRintoneVC: TSBaseVC {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
- func updateGeneratedList(num:Int){
|
|
|
|
-// **reloadData()**:简单易用,适合数据量小且不需要动画的场景。
|
|
|
|
-// **performBatchUpdates**:更高效且支持动画,适合数据量大或需要动画的场景。
|
|
|
|
-// **UICollectionViewDiffableDataSource**:iOS 13 及以上版本的最佳选择,自动处理数据变化并支持动画。
|
|
|
|
-// let maxNum = num > 2 ? 2 : num
|
|
|
|
-
|
|
|
|
- if collectionView.numberOfSections != viewModel.modelList.count {
|
|
|
|
- collectionView.reloadData()
|
|
|
|
- }
|
|
|
|
- if let historyModel = viewModel.modelList.first,historyModel.type == .history{
|
|
|
|
- UIView.performWithoutAnimation {
|
|
|
|
- collectionView.reloadSections(IndexSet(integer: 0))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-// var array:[IndexPath] = []
|
|
|
|
-// for i in 0..<1 {
|
|
|
|
-// array.append(IndexPath(item: i, section: 0))
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// UIView.performWithoutAnimation {
|
|
|
|
-// collectionView.reloadItems(at: array)
|
|
|
|
-// }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
extension TSAIRintoneVC: UICollectionViewDataSource ,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout {
|
|
extension TSAIRintoneVC: UICollectionViewDataSource ,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout {
|
|
@@ -195,15 +172,13 @@ extension TSAIRintoneVC: UICollectionViewDataSource ,UICollectionViewDelegate,UI
|
|
let cell = cell as? TSAIRintoneHistoryCell
|
|
let cell = cell as? TSAIRintoneHistoryCell
|
|
{
|
|
{
|
|
cell.delegate = self
|
|
cell.delegate = self
|
|
-
|
|
|
|
|
|
+ cell.setRingBtn.indexPath = indexPath
|
|
|
|
+ cell.setRingBtn.addTarget(self, action: #selector(clickSetRingBtn(_ :)), for: .touchUpInside)
|
|
if let model = itemModel as? TSActionInfoModel {
|
|
if let model = itemModel as? TSActionInfoModel {
|
|
cell.model = model
|
|
cell.model = model
|
|
}else if let ringModel = itemModel as? TSRingModel {
|
|
}else if let ringModel = itemModel as? TSRingModel {
|
|
cell.ringModel = ringModel
|
|
cell.ringModel = ringModel
|
|
}
|
|
}
|
|
-
|
|
|
|
- cell.setRingBtn.indexPath = indexPath
|
|
|
|
- cell.setRingBtn.addTarget(self, action: #selector(clickSetRingBtn(_ :)), for: .touchUpInside)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return cell
|
|
return cell
|
|
@@ -303,6 +278,17 @@ extension TSAIRintoneVC: SwipeCollectionViewCellDelegate {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if let sectionModel = self.viewModel.modelList.safeObj(At: indexPath.section),
|
|
|
|
+ let model = sectionModel.list.safeObj(At: indexPath.item){
|
|
|
|
+ if let model = model as? TSActionInfoModel {
|
|
|
|
+ switch model.actionStatus {
|
|
|
|
+ case .pending,.running:
|
|
|
|
+ return nil
|
|
|
|
+ default:break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// 删除操作
|
|
// 删除操作
|
|
let deleteAction = SwipeAction(style: .destructive, title: nil) {[weak self] action, indexPath in
|
|
let deleteAction = SwipeAction(style: .destructive, title: nil) {[weak self] action, indexPath in
|
|
guard let self = self else { return }
|
|
guard let self = self else { return }
|
|
@@ -310,14 +296,18 @@ extension TSAIRintoneVC: SwipeCollectionViewCellDelegate {
|
|
if let sectionModel = self.viewModel.modelList.safeObj(At: indexPath.section),
|
|
if let sectionModel = self.viewModel.modelList.safeObj(At: indexPath.section),
|
|
let model = sectionModel.list.safeObj(At: indexPath.item){
|
|
let model = sectionModel.list.safeObj(At: indexPath.item){
|
|
if let model = model as? TSActionInfoModel {
|
|
if let model = model as? TSActionInfoModel {
|
|
- collectionView.performBatchUpdates({
|
|
|
|
- self.viewModel.removeModel(model: model)
|
|
|
|
- if sectionModel.list.count == 0 {
|
|
|
|
- collectionView.deleteSections([indexPath.section])
|
|
|
|
- }else{
|
|
|
|
- collectionView.deleteItems(at: [indexPath])
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+// collectionView.performBatchUpdates({
|
|
|
|
+// self.viewModel.removeModel(model: model)
|
|
|
|
+// if sectionModel.list.count == 0 {
|
|
|
|
+// collectionView.deleteSections([indexPath.section])
|
|
|
|
+// }else{
|
|
|
|
+// collectionView.deleteItems(at: [indexPath])
|
|
|
|
+// }
|
|
|
|
+// })
|
|
|
|
+
|
|
|
|
+ self.viewModel.removeModel(model: model)
|
|
|
|
+ collectionView.reloadData()
|
|
|
|
+
|
|
TSBusinessAudioPlayer.shared.stop()
|
|
TSBusinessAudioPlayer.shared.stop()
|
|
}
|
|
}
|
|
}
|
|
}
|