Explorar el Código

feat:新增左滑删除

kailen hace 1 mes
padre
commit
945c8a4444

+ 3 - 3
Podfile.lock

@@ -178,7 +178,7 @@ CHECKOUT OPTIONS:
     :git: https://gitee.com/WanlanNeel/tsvideo-kit.git
 
 SPEC CHECKSUMS:
-  ADManager: 82b2c255aadfb314141275088e13287ccc3dcd14
+  ADManager: 69cd1b8805b2e64a72315ed2abfa1f1c02f8f879
   AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58
   Alamofire: 7193b3b92c74a07f85569e1a6c4f4237291e7496
   BetterSegmentedControl: 09607b27861d49cbce48b7673b74f9150a3d371a
@@ -198,11 +198,11 @@ SPEC CHECKSUMS:
   SJVideoPlayer: 4f09814f58522e0975cb2dccfda925f6c8643467
   SnapKit: d612e99e678a2d3b95bf60b0705ed0a35c03484a
   SVProgressHUD: 4837c74bdfe2e51e8821c397825996a8d7de6e22
-  TSVideoKit: 922402ea051d72e78224f22d37c10fdb2e378f60
+  TSVideoKit: 16761d4bf8bb9e8af192459ae9eb01a213fc1531
   TYCyclePagerView: 2b051dade0615c70784aa34f40c646feeddb7344
   TZImagePickerController: d084a7b97c82d387e7669dd86dc9a9057500aacf
   YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
 
 PODFILE CHECKSUM: 436b32429cb708cca90f47b70a0a376c1a6e0417
 
-COCOAPODS: 1.16.2
+COCOAPODS: 1.15.2

+ 11 - 11
TSLiveWallpaper/Business/AdMob/ADScene.swift

@@ -16,20 +16,20 @@ import Foundation
 // TODO: !!!
 
 // #if DEBUG
-// private let GAD_ID_Launch                   = "ca-app-pub-3940256099942544/5575463023"
-// private let GAD_ID_Search_Insert            = "ca-app-pub-3940256099942544/4411468910"
-// private let GAD_ID_Play_Insert              = "ca-app-pub-3940256099942544/4411468910"
-// private let GAD_ID_Download_Reward          = "ca-app-pub-3940256099942544/1712485313"
+ private let GAD_ID_Launch                   = "ca-app-pub-3940256099942544/5575463023"
+ private let GAD_ID_Search_Insert            = "ca-app-pub-3940256099942544/4411468910"
+ private let GAD_ID_Play_Insert              = "ca-app-pub-3940256099942544/4411468910"
+ private let GAD_ID_Download_Reward          = "ca-app-pub-3940256099942544/1712485313"
 // #else
 
 // 开屏广告
-private let GAD_ID_Launch = "ca-app-pub-4941656534177879/5488145330"
-// 点击搜索时弹出的插屏广告
-private let GAD_ID_Search_Insert = "ca-app-pub-4941656534177879/9397376852"
-// 播放视频时弹出的插屏广告
-private let GAD_ID_Play_Insert = "ca-app-pub-4941656534177879/2201413111"
-// 下载视频弹出的激励广告
-private let GAD_ID_Download_Reward = "ca-app-pub-4941656534177879/9888331446"
+//private let GAD_ID_Launch = "ca-app-pub-4941656534177879/5488145330"
+//// 点击搜索时弹出的插屏广告
+//private let GAD_ID_Search_Insert = "ca-app-pub-4941656534177879/9397376852"
+//// 播放视频时弹出的插屏广告
+//private let GAD_ID_Play_Insert = "ca-app-pub-4941656534177879/2201413111"
+//// 下载视频弹出的激励广告
+//private let GAD_ID_Download_Reward = "ca-app-pub-4941656534177879/9888331446"
 // #endif
 
 enum ADScene: CaseIterable, ADSceneProtocol {

+ 37 - 0
TSLiveWallpaper/Business/TSMusic/List/ViewModel/SongListViewModel.swift

@@ -98,6 +98,43 @@ extension SongListViewModel: UITableViewDataSource {
         }
     }
     
+    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
+        if indexPath.section == 0 {
+            if indexPath.row < unFinishedVideo.count {
+                let viewModel = unFinishedVideo[indexPath.row]
+                if let video = viewModel.dataVideo, let videoId = video.videoId {
+                    TSVideoOperator.shared.downloadManager.cancelTask(id: videoId) {
+                        self.requestData()
+                    }
+                }
+            }
+        } else {
+            if indexPath.row < videos.count {
+                let ac = UIAlertController(title: nil,
+                                           message: "Are you sure to delete".localized(), preferredStyle: .alert)
+                ac.addAction(UIAlertAction(title: "Cancel".localized(), style: .cancel))
+                ac.addAction(UIAlertAction(title: "Delete".localized(), style: .destructive, handler: { _ in
+
+                    let video = self.videos[indexPath.row]
+                    /// 如果删除视频为当前播放视频,那么minibar 要初始化
+                    if video.videoId == PlayerManager.shared.currentVideo?.videoId {
+                        TSVideoOperator.shared.playerViewModel.clearCurrenVideo()
+                    }
+                    /// 歌单也要删除
+                    PlayerManager.shared.player?.playControl.viewModel.currentVideos.removeAll {
+                        $0.videoId == video.videoId
+                    }
+
+                    TSVideoOperator.shared.dataManager.deleteVideo(video: video) { _ in
+                        self.requestData()
+                    }
+
+                }))
+                PlayerManager.shared.rootVc?.present(ac, animated: true)
+            }
+        }
+    }
+    
     /// 加入选中列表
     /// - Parameter video: video
     func addToSelectedList(video: TSVideo) {