Explorar o código

修改 1.5(1)bug

100Years hai 3 semanas
pai
achega
d2fae57f71

+ 2 - 2
AIRingtone.xcodeproj/project.pbxproj

@@ -1325,7 +1325,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1;
+				CURRENT_PROJECT_VERSION = 2;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AIRingtone/Info.plist;
@@ -1367,7 +1367,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1;
+				CURRENT_PROJECT_VERSION = 2;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AIRingtone/Info.plist;

+ 1 - 1
AIRingtone/Business/TSAIPhotoVC/TSAIPhotoChildVC/TSAIPhotoChildVC.swift

@@ -101,7 +101,7 @@ class TSAIPhotoChildVC: TSBaseVC {
             if let userInfo = notification.userInfo as? [String: Any], let uuid = userInfo["uuid"] as? String,let state = userInfo["state"] as? TSProgressState {
                 dePrint("TSBaseOperation stateDatauPblished 收到 = \(state)")
                 switch state {
-                case .start, .success(_),.failed(_):
+                case .start, .success(_),.failed(_),.none:
                     self.vm.setRecentData()
                     self.reloadView()
                 default:break

+ 11 - 0
AIRingtone/Business/TSAIPhotoVC/TSAIPhotoChildVC/View/TSAIPhotoImageCell.swift

@@ -140,6 +140,11 @@ class TSAIPhotoImageCell: TSBaseCollectionCell {
   
     }
     
+    override func prepareForReuse() {
+        super.prepareForReuse()
+        showImageView.image = nil
+    }
+    
 }
 
 class TSImageGenerateView:TSBaseView {
@@ -165,6 +170,7 @@ class TSImageGenerateView:TSBaseView {
     override func creatUI() {
         backgroundColor = .cardColor
 
+        contentView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickContentView)))
         
         let bgImageView = UIImageView.createImageView(imageName: "ringPhotoBg",contentMode: .scaleAspectFill)
         contentView.addSubview(bgImageView)
@@ -188,6 +194,11 @@ class TSImageGenerateView:TSBaseView {
         
     }
     
+    @objc func clickContentView() {
+        if refreshBtn.isHidden == false{
+            refreshHandel?()
+        }
+    }
     func setProgress(progress:Float) {
         refreshBtn.isHidden = true
         let progressInt = Int(progress*100)

+ 1 - 1
AIRingtone/Business/TSAIPhotoVC/TSGeneralPicVC/TSGeneralPicVC.swift

@@ -46,7 +46,7 @@ class TSGeneralPicVC: TSBottomAlertVC {
     //############################## 生成动画 ##############################
     lazy var generateInView : TSCommonloadingView = {
         let generateInView = TSCommonloadingView()
-        generateInView.timeLabel.text = "~ 1min"
+//        generateInView.timeLabel.text = "~ 1min"
         //generateInView.cancelBtn.addTarget(self, action: #selector(closePage), for: .touchUpInside)
         generateInView.backstageBtn.addTarget(self, action: #selector(clickBackstageBtn), for: .touchUpInside)
         return generateInView

+ 1 - 0
AIRingtone/Business/TSAIPhotoVC/TSTextGeneralPicVC/View/TSPromptStyleView.swift

@@ -142,6 +142,7 @@ class TSPTPSelectStyleCCell: TSBaseCollectionCell {
 
     lazy var textLabel: UILabel = {
         let textLabel = UILabel.createLabel(font: .font(size: 14),textColor: .white,textAlignment: .center,numberOfLines: 0)
+        textLabel.addShadow(shadowColor: UIColor.black.cgColor, shadowOffset: CGSize(width: 0, height: 2), shadowRadius: 2, shadowOpacity: 0.3)
         return textLabel
     }()
     

+ 113 - 119
AIRingtone/Business/TSAIRintoneVC/TSAIRintoneVC/View/TSAIRintoneHistoryCell.swift

@@ -26,32 +26,17 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell  {
 
     lazy var setRingBtn: TSUIExpandedTouchButton = {
         let setRingBtn = TSUIExpandedTouchButton()
-        setRingBtn.setUpButton(image: UIImage(named: "ai_setRing_icon")){[weak self]  in
-            guard let self = self else { return }
-            actionHandler(any: "SetNow")
-        }
+        setRingBtn.setUpButton(image: UIImage(named: "ai_setRing_icon"))
         setRingBtn.setImage(UIImage(named: "ai_setRing_icon"), for: .normal)
         return setRingBtn
     }()
     
     lazy var ringView: TSRingToneCellView = {
         let ringToneView = TSRingToneCellView()
+        ringToneView.cornerRadius = 0.0
         ringToneView.clickPlayHandel = { [weak self] isplay in
             guard let self = self else { return }
-            
-            if playSelf{
-                if TSBusinessAudioPlayer.shared.isLoading{
-                    return
-                }
-                if TSBusinessAudioPlayer.shared.isPlaying{
-                    TSBusinessAudioPlayer.shared.stop()
-                }else{
-                    TSBusinessAudioPlayer.shared.playUrlString(modelUrlString,indexPath: indexPath)
-                }
-                
-            }else{
-                TSBusinessAudioPlayer.shared.playUrlString(modelUrlString,indexPath: indexPath)
-            }
+            clickPlay()
         }
         return ringToneView
     }()
@@ -69,7 +54,6 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell  {
     }()
     
     
-    
     lazy var exampleView: UIView = {
         let exampleView = UIView()
         exampleView.backgroundColor = "#7E57F4".uiColor
@@ -100,87 +84,20 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell  {
     
     var model:TSActionInfoModel?{
         didSet{
-            guard let model = model else { return }
-            if let rintoneOperation = TSGenerateRintoneOperationQueue.shared.findOperation(uuid: model.uuid) as? TSGenerateRintoneOperation {
-                    rintoneOperation.currentActionInfoModelChanged = { [weak self] actionInfoModel in
-                        guard let self = self else { return }
-                        DispatchQueue.main.async {
-                            self.updataActionInfoModelView(model: actionInfoModel)
-                        }
-                    }
-            }
-
-            updataActionInfoModelView(model: model)
-            dePrint("model actionStatus 收到=\(model.actionStatus)")
+            modelDidSet()
         }
     }
-    
-    func updataActionInfoModelView(model:TSActionInfoModel){
-        
-        if model.modelType == .example {
-            model.actionStatus = .success
-        }
-        
-        switch model.actionStatus {
-        case .pending,.running:
-            generateView.isHidden = false
-            generateView.setProgress(progress: model.percent)
-        case .success:
-            generateView.isHidden = true
-            
-            ringView.timeLab.text = Float(model.request.duration).floatToMinuteSecond()
-            ringView.nameLab.text = model.response.title
-            ringView.setCoverImageView(urlString: model.response.coverUrl)
-            exampleView.isHidden = model.modelType != .example
-            vipView.isHidden = true
-            
-            self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
-            
-        case .failed:
-            generateView.isHidden = false
-            generateView.setFail()
-        }
-    }
-    
+
     var ringModel:TSRingModel?{
         didSet{
-            guard let ringModel = ringModel else { return }
-
-            ringView.timeLab.text = Float(ringModel.duration).floatToMinuteSecond()
-            ringView.nameLab.text = ringModel.title
-            ringView.setCoverImageView(urlString: "")
-            exampleView.isHidden = true
-            generateView.isHidden = true
-            vipView.isHidden = !ringModel.vip
-            self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
+            ringModelDidSet()
         }
     }
      
-    var playSelf:Bool{
-        return TSBusinessAudioPlayer.shared.isPlayURLString(string: modelUrlString,indexPath: indexPath)
-    }
-
-    var modelUrlString:String{
-        var urlString:String = ""
-        if let model = model{
-            urlString = model.response.musicUrl
-        }else if let ringModel = ringModel{
-            urlString = ringModel.audioUrl
-        }
-        return urlString
-    }
-
     func creatUI() {
         cornerRadius = 16.0
         backgroundColor = .cardColor
-  
-        contentView.addSubview(exampleView)
-        exampleView.snp.makeConstraints { make in
-            make.trailing.equalToSuperview()
-            make.top.equalTo(0)
-            make.height.equalTo(20)
-        }
-  
+        
         contentView.addSubview(ringView)
         ringView.snp.makeConstraints { make in
             make.edges.equalToSuperview()
@@ -199,7 +116,13 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell  {
             make.width.height.equalTo(24)
         }
         
-        
+        contentView.addSubview(exampleView)
+        exampleView.snp.makeConstraints { make in
+            make.trailing.equalToSuperview()
+            make.top.equalTo(0)
+            make.height.equalTo(20)
+        }
+  
         contentView.addSubview(generateView)
         generateView.snp.makeConstraints { make in
             make.edges.equalToSuperview()
@@ -222,49 +145,120 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell  {
 //        cancellable.removeAll()
     }
     
-    func changePlayerState(state:TSBusinessAudioPlayer.PlayerState){
-        dePrint("changePlayerState = \(state)")
-        if playSelf == false {
-            ringView.handelAudioPlayerStateChange(state: .stop)
-            return
-        }
-        ringView.handelAudioPlayerStateChange(state: state)
-    }
-
     deinit {
         NotificationCenter.default.removeObserver(self)
     }
+
+}
+
+
+extension TSAIRintoneHistoryCell {
     
-    var indexPath:IndexPath? {
-        return setRingBtn.indexPath
+    func modelDidSet(){
+        guard let model = model else { return }
+        if let rintoneOperation = TSGenerateRintoneOperationQueue.shared.findOperation(uuid: model.uuid) as? TSGenerateRintoneOperation {
+            rintoneOperation.currentActionInfoModelChanged = { [weak self] actionInfoModel in
+                guard let self = self else { return }
+                DispatchQueue.main.async {
+                    self.updataActionInfoModelView(model: actionInfoModel)
+                }
+            }
+        }
+
+        updataActionInfoModelView(model: model)
+        dePrint("model actionStatus 收到=\(model.actionStatus)")
     }
+    
+    func ringModelDidSet(){
+        guard let ringModel = ringModel else { return }
+
+        ringView.timeLab.text = Float(ringModel.duration).floatToMinuteSecond()
+        ringView.nameLab.text = ringModel.title
+        ringView.setCoverImageView(urlString: "")
+        exampleView.isHidden = true
+        generateView.isHidden = true
+        vipView.isHidden = !ringModel.vip
+        self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
+    }
+    
 }
 
-extension TSAIRintoneHistoryCell : TSComponentView {
+
+extension TSAIRintoneHistoryCell {
+    func clickPlay() {
+        if playSelf{
+            if TSBusinessAudioPlayer.shared.isLoading{
+                return
+            }
+            if TSBusinessAudioPlayer.shared.isPlaying{
+                TSBusinessAudioPlayer.shared.stop()
+            }else{
+                TSBusinessAudioPlayer.shared.playUrlString(modelUrlString,indexPath: indexPath)
+            }
+            
+        }else{
+            TSBusinessAudioPlayer.shared.playUrlString(modelUrlString,indexPath: indexPath)
+        }
+    }
     
-    func renderView(with object: Any?, component: TSCollectionViewComponent, attributes: [String : Any]?) {
-        self.colComponent = component
-        self.colAttributes = attributes
+
+    func changePlayerState(state:TSBusinessAudioPlayer.PlayerState){
+        if playSelf == false {
+            if ringView.isPlay == true ||
+                ringView.isloading == true
+            {
+                ringView.handelAudioPlayerStateChange(state: .stop)
+            }
+            return
+        }
+//        dePrint("changePlayerState = \(state)")
+        ringView.handelAudioPlayerStateChange(state: state)
+    }
+    
+    
+    func updataActionInfoModelView(model:TSActionInfoModel){
         
+        if model.modelType == .example {
+            model.actionStatus = .success
+        }
         
-        if let itemModel = object as? TSColVVMItemModel{
-            if let dataModel = itemModel.dataModel as? TSRingModel{
-                ringModel = dataModel
-            }
+        switch model.actionStatus {
+        case .pending,.running:
+            generateView.isHidden = false
+            generateView.setProgress(progress: model.percent)
+        case .success:
+            generateView.isHidden = true
+            
+            ringView.timeLab.text = Float(model.request.duration).floatToMinuteSecond()
+            ringView.nameLab.text = model.response.title
+            ringView.setCoverImageView(urlString: model.response.coverUrl)
+            exampleView.isHidden = model.modelType != .example
+            vipView.isHidden = true
+            
+            self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
+            
+        case .failed:
+            generateView.isHidden = false
+            generateView.setFail()
         }
+    }
 
+    var playSelf:Bool{
+        return TSBusinessAudioPlayer.shared.isPlayURLString(string: modelUrlString,indexPath: indexPath)
     }
-    
-    public var itemActionHandler: ((Any?, IndexPath) -> Void)?{
-        if let colComponent = colComponent,let itemActionHandler = colComponent.itemActionHandler {
-            return itemActionHandler
+
+    var modelUrlString:String{
+        var urlString:String = ""
+        if let model = model{
+            urlString = model.response.musicUrl
+        }else if let ringModel = ringModel{
+            urlString = ringModel.audioUrl
         }
-        return nil
+        return urlString
     }
     
-    public func actionHandler(any:Any?){
-        if let sectionActionHandler = itemActionHandler ,let indexPath = indexPath{
-            sectionActionHandler(any,indexPath)
-        }
+    
+    var indexPath:IndexPath? {
+        return setRingBtn.indexPath
     }
 }

+ 1 - 1
AIRingtone/Business/TSAIRintoneVC/TSAIRintoneVC/ViewModel/TSAIRintoneVM.swift

@@ -44,7 +44,7 @@ class TSAIRintoneVM {
     
     //生成的历史
     lazy var aiRintoneHistoryModel: TSAIRintoneHistoryModel = {
-        let model = TSAIRintoneHistoryModel(title: "Generate History", list:TSAIRintoneHistory.listModelArray,type: .history)
+        let model = TSAIRintoneHistoryModel(title: "Generate History", list:Array(TSAIRintoneHistory.listModelArray.prefix(2)),type: .history)
         return model
     }()
     

+ 2 - 1
AIRingtone/Business/TSAIRintoneVC/TSGeneralRintoneVC/TSGeneralRintoneVC.swift

@@ -33,6 +33,7 @@ class TSGeneralRintoneVC: TSBottomAlertVC {
     
     lazy var ringView: TSRingToneCellView = {
         let ringToneView = TSRingToneCellView()
+        ringToneView.isSelectedChangeColor = false
         ringToneView.clickPlayHandel = { [weak self] play  in
             guard let self = self else { return }
             clickPlay()
@@ -43,7 +44,7 @@ class TSGeneralRintoneVC: TSBottomAlertVC {
     //############################## 生成动画 ##############################
     lazy var generateInView : TSCommonloadingView = {
         let generateInView = TSCommonloadingView()
-        generateInView.timeLabel.text = "~ 4min"
+//        generateInView.timeLabel.text = "~ 4min"
 //        generateInView.cancelBtn.addTarget(self, action: #selector(closePage), for: .touchUpInside)
         generateInView.backstageBtn.addTarget(self, action: #selector(clickBackstageBtn), for: .touchUpInside)
         return generateInView

+ 0 - 44
AIRingtone/Business/TSCollectionViewVM/TSCollectionViewVM+Config.swift

@@ -244,47 +244,3 @@ let ringCategoriesConfig:TSColVVMSizeConfig = {
     
     return config
 }()
-
-
-//MARK: ring list 配置
-let ringListConfig:TSColVVMSizeConfig = {
-
-    let sectionInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
-    let lineSpacing = 13.0
-    let itemSpacing = 13.0
-    
-    let originalSize = CGSizeMake(343.0, 72)
-    
-    let cellRowNum = 1
-    
-    let originalScale = originalSize.width/originalSize.height
-    var w = k_ScreenWidth-sectionInset.left-sectionInset.right
-    w = w - lineSpacing * CGFloat((cellRowNum-1))
-    w = w/CGFloat(cellRowNum)
-    let h = w/originalScale
-    
-    let cellSize = CGSizeMake(w, h)
-    let cellClass = TSAIRintoneHistoryCell.self
-    
-    let headerViewSize = CGSizeMake(k_ScreenWidth, 0)
-    let headerView = TSColVVMSectionHeaderView.self
-
-    let footerViewSize = CGSizeMake(k_ScreenWidth, 0)
-    let footerView = UICollectionReusableView.self
-    
-    var config = TSColVVMSizeConfig(
-        sectionInset: sectionInset,
-        lineSpacing: lineSpacing,
-        itemSpacing: itemSpacing,
-        originalSize: originalSize,
-        cellRowNum: cellRowNum,
-        cellSize: cellSize,
-        cellClass: cellClass,
-        headerViewSize: headerViewSize,
-        headerView: headerView,
-        footerViewSize: footerViewSize,
-        footerView: footerView
-    )
-    
-    return config
-}()

+ 0 - 4
AIRingtone/Business/TSCollectionViewVM/TSCollectionViewVM.swift

@@ -17,7 +17,6 @@ enum TSColVVMStyple : Int {
     case photoHistory    //生成头像的历史记录
     
     case ringCategories    //铃声分类
-//    case ringList       //铃声列表
     
     var config:TSColVVMSizeConfig {
         switch self {
@@ -31,8 +30,6 @@ enum TSColVVMStyple : Int {
             return photoHistoryConfig
         case .ringCategories:
             return ringCategoriesConfig
-        case .ringList:
-            return ringListConfig
         }
     }
     
@@ -48,7 +45,6 @@ enum TSColVVMStyple : Int {
         config.itemSpacing
     }
 
-    
     var cellSize:CGSize {
         config.cellSize
     }

+ 1 - 124
AIRingtone/Business/TSDiscoverVC/TSDiscoverListVC/VM/TSDiscoverListVM.swift

@@ -9,16 +9,6 @@
 import ObjectMapper
 class TSDiscoverListVM {
 
-//    var colDataArray:[TSComponent] = [TSComponent]()
-//    
-//    lazy var contentSecitonModel: TSColVVMSectionModel = {
-//        let contentSeciton = TSColVVMSectionModel()
-//        contentSeciton.style = .ringList
-//        return contentSeciton
-//    }()
-//    
-//    
-  
     lazy var modelList: [TSAIRintoneHistoryModel] = {
         return [discoverList]
     }()
@@ -27,10 +17,7 @@ class TSDiscoverListVM {
         let model = TSAIRintoneHistoryModel(title: "Generate History", list:[])
         return model
     }()
-    
-//    var listModelArray: [TSRingModel] = []
-    
-    
+
     init(categoryID: String,animationView:UIView) {
         self.categoryID = categoryID
         self.animationView = animationView
@@ -115,114 +102,4 @@ extension TSDiscoverListVM {
             }
         }
     }
-    
 }
-
-
-
-//
-//extension TSDiscoverListVM {
-//
-//    
-////    func setContentItemModels(){
-////        var array = [TSColVVMItemModel]()
-////        listModelArray.forEach { themeModel in
-////            array.append(getTSColVVMItemModel(model: themeModel))
-////        }
-////        contentSecitonModel.items = array
-////    }
-////    
-////    func appendContentItemModels(modelArray:[TSRingModel]){
-////        var array = [TSColVVMItemModel]()
-////        modelArray.forEach { themeModel in
-////            array.append(getTSColVVMItemModel(model: themeModel))
-////        }
-////        contentSecitonModel.items = contentSecitonModel.items + array
-////    }
-////    
-////    func getTSColVVMItemModel(model:TSRingModel)->TSColVVMItemModel{
-////        let itemModel = TSColVVMItemModel()
-////        itemModel.dataModel = model
-////        itemModel.style = .ringList
-////        return itemModel
-////    }
-//}
-// 
-//extension TSDiscoverListVM {
-//    
-//    func getData(complete:@escaping (Bool)->Void){
-//        pageNum = kPageNum
-//        getNetWorkData(useCache: true,animationView: animationView) { [weak self] modelArray,success  in
-//            guard let self = self else { return }
-//            if modelArray.count > 0 {
-//                listModelArray.removeAll()
-//                listModelArray.append(contentsOf: modelArray)
-//                setContentItemModels()
-//                complete(true)
-//            }else{
-//                complete(false)
-//            }
-//        }
-//    }
-//    
-//    /// 上拉刷新
-//    /// - Parameter complete: (是否成功)
-//    func reloadAllData(complete:@escaping (Bool)->Void){
-//        TSNetworkShared.removeCache(urlType:.rings)
-//        pageNum = kPageNum
-//        getNetWorkData(useCache: false,animationView: nil) {[weak self] modelArray,success  in
-//            guard let self = self else { return }
-//            if modelArray.count > 0 {
-//                listModelArray.removeAll()
-//                listModelArray.append(contentsOf: modelArray)
-//                setContentItemModels()
-//                complete(true)
-//            }else{
-//                complete(false)
-//            }
-//        }
-//    }
-//    
-//    /// 获取更多数据
-//    /// - Parameter complete: (是否成功,还有更多数据)
-//    func getMoreData(complete:@escaping (Bool,Bool)->Void){
-//        pageNum+=1
-//        getNetWorkData(useCache: true,animationView: nil) { [weak self] modelArray,success in
-//            guard let self = self else { return }
-//            if modelArray.count > 0 {
-//                listModelArray.append(contentsOf: modelArray)
-////                setContentItemModels()
-//                appendContentItemModels(modelArray: modelArray)
-//                complete(success,true)
-//            }else{
-//                complete(success,false)
-//            }
-//        }
-//    }
-//
-//    func getNetWorkData(useCache:Bool,animationView:UIView?,complete:@escaping ([TSRingModel],Bool)->Void){
-//        
-//        let parameters:[String:Any] = [
-//            "page_size":pageSize,
-//            "page":pageNum,
-//            "category_id":categoryID,
-//        ]
-//        
-//        _ = TSNetworkShared.get(
-//            urlType: .rings,
-//            parameters: parameters,
-//            animationView: animationView,
-//            useCache: useCache)
-//        {  data, error in
-//            if let result = kNetWorkResultArraySuccess(data: data) {
-//                let modelArray = Mapper<TSRingModel>().mapArray(JSONArray: result)
-//                complete(modelArray,true)
-//            }else{
-//                complete([],false)
-//            }
-//        }
-//    }
-//    
-//}
-//
-

+ 1 - 0
AIRingtone/Business/TSThemeVC/TSThemeSetVC/TSThemeSetRingToneView.swift

@@ -14,6 +14,7 @@ class TSThemeSetRingToneView: TSThemeSetItemView {
         titleLabel.text = "Ringtone".localized
         numImageView.image = UIImage(named: "num_1")
         iconImageView.image = UIImage(named: "theme_icon_ringtone")
+        cellView.isSelectedChangeColor = false
         diyView.addSubview(cellView)
         cellView.snp.makeConstraints { make in
             make.top.bottom.equalToSuperview()

+ 7 - 151
AIRingtone/Business/VIewTool/TSCommonloadingView.swift

@@ -34,12 +34,12 @@ class TSCommonloadingView: TSBaseView {
     
     
     lazy var timeLabel: UILabel = {
-        let timeLabel = UILabel.createLabel(text: "~ 1min",font: .font(size: 20,weight: .bold),textColor: .fromHex("#FFFFFF"),textAlignment: .center)
+        let timeLabel = UILabel.createLabel(text: "~ 1min",font: .font(size: 24,weight: .bold),textColor: .fromHex("#FFFFFF"),textAlignment: .center)
         return timeLabel
     }()
     
     lazy var textLabel: UILabel = {
-        let textLabel = UILabel.createLabel(font: .font(size: 12),textColor: .fromHex("#FFFFFF",alpha: 0.6),textAlignment: .center)
+        let textLabel = UILabel.createLabel(font: .font(size: 16),textColor: .fromHex("#FFFFFF",alpha: 0.6),textAlignment: .center)
         return textLabel
     }()
     
@@ -62,14 +62,16 @@ class TSCommonloadingView: TSBaseView {
         imageView.snp.makeConstraints { make in
             make.width.height.equalTo(200.0)
             make.centerX.equalToSuperview()
-            make.centerY.equalToSuperview().offset(-60)
+//            make.centerY.equalToSuperview().offset(-60)
+            make.top.equalToSuperview().offset(240)
         }
         
         contentView.addSubview(animatedImageView)
         animatedImageView.snp.makeConstraints { make in
             make.width.height.equalTo(200.0)
             make.centerX.equalToSuperview()
-            make.centerY.equalToSuperview().offset(-60)
+//            make.centerY.equalToSuperview().offset(-60)
+            make.top.equalToSuperview().offset(240)
         }
   
         contentView.addSubview(timeLabel)
@@ -89,8 +91,7 @@ class TSCommonloadingView: TSBaseView {
         contentView.addSubview(backstageBtn)
         backstageBtn.snp.makeConstraints { make in
             make.height.equalTo(48.0)
-//            make.top.equalTo(textLabel.snp.bottom).offset(36)
-            make.bottom.equalTo(-40)
+            make.top.equalTo(textLabel.snp.bottom).offset(32)
             make.width.equalTo(312.0)
             make.centerX.equalToSuperview()
         }
@@ -164,148 +165,3 @@ class TSCommonloadingView: TSBaseView {
         isRotating = isRotating
     }
 }
-
-
-//class TSCommonloadingView: TSBaseView {
-//    
-//    lazy var imageView: UIImageView = {
-//        let imageView = UIImageView.createImageView(imageName: "failed_big")
-//        imageView.isHidden = true
-//        return imageView
-//    }()
-//    
-//    lazy var animatedImageView: AnimatedImageView = {
-//        let animatedImageView = AnimatedImageView()
-//        animatedImageView.autoPlayAnimatedImage = false
-//        if let gifURL = Bundle.main.url(forResource: "rotatingAnimation", withExtension: "gif") {
-//            animatedImageView.kf.setImage(with: gifURL, options: [.cacheOriginalImage]) { result in
-//                switch result {
-//                case .success(let value):
-//                    print("GIF 加载成功: \(value.source.url?.absoluteString ?? "")")
-//                case .failure(let error):
-//                    print("GIF 加载失败: \(error.localizedDescription)")
-//                }
-//            }
-//        }
-//        
-//        return animatedImageView
-//    }()
-//    
-//    lazy var textLabel: UILabel = {
-//        let textLabel = UILabel.createLabel(font: .font(size: 12),textColor: .fromHex("#FFFFFF",alpha: 0.6),textAlignment: .center)
-//        return textLabel
-//    }()
-//    
-//    
-//    lazy var cancelBtn: UIButton = {
-//        let textColor = UIColor.white.withAlphaComponent(0.4)
-//        let cancelBtn = UIButton.createButton(title:"Cancel".localized,backgroundColor: "#171717".uiColor,font: UIFont.font(size: 16,weight: .regular),titleColor:textColor,corner: 24)
-//        cancelBtn.layer.borderWidth = 1
-//        cancelBtn.layer.borderColor = UIColor.white.withAlphaComponent(0.15).cgColor
-//        return cancelBtn
-//    }()
-//    private var targetView: UIView = UIView()
-//    
-//    override func creatUI() {
-//        
-//        let blurEffect = createBlurEffectView(style: .dark)
-//        contentView.addSubview(blurEffect)
-//        
-//        contentView.addSubview(imageView)
-//        imageView.snp.makeConstraints { make in
-//            make.width.height.equalTo(200.0)
-//            make.centerX.equalToSuperview()
-//            make.centerY.equalToSuperview().offset(-60)
-//        }
-//        
-//        contentView.addSubview(animatedImageView)
-//        animatedImageView.snp.makeConstraints { make in
-//            make.width.height.equalTo(200.0)
-//            make.centerX.equalToSuperview()
-//            make.centerY.equalToSuperview().offset(-60)
-//        }
-//  
-//        contentView.addSubview(textLabel)
-//        textLabel.snp.makeConstraints { make in
-//            make.height.equalTo(18.0)
-//            make.top.equalTo(imageView.snp.bottom).offset(16)
-//            make.leading.trailing.equalToSuperview()
-//        }
-//        
-//        contentView.addSubview(cancelBtn)
-//        cancelBtn.snp.makeConstraints { make in
-//            make.height.equalTo(48.0)
-//            make.top.equalTo(textLabel.snp.bottom).offset(36)
-//            make.width.equalTo(200.0)
-//            make.centerX.equalToSuperview()
-//        }
-//    }
-//    
-//    
-//    override func dealThings() {
-//        // 监听应用生命周期事件
-//        NotificationCenter.default.addObserver(
-//            self,
-//            selector: #selector(handleAppDidEnterBackground),
-//            name: UIApplication.didEnterBackgroundNotification,
-//            object: nil
-//        )
-//        
-//        NotificationCenter.default.addObserver(
-//            self,
-//            selector: #selector(handleAppWillEnterForeground),
-//            name: UIApplication.willEnterForegroundNotification,
-//            object: nil
-//        )
-//    }
-//    
-//    
-//    lazy var isRotating = false{
-//        didSet{
-//            if isRotating == true{
-//                startRotating(view: imageView)
-//            }else{
-//                stopRotating(view: imageView)
-//            }
-//        }
-//    }
-//    
-//    
-//    /// 开始旋转
-//    func startRotating(view:UIView,duration: Double = 2.0) {
-//        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
-//            self.animatedImageView.startAnimating()
-//        }
-//    }
-//
-//    /// 停止旋转
-//    func stopRotating(view:UIView) {
-//        animatedImageView.stopAnimating()
-//    }
-//    
-//    func showLoading(text:String){
-//        animatedImageView.isHidden = false
-//        imageView.isHidden = true
-//        
-//        textLabel.text = text
-//        isRotating = true
-//    }
-//    
-//    func showError(text:String){
-//        animatedImageView.isHidden = true
-//        
-//        imageView.isHidden = false
-//        imageView.image = UIImage(named: "failed_big")
-//        
-//        textLabel.text = text
-//        isRotating = false
-//    }
-//    
-//    @objc private func handleAppDidEnterBackground() {
-//        stopRotating(view: targetView)
-//    }
-//
-//    @objc private func handleAppWillEnterForeground() {
-//        isRotating = isRotating
-//    }
-//}

+ 20 - 6
AIRingtone/Business/VIewTool/TSRingToneCellView.swift

@@ -7,11 +7,11 @@
 
 class TSRingToneCellView: TSBaseView {
     
-    
     var clickPlayHandel:((Bool)->Void)?
+    var isSelectedChangeColor:Bool = true //选中是否改变颜色
     
     let coverImageView:UIImageView = UIImageView()
-    
+    let selectedColor:UIColor = "#3C213F".uiColor
     lazy var progressView: TSCircularProgressView = {
         let progressView = TSCircularProgressView(frame: CGRect(x: 0, y: 0, width: 49, height: 49))
         progressView.trackColor = .clear
@@ -36,7 +36,10 @@ class TSRingToneCellView: TSBaseView {
         didSet{
             playBtn.stopRotating()
             playBtn.setImage(UIImage(named: isPlay ? "ringtone_pause" : "ringtone_play"), for: .normal)
-            backgroundColor = isPlay ? "#3C213F".uiColor : .cardColor
+            if isSelectedChangeColor {
+                backgroundColor = isPlay ? selectedColor : .cardColor
+            }
+            
         }
     }
     
@@ -79,7 +82,7 @@ class TSRingToneCellView: TSBaseView {
         
         playBtn.snp.makeConstraints { make in
             make.center.equalToSuperview()
-            make.width.height.equalTo(24)
+            make.width.height.equalTo(28)
         }
 
         nameLab.snp.makeConstraints { make in
@@ -121,11 +124,14 @@ extension TSRingToneCellView {
     func monitorPlayStateDefaultHandle(){
         TSBusinessAudioPlayer.shared.stateChangedHandle = { [weak self] state  in
             guard let self = self else { return }
-            self.handelAudioPlayerStateChange(state: state)
+            DispatchQueue.main.async {
+                self.handelAudioPlayerStateChange(state: state)
+            }
         }
     }
     
     func handelAudioPlayerStateChange(state:TSBusinessAudioPlayer.PlayerState){
+        dePrint("TSRingToneCellView handelAudioPlayerStateChange=\(state)")
         switch state {
         case .loading(let progress):
             if progress == 0.0 {
@@ -143,7 +149,7 @@ extension TSRingToneCellView {
         case .currentTime(_):
             self.isPlay = true
             self.progressView.isHidden = false
-            self.progressView.progress =  CGFloat(TSBusinessAudioPlayer.shared.playProgress)
+            self.progressView.progress = CGFloat(TSBusinessAudioPlayer.shared.playProgress)
         default:
             break
         }
@@ -187,6 +193,8 @@ class TSRingToneGenerateView:TSBaseView {
     override func creatUI() {
         backgroundColor = .cardColor
         
+        contentView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickContentView)))
+        
         contentView.addSubview(generateProgressView)
         generateProgressView.snp.makeConstraints { make in
             make.leading.top.bottom.equalTo(0)
@@ -216,6 +224,12 @@ class TSRingToneGenerateView:TSBaseView {
         
     }
     
+    @objc func clickContentView() {
+        if refreshBtn.isHidden == false{
+            refreshHandel?()
+        }
+    }
+    
     func setProgress(progress:Float) {
         generateProgressView.snp.remakeConstraints{ make in
             make.leading.top.bottom.equalTo(0)

+ 1 - 1
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGenerateBaseOperation.swift

@@ -118,7 +118,7 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
      
      
     func getGeneratingProgressText()->String{
-        return "Generating \(generatingProgress)%"
+        return "Working on your ringtone \(generatingProgress)%..."
     }
      
      func cancelAllRequest(){

+ 5 - 1
AIRingtone/Common/Tool/TSAudioPlayer/TSBusinessAudioPlayer.swift

@@ -56,7 +56,7 @@ class TSBusinessAudioPlayer {
     
     var playProgress:Double{
         let playProgress = currentTime / duration
-        dePrint("TSAudioPlayer playProgress = \(playProgress)")
+//        dePrint("TSAudioPlayer playProgress = \(playProgress)")
         return playProgress
     }
     
@@ -113,6 +113,9 @@ class TSBusinessAudioPlayer {
                 
                 self.audioPlayer?.currentTimeChanged = { [weak self] currentTime in
                     guard let self = self else { return }
+                    
+                    
+                    
                     changePlayerState(.currentTime(currentTime))
                 }
                 
@@ -159,6 +162,7 @@ class TSBusinessAudioPlayer {
     }
     
     func stop() {
+        self.audioPlayer?.currentTimeChanged = nil
         isStopPlayingAfterLoading = true
         currentURLString = ""
         self.audioPlayer?.stop()