ソースを参照

修改下载记录删除交互

zhongbaojian 5 年 前
コミット
074d392161

+ 4 - 4
SuperShow.xcodeproj/project.pbxproj

@@ -3853,7 +3853,7 @@
 				CODE_SIGN_ENTITLEMENTS = SuperShow/SuperShow.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1114;
+				CURRENT_PROJECT_VERSION = 1117;
 				DEVELOPMENT_TEAM = 6DTLD5LADX;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4016,7 +4016,7 @@
 				CODE_SIGN_ENTITLEMENTS = SuperShow/SuperShow.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1114;
+				CURRENT_PROJECT_VERSION = 1117;
 				DEVELOPMENT_TEAM = 6DTLD5LADX;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4234,7 +4234,7 @@
 				CODE_SIGN_ENTITLEMENTS = SuperShow/SuperShow.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1114;
+				CURRENT_PROJECT_VERSION = 1117;
 				DEVELOPMENT_TEAM = 6DTLD5LADX;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4458,7 +4458,7 @@
 				CODE_SIGN_ENTITLEMENTS = SuperShow/SuperShow.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1114;
+				CURRENT_PROJECT_VERSION = 1117;
 				DEVELOPMENT_TEAM = 6DTLD5LADX;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (

+ 42 - 14
SuperShow/UI/Profile/Collection/WSSProfileMyTemplateViewController.swift

@@ -51,6 +51,7 @@ class WSSProfileMyTemplateViewController: MTViewController {
 
     fileprivate var dataArray = [WSSCommonTemplateModel]()
     fileprivate var timeline: Int64 = 0
+    fileprivate var isEditingMode: Bool = false
 
     convenience init() {
         self.init(nibName: nil, bundle: nil)
@@ -106,46 +107,57 @@ private extension WSSProfileMyTemplateViewController {
     }
 
     func setupNavigationBar() {
+        if mode == false {
+            // 已购模板
+            setupOnlyBackNavigationBar()
+            return
+        }
+
         ojs_navBarView?.leftOneButton.contentHorizontalAlignment = .left
         ojs_navBarView?.rightOneButton.contentHorizontalAlignment = .right
 
         ojs_navBarView?.leftOneButton.width = 50.0
         ojs_navBarView?.leftOneButton.left = OJAStyle.LRCommonMargin
+        ojs_navBarView?.leftOneButton.titleLabel?.font = OJAFont.font16
+        ojs_navBarView?.leftOneButton.setTitleColor(OJAStyle.mainColor, for: .normal)
 
+        ojs_navBarView?.rightOneButton.titleLabel?.font = OJAFont.font16
         ojs_navBarView?.rightOneButton.width = 50.0
         ojs_navBarView?.rightOneButton.right = kOJSScreenWidth - OJAStyle.LRCommonMargin
+        ojs_navBarView?.rightOneButton.setTitleColor(OJAStyle.mainColor, for: .normal)
 
         switchNavigationBarMode(false)
     }
 
     func switchNavigationBarMode(_ mode: Bool) {
+        ojs_navBarView?.viewType = .type1_1
+
         if mode {
             // 编辑状态
-            ojs_navBarView?.viewType = .type1_1
-
-            ojs_navBarView?.leftOneButton.titleLabel?.font = OJAFont.font16
             ojs_navBarView?.leftOneButton.setTitle("全选", for: .normal)
             ojs_navBarView?.leftOneButton.setImage(nil, for: .normal)
-            ojs_navBarView?.leftOneButton.setTitleColor(OJAStyle.mainColor, for: .normal)
             ojs_navBarView?.leftOneButton.addCallback({ [weak self] _ in
                 self?.checkAllItem(true)
             })
 
-            ojs_navBarView?.rightOneButton.titleLabel?.font = OJAFont.font16
             ojs_navBarView?.rightOneButton.setTitle("完成", for: .normal)
-            ojs_navBarView?.rightOneButton.setTitleColor(OJAStyle.mainColor, for: .normal)
             ojs_navBarView?.rightOneButton.addCallback({ [weak self] _ in
+                self?.enterEditing(false)
                 self?.checkAllItem(false)
             })
 
         } else {
             // 普通状态
-            ojs_navBarView?.viewType = .type1_0
             ojs_navBarView?.leftOneButton.setImage(R.image.nav_back(), for: UIControl.State.normal)
             ojs_navBarView?.leftOneButton.setTitle(nil, for: .normal)
             ojs_navBarView?.leftOneButton.addCallback { [unowned self] _ in
                 self.exitPage()
             }
+
+            ojs_navBarView?.rightOneButton.setTitle("管理", for: .normal)
+            ojs_navBarView?.rightOneButton.addCallback({ [weak self] _ in
+                self?.enterEditing(true)
+            })
         }
 
         bringOJSNavBarViewToFront()
@@ -198,6 +210,10 @@ private extension WSSProfileMyTemplateViewController {
                 }
                 self.timeline = listModel.timeline
                 self.collectionView.reloadData()
+                
+                if self.dataArray.count == 0 && self.isEditingMode = true{
+                    self.switchNavigationBarMode(false)
+                }
             }
 
             if self.dataArray.count > 0 {
@@ -216,6 +232,16 @@ private extension WSSProfileMyTemplateViewController {
         })
     }
 
+    func enterEditing(_ flag: Bool) {
+        isEditingMode = flag
+
+        switchNavigationBarMode(flag)
+        if flag {
+            collectionView.reloadData()
+            refreshSelectedInfo()
+        }
+    }
+
     func checkAllItem(_ flag: Bool) {
         dataArray.forEach({ $0.selected = flag })
 
@@ -228,8 +254,6 @@ private extension WSSProfileMyTemplateViewController {
 
         bottomActionView.changeCount(selectedModels.count)
         bottomActionView.isHidden = selectedModels.count == 0
-
-        switchNavigationBarMode(selectedModels.count > 0)
     }
 
     func deleteRecord() {
@@ -237,14 +261,18 @@ private extension WSSProfileMyTemplateViewController {
         if selectedModels.count > 0 {
             let ids = selectedModels.map({ $0.templateId })
 
+            WSSHub.showHub("请稍后...")
             OJARequest<WSSAPITemplateRequest, OJABaseResponseBean>.sendRequest(.deleteDownloadRecord(templateIds: ids, isAll: false), callback: { _, _, err in
-                if err == nil {
-                    self.timeline = 0
-                    self.loadNetworkData()
+                WSSHub.dismissHub()
+
+                showHud(withOnlyText: "删除成功")
 
+                if err == nil {
                     self.bottomActionView.changeCount(0)
                     self.bottomActionView.isHidden = true
-                    self.switchNavigationBarMode(false)
+
+                    self.timeline = 0
+                    self.loadNetworkData()
 
                     WSSUserTool.shared.refreshUserInfo {
                         //
@@ -267,7 +295,7 @@ extension WSSProfileMyTemplateViewController: UICollectionViewDataSource {
 
         if mode == true {
             // 下载模板模式,只有在下载模板列表可以勾选
-            cell.isShowCheck = true
+            cell.isShowCheck = isEditingMode
             cell.checkEventHandle = { [weak self] in
                 self?.refreshSelectedInfo()
             }