kln 1 week ago
parent
commit
77bf4d22cc

+ 2 - 2
AIPlayRingtones.xcodeproj/project.pbxproj

@@ -859,7 +859,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 3;
+				CURRENT_PROJECT_VERSION = 4;
 				DEVELOPMENT_TEAM = HR2R5NZ2MG;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AIPlayRingtones/Info.plist;
@@ -896,7 +896,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 3;
+				CURRENT_PROJECT_VERSION = 4;
 				DEVELOPMENT_TEAM = HR2R5NZ2MG;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AIPlayRingtones/Info.plist;

+ 1 - 1
AIPlayRingtones/APConfig/APConfig+Color.swift

@@ -10,7 +10,7 @@ extension UIColor {
     static let mainBg = "#111018".uiColor
     
     /// 主色调
-    static let themeColor = "#FECB34".uiColor
+    static let themeColor = "#B48EFF".uiColor
     
     /// 弹窗色
     static let popupColor = "#222222".uiColor

+ 5 - 0
AIPlayRingtones/AppDelegate.swift

@@ -53,6 +53,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     func initPlatform() {
         TSColorConfigShared.naviMianTextColor = .white
         TSColorConfigShared.mainBg = .mainBg
+        
+        DispatchQueue.main.async {//先提前调用,启动下数据库.
+            debugPrint("ASRMShared.ringDBHistory.istModels.count = \(ASRMShared.ringDBHistory.listModels.count)")
+        }
+
     }
 }
 

+ 38 - 35
AIPlayRingtones/AppPage/APMyRingVC/ASMyRingCell.swift

@@ -153,7 +153,7 @@ class ASMyRingCell: SwipeCollectionViewCell  {
     func dealThings(){
         
     }
-    var operation:ASGenerateBaseOperation?
+    
 }
 
 
@@ -172,45 +172,26 @@ extension ASMyRingCell {
     func modelDidSet(){
         guard let model = model else { return }
         
+        //处理model数据
+        updataActionInfoModelView(model: model)
+        dePrint("\(self.indexPath.item),model actionStatus 收到=\(model.actionStatus)")
+        
+        //处理生成任务
         if let rintoneOperation = currentOperation {
-//            rintoneOperation.currentActionInfoModelChanged = { [weak self] actionInfoModel in
-//                guard let self = self else { return }
-//                DispatchQueue.main.async {
-//                    self.updataActionInfoModelView(model: actionInfoModel)
-//                }
-//            }
-            
             rintoneOperation.stateDataPblishedChanged = { [weak self] state, actionInfoModel in
                 guard let self = self else { return }
-                switch state {
-                    case .failed(let errorStr,let code):
-                    generateView.isHidden = false
-                    generateView.setFail()
-                    case .success:
-                    if let model = actionInfoModel {
-                        updataActionInfoModelView(model: model)
-                    }
-                    case .progress(let progress, let string):
-                    generateView.isHidden = false
-                    generateView.setProgress(progress: progress)
-                    default:
-                    generateView.isHidden = false
-                    generateView.setProgress(progress: 0)
+                if rintoneOperation.uuid != self.model?.uuid {
+                    return
                 }
+                handleStateDataPblishedChanged(state: state, actionInfoModel: actionInfoModel)
             }
-            
-            self.operation = rintoneOperation
-//            dePrint("\(self.indexPath.item),刷新进度真self.operation=\(self.operation)")
-        }
-        else{
-//            dePrint("\(self.indexPath.item),刷新进度空self.operation=\(self.operation)")
-            self.operation = nil
+            dePrint("\(self.indexPath.item),刷新进度真handleStateDataPblishedChanged=\(rintoneOperation.stateDatauPblished)")
+            handleStateDataPblishedChanged(state: rintoneOperation.stateDatauPblished.0, actionInfoModel: rintoneOperation.stateDatauPblished.1)
         }
 
-        updataActionInfoModelView(model: model)
-        dePrint("\(self.indexPath.item),model actionStatus 收到=\(model.actionStatus)")
-        
+        //处理播放进度
         if playSelf{
+            dePrint("\(self.indexPath.item),playSelf")
             setPlayerStateChangedHandle()
         }else{
             changePlayerState(state: .stop)
@@ -221,14 +202,36 @@ extension ASMyRingCell {
         
         TSBusinessAudioPlayer.shared.stateChangedHandle = { [weak self] playerState in
             guard let self = self else { return }
-            self.changePlayerState(state: playerState)
+            dePrint("\(self.indexPath.item),stateChangedHandle self=\(self)")
+            
+            if playSelf {
+                self.changePlayerState(state: playerState)
+            }
+
         }
         self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
     }
-    
+
 }
 extension ASMyRingCell {
-    
+   
+    func handleStateDataPblishedChanged(state:ASProgressState,actionInfoModel:ASActionInfoModel?){
+        switch state {
+            case .failed(let errorStr,let code):
+            generateView.isHidden = false
+            generateView.setFail()
+            case .success:
+            if let model = actionInfoModel {
+                updataActionInfoModelView(model: model)
+            }
+            case .progress(let progress, let string):
+            generateView.isHidden = false
+            generateView.setProgress(progress: progress)
+            default:
+            generateView.isHidden = false
+            generateView.setProgress(progress: 0)
+        }
+    }
     
 }
 

+ 1 - 1
AIPlayRingtones/AppPage/APMyRingVC/ASMyRingVC.swift

@@ -93,7 +93,7 @@ class APMyRingVC: TSBaseVC {
     
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
-        debugPrint("viewWillAppear listModels.count = \(ASRMShared.ringDBHistory.listModels.count)")
+//        debugPrint("viewWillAppear listModels.count = \(ASRMShared.ringDBHistory.listModels.count)")
     }
     
     override func viewWillDisappear(_ animated: Bool) {

+ 2 - 2
AIPlayRingtones/AppPage/ASRingGeneratorVC/ASRingGeneratorVC+load.swift

@@ -9,8 +9,8 @@ extension ASRingGeneratorVC {
     
     func createGeneratorView() -> ASGeneratorView{
         let generateInView = ASGeneratorView()
-        generateInView.animationView.setText(time: String(format: "~ %d min".localized, 2), info: "Lots of people are creating images right now, so this might take a bit.".localized)
-
+        generateInView.animationView.setText(time: String(format: "~ %d min".localized, 2), info: "Lots of people are creating ringtones right now, so this might take a bit.".localized)
+        
         generateInView.clickClosePage = { [weak self] in
             guard let self = self else { return }
             closePage()

+ 5 - 6
AIPlayRingtones/AppPage/ASRingGeneratorVC/ASRingGeneratorVC.swift

@@ -31,6 +31,9 @@ class ASRingGeneratorVC: ASRingGeneratorBaseVC {
     lazy var ringView: ASRingToneCellView = {
         let ringToneView = ASRingToneCellView()
         ringToneView.isSelectedChangeColor = false
+        ringToneView.nameLab.snp.updateConstraints { make in
+            make.trailing.equalTo(-16)
+        }
         ringToneView.clickPlayHandel = { [weak self] play  in
             guard let self = self else { return }
             clickPlay()
@@ -68,11 +71,11 @@ class ASRingGeneratorVC: ASRingGeneratorBaseVC {
         }else{
             TSCustomAlertController.show(in: self, config: TSCustomAlertController.AlertConfig(
                 message: "As you leave, your generation will be interrupted and no result.".localized,
-                messageColor: .white,
+                messageColor: .white.withAlphaComponent(0.6),
                 messageFont: .systemFont(ofSize: 16),
                 
                 cancelTitle: "Leave".localized,
-                cancelColor: .white,
+                cancelColor: .white.withAlphaComponent(0.6),
                 
                 confirmTitle: "Wait".localized,
                 confirmColor: .themeColor,
@@ -245,10 +248,6 @@ extension ASRingGeneratorVC{
 
 extension ASRingGeneratorVC{
 
-    var resultIcon:UIImage?{
-        return UIImage(named: "ai_rintone_icon")
-    }
-    
     func updateInfoModel(model:ASActionInfoModel?){
         infoModel = model
         if let model = model {

+ 4 - 3
AIPlayRingtones/CommonView/ASRingToneCellView.swift

@@ -71,6 +71,7 @@ class ASRingToneCellView: TSBaseView {
     
     lazy var rightShade: UIImageView = {
         let rightShade = UIImageView.createImageView(imageName: "play_right_shade",contentMode: .scaleAspectFill)
+        rightShade.isHidden = true
         return rightShade
     }()
     
@@ -136,7 +137,7 @@ class ASRingToneCellView: TSBaseView {
 
         nameLab.snp.makeConstraints { make in
             make.leading.equalTo(76)
-            make.trailing.equalTo(-86)
+            make.trailing.equalTo(-50)
             make.top.equalTo(17)
         }
         
@@ -199,7 +200,7 @@ extension ASRingToneCellView {
     }
     
     func handelAudioPlayerStateChange(state:TSBusinessAudioPlayer.PlayerState){
-        dePrint("ASRingToneCellView handelAudioPlayerStateChange=\(state)")
+        dePrint("ASRingToneCellView handelAudioPlayerStateChange=\(state),self=\(self)")
         switch state {
         case .loading(let progress):
             if progress == 0.0 {
@@ -237,7 +238,7 @@ class TSRingToneGenerateView:TSBaseView {
     }()
     
     lazy var progressLabel: UILabel = {
-        let progressLabel = UILabel.createLabel(text:"Working On Your Ringtone...".localized,font: .font(size: 14),textColor: .white,numberOfLines: 1)
+        let progressLabel = UILabel.createLabel(text:"Working on your ringtone...".localized,font: .font(size: 14),textColor: .white,numberOfLines: 1)
         return progressLabel
     }()
     

+ 10 - 9
AIPlayRingtones/OperationQueue/Generate/ASGenerateTextToRingOperation.swift

@@ -170,26 +170,27 @@ class ASGenerateTextToRingOperation: ASGenerateBaseOperation , @unchecked Sendab
 //            self.stateDatauPblished = (.pending,nil) //通知首页进行更新
 //        }
 //        complete(true)
+//        let multiple = 3.0
 //        for index in 1...10 {
-//            kDelayOnMainThread(currentSec+Double(index)*3) {
+//            kDelayOnMainThread(currentSec+Double(index)*multiple) {
 //                sendProgress(Float(index)/10.0,infoModel)
 //            }
 //        }
 //
-//        currentSec+=10.0*3.0+2.0
+//        currentSec+=10.0*multiple+2.0
 //        kDelayOnMainThread(currentSec) {
-//            if kRandomBool() {
+////            if kRandomBool() {
 //                infoModel.actionStatus = .success
 //                infoModel.status = "success"
 //                self.replaceSaveInfoModel(model: infoModel)
 //                self.stateDatauPblished = (.success(nil),infoModel)
 //                self.handleGenerateSuccess()
-//            }else{
-//                infoModel.actionStatus = .failed
-//                infoModel.status = "failed"
-//                self.replaceSaveInfoModel(model: infoModel)
-//                self.stateDatauPblished = (.failed("模拟失败", 0),infoModel)
-//            }
+////            }else{
+////                infoModel.actionStatus = .failed
+////                infoModel.status = "failed"
+////                self.replaceSaveInfoModel(model: infoModel)
+////                self.stateDatauPblished = (.failed("模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败模拟失败", 0),infoModel)
+////            }
 //        }
 //    }