100Years il y a 5 jours
Parent
commit
a4d9a7b53b

+ 4 - 4
AIEmoji.xcodeproj/project.pbxproj

@@ -2250,7 +2250,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 5;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				GENERATE_INFOPLIST_FILE = YES;
@@ -2266,7 +2266,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				MARKETING_VERSION = 3.3;
+				MARKETING_VERSION = 3.3.1;
 				PRODUCT_BUNDLE_IDENTIFIER = com.girl.music.wallpaper;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
@@ -2289,7 +2289,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 5;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				GENERATE_INFOPLIST_FILE = YES;
@@ -2305,7 +2305,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				MARKETING_VERSION = 3.3;
+				MARKETING_VERSION = 3.3.1;
 				PRODUCT_BUNDLE_IDENTIFIER = com.girl.music.wallpaper;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";

+ 22 - 0
AIEmoji/Assets.xcassets/PTP/style/ptp_style_noStyle.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "ptp_style_noStyle@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "ptp_style_noStyle@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
AIEmoji/Assets.xcassets/PTP/style/ptp_style_noStyle.imageset/ptp_style_noStyle@2x.png


BIN
AIEmoji/Assets.xcassets/PTP/style/ptp_style_noStyle.imageset/ptp_style_noStyle@3x.png


+ 3 - 2
AIEmoji/Business/TSAILIstVC/TSAIChangeEmoteVC/TSAIChangeEmoteVC.swift

@@ -72,8 +72,9 @@ class TSAIChangeEmoteVC: TSBaseVC {
         return btn
     }()
     
-    lazy var switchOriginalPictureBtn: UIButton = {
-        let switchOriginalPictureBtn = UIButton.createButton(image:UIImage(named: "switch_original_picture"))
+    lazy var switchOriginalPictureBtn: TSUIExpandedTouchButton = {
+        let switchOriginalPictureBtn = TSUIExpandedTouchButton()
+        switchOriginalPictureBtn.setUpButton(image:UIImage(named: "switch_original_picture"))
         switchOriginalPictureBtn.addTarget(self, action: #selector(switchOriginalPictureTouchDown), for: .touchDown)
         switchOriginalPictureBtn.addTarget(self, action: #selector(switchOriginalPictureTouchUp), for: [.touchUpInside, .touchUpOutside, .touchCancel])
         switchOriginalPictureBtn.isHidden = true

+ 3 - 2
AIEmoji/Business/TSAILIstVC/TSAIPhotoGeneratorBaseVC/TSAIListPhotoGeneratorBaseVC.swift

@@ -46,8 +46,9 @@ class TSAIListPhotoGeneratorBaseVC: TSAIPhotoGeneratorBaseVC {
         return generateInView
     }()
     
-    lazy var switchOriginalPictureBtn: UIButton = {
-        let switchOriginalPictureBtn = UIButton.createButton(image:UIImage(named: "switch_original_picture"))
+    lazy var switchOriginalPictureBtn: TSUIExpandedTouchButton = {
+        let switchOriginalPictureBtn = TSUIExpandedTouchButton()
+        switchOriginalPictureBtn.setUpButton(image:UIImage(named: "switch_original_picture"))
         switchOriginalPictureBtn.addTarget(self, action: #selector(switchOriginalPictureTouchDown), for: .touchDown)
         switchOriginalPictureBtn.addTarget(self, action: #selector(switchOriginalPictureTouchUp), for: [.touchUpInside, .touchUpOutside, .touchCancel])
         switchOriginalPictureBtn.isHidden = true

+ 3 - 2
AIEmoji/Business/TSPTPGeneratorVC/TSPTPGeneratorVC/TSPTPGeneratorVC.swift

@@ -42,8 +42,9 @@ class TSPTPGeneratorVC: TSAIPhotoGeneratorBaseVC {
         return generateInView
     }()
     
-    lazy var rotatingPictureBtn: UIButton = {
-        let rotatingPictureBtn = UIButton.createButton(image:UIImage(named: "rotating_picture")){ [weak self]  in
+    lazy var rotatingPictureBtn: TSUIExpandedTouchButton = {
+        let rotatingPictureBtn = TSUIExpandedTouchButton()
+        rotatingPictureBtn.setUpButton(image:UIImage(named: "rotating_picture")){ [weak self]  in
             guard let self = self else { return }
             //旋转图片并储存
             if let image = netWorkImageView.image?.rotated(by: .degrees90) {

+ 107 - 103
AIEmoji/Business/TSPTPGeneratorVC/TSPTPInputVC/TSPTPInputVC.swift

@@ -23,7 +23,7 @@ class TSPTPInputVC: TSBaseVC {
         return photoPickerManager
     }()
     
-    
+    private var keyboardHeight: CGFloat = 0
     var hintBaseVC = TSAIListHintBaseVC(config: .defaultConfig)
     
     //###################################### 导航栏 view ######################################
@@ -118,7 +118,6 @@ class TSPTPInputVC: TSBaseVC {
     
     
     //###################################### 输入框 ######################################
-    private let maxLength = 200 // 最大长度限制
     lazy var customTextView: TSPlaceholderTextView = {
         let customTextView = TSPlaceholderTextView(
             placeholder: "Please describe your photo".localized,
@@ -127,14 +126,14 @@ class TSPTPInputVC: TSBaseVC {
             textColor: .white,
             backgroundColor: .clear
         )
-        customTextView.verticalAlignment = .center
         customTextView.delegate = self
         customTextView.returnKeyType = .send
         return customTextView
     }()
     
-    lazy var clearBtn: UIButton = {
-        let clearBtn = UIButton.createButton(
+    lazy var clearBtn: TSUIExpandedTouchButton = {
+        let clearBtn = TSUIExpandedTouchButton()
+        clearBtn.setUpButton(
             image: UIImage(named: "clear_text")
         )
         { [weak self]  in
@@ -145,7 +144,7 @@ class TSPTPInputVC: TSBaseVC {
         return clearBtn
     }()
     
-    var promptTextViewH:CGFloat = 84.0
+    var promptTextViewH:CGFloat = 96.0
     lazy var promptTextView:UIView =  {
         let promptTextView = UIView()
         promptTextView.clipsToBounds = true
@@ -161,10 +160,11 @@ class TSPTPInputVC: TSBaseVC {
         bgView.addSubview(clearBtn)
         
         customTextView.snp.makeConstraints { make in
-            make.top.bottom.equalTo(0)
             make.centerY.equalToSuperview()
             make.leading.equalTo(12.0)
-            make.trailing.equalTo(-32)
+            make.top.equalTo(12.0)
+            make.bottom.equalTo(-12.0)
+            make.trailing.equalTo(-20)
         }
         
         clearBtn.snp.makeConstraints { make in
@@ -216,7 +216,7 @@ class TSPTPInputVC: TSBaseVC {
                 kPresentModalVC(target: self, modelVC: browseVC,transitionStyle: .crossDissolve)
             }
         }
-
+        cp.collectionView.keyboardDismissMode = .interactive
         return cp
     }()
     
@@ -272,46 +272,36 @@ class TSPTPInputVC: TSBaseVC {
         updateVipView()
         TSAIListHintBaseVC.userDefaultsKey = "isFirstUploadImagePTP"
 //        collectionViewObserverHandle()
-////        // 监听键盘事件
-//        NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
-//        NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
+//        // 监听键盘事件
+        NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
     }
+
+
+//    private var collectionViewObserver: CollectionViewObserver!
 //    
-//    override func viewWillAppear(_ animated: Bool) {
-//        super.viewWillAppear(animated)
-//        IQKeyboardManager.shared.isEnabled = false
-//    }
-//    override func viewWillDisappear(_ animated: Bool) {
-//        super.viewWillDisappear(animated)
+//    func collectionViewObserverHandle(){
+//        collectionViewObserver = CollectionViewObserver(collectionView: collectionComponent.collectionView)
+//        
+//        collectionViewObserver.onContentSizeChange = { size in
+//            print("collectionViewObserver 内容大小变化: \(size)")
+//        }
+//        
+//        collectionViewObserver.onContentInsetChange = { inset in
+//            print("collectionViewObserver 内边距变化: \(inset)")
+//        }
+//        
+//        collectionViewObserver.onContentOffsetChange = { offset in
+//            print("collectionViewObserver 偏移量变化: \(offset)")
+//        }
 //        
-//        IQKeyboardManager.shared.isEnabled = true
 //    }
-    
-    
-    private var collectionViewObserver: CollectionViewObserver!
-    
-    func collectionViewObserverHandle(){
-        collectionViewObserver = CollectionViewObserver(collectionView: collectionComponent.collectionView)
-        
-        collectionViewObserver.onContentSizeChange = { size in
-            print("collectionViewObserver 内容大小变化: \(size)")
-        }
-        
-        collectionViewObserver.onContentInsetChange = { inset in
-            print("collectionViewObserver 内边距变化: \(inset)")
-        }
-        
-        collectionViewObserver.onContentOffsetChange = { offset in
-            print("collectionViewObserver 偏移量变化: \(offset)")
-        }
-        
-    }
-    
-    
-    func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        print("contentOffset 变化: \(scrollView.contentOffset)")
-        // 实时监听偏移量变化
-    }
+//    
+//    
+//    func scrollViewDidScroll(_ scrollView: UIScrollView) {
+//        print("contentOffset 变化: \(scrollView.contentOffset)")
+//        // 实时监听偏移量变化
+//    }
 }
 
 extension TSPTPInputVC {
@@ -322,20 +312,29 @@ extension TSPTPInputVC {
                 dePrint("collectionViewObserver cusStackView.viewH == \(cusStackView.viewH)")
                 return cusStackView.viewH
             }
-            return 454 //+bannerH+bannerY+promptTextViewH
+            return 454 //promptTextViewH
         }
     }
     
-    func upDateCusStackViewH(){
+    func upDateCusStackViewH(scrollTop:Bool = true){
         let cusH = cusStackViewH
         self.collectionComponent.collectionView.contentInset = UIEdgeInsets(top: cusH, left: 0, bottom: collectionViewBtootm, right: 0)
-        cusStackView.snp.remakeConstraints { make in
+
+        cusStackView.snp.updateConstraints { make in
             make.top.equalTo(-cusH)
-            make.leading.trailing.equalTo(0)
             make.height.equalTo(cusH)
         }
-        self.collectionComponent.collectionView.contentOffset = CGPoint(x: 0, y: -cusH)
         
+        dePrint("self.collectionComponent.collectionView.contentOffset.y=\(self.collectionComponent.collectionView.contentOffset.y)")
+        
+//        if self.collectionComponent.collectionView.contentOffset.y <= -cusH{
+            self.collectionComponent.collectionView.contentOffset = CGPoint(x: 0, y: -cusH)
+//
+//        if scrollTop {
+//            self.collectionComponent.collectionView.contentOffset = CGPoint(x: 0, y: -cusH)
+//        }else {
+//            self.collectionComponent.collectionView.contentOffset = self.collectionComponent.collectionView.contentOffset
+//        }
     }
     
     func presentModalHintVC(){
@@ -349,15 +348,12 @@ extension TSPTPInputVC {
     }
     
     func setUpCusStackView(){
-        
         collectionComponent.collectionView.addSubview(cusStackView)
-        
-//        cusStackView.addSubviewToStack(entranceView)
-//        entranceView.snp.makeConstraints { make in
-//            make.height.equalTo(bannerH+bannerY)
-//            make.width.equalTo(k_ScreenWidth)
-//        }
-
+        cusStackView.snp.makeConstraints { make in
+            make.top.equalTo(-cusStackViewH)
+            make.leading.trailing.equalTo(0)
+            make.height.equalTo(cusStackViewH)
+        }
         let uploadPhotoTitleView = TSTitleView.creatTitleView(title: "Upload Photo".localized, subTitle: "(Size ≤ 10MB)".localized)
         cusStackView.addSubviewToStack(uploadPhotoTitleView)
         uploadPhotoTitleView.snp.makeConstraints { make in
@@ -396,7 +392,6 @@ extension TSPTPInputVC {
             make.width.equalTo(k_ScreenWidth)
         }
         
-
 //        cusStackView.addSubviewToStack(promptTextView)
 //        promptTextView.snp.makeConstraints { make in
 //            make.height.equalTo(promptTextViewH)
@@ -415,6 +410,7 @@ extension TSPTPInputVC: UITextViewDelegate{
     // 实现 UITextViewDelegate 协议方法,控制 return 键行为
     func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
         
+        clearBtn.isHidden = textView.text.count <= 0
         if text == "\n" {
             // 当输入为换行符(即按下 return 键)时,执行相应操作
             //sendBolck?(textView.text)
@@ -422,7 +418,6 @@ extension TSPTPInputVC: UITextViewDelegate{
         }
         return true
     }
-
 }
 
 
@@ -452,9 +447,28 @@ extension TSPTPInputVC {
  
 
     func updateTextFiledView () {
-//        promptTextView.snp.updateConstraints { make in
-//            make.height.equalTo(viewModel.selectedPTPStyleModel?.style == "No Style" ? promptTextViewH : 0 )
-//        }
+        if isNoneStyle {
+            if promptTextView.superview == nil {
+                cusStackView.addSubviewToStack(promptTextView)
+                promptTextView.snp.makeConstraints { make in
+                    make.height.equalTo(promptTextViewH)
+                    make.width.equalTo(k_ScreenWidth)
+                }
+            }
+        }else{
+            cusStackView.removeViewToStack(promptTextView)
+        }
+        
+        kDelayMainShort {
+            self.upDateCusStackViewH(scrollTop: false)
+        }
+    }
+    
+    var isNoneStyle:Bool{
+        if viewModel.selectedPTPStyleModel?.style == "No Style" {
+            return true
+        }
+        return false
     }
 }
 extension TSPTPInputVC {
@@ -471,15 +485,17 @@ extension TSPTPInputVC {
         }
         
         //判断 vip
-        if kJudgeVip(externalBool: isVip, vc: self) { [weak self] in
-            guard let self = self else { return }
-        }{ return }
+        if kJudgeVip(externalBool: isVip, vc: self) { return }
         
 
         guard let selectedPTPStyleModel = viewModel.selectedPTPStyleModel else { return }
         guard let upLoadImage = viewModel.upLoadImage else { return }
-
-        let gennerateVC = TSPTPGeneratorVC(prompt: viewModel.prompt,promptSort: selectedPTPStyleModel.imageText , imageUrl: "",upLoadImage: upLoadImage,style: selectedPTPStyleModel.style) { [weak self] model in
+        var prompt = viewModel.prompt
+        if isNoneStyle {
+            prompt = customTextView.text
+        }
+        
+        let gennerateVC = TSPTPGeneratorVC(prompt:prompt,promptSort: selectedPTPStyleModel.imageText , imageUrl: "",upLoadImage: upLoadImage,style: selectedPTPStyleModel.style) { [weak self] model in
             guard let self = self else { return }
             if viewModel.saveModel(model:model) {
                 collectionComponent.clear()
@@ -499,41 +515,29 @@ extension TSPTPInputVC {
     }
 
 }
-extension TSPTPInputVC {
-    
-    @objc func keyboardWillShow(_ notification: Notification) {
 
-        guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect,
-              let animationDuration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval else {
-            return
-        }
-//        dePrint("keyboardWillShow contentInset IQKeyboardManager=\(IQKeyboardManager.shared.isEnabled)")
-        
-//        let keyboardHeight = keyboardFrame.height
-//        let contentInset = UIEdgeInsets(top:cusStackViewH, left: 0, bottom: keyboardHeight, right: 0)
-//        dePrint("keyboardWillShow contentInset=\(contentInset)")
-////        UIView.animate(withDuration: animationDuration) {
-//            self.collectionComponent.collectionView.contentInset = contentInset
-//            self.collectionComponent.collectionView.scrollIndicatorInsets = contentInset
-////        }
-        
-//        kDelayMainShort {
-//            self.collectionComponent.collectionView.scrollToLastItem(animated: false)
-//        }
-    }
-
-    @objc func keyboardWillHide(_ notification: Notification) {
-        guard let animationDuration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval else {
-            return
-        }
-
-//        let contentInset = UIEdgeInsets(top: cusStackViewH, left: 0, bottom: collectionViewBtootm, right: 0)
-//        dePrint("keyboardWillHide contentInset=\(contentInset)")
-////        UIView.animate(withDuration: animationDuration) {
-//            self.collectionComponent.collectionView.contentInset = contentInset
-//            self.collectionComponent.collectionView.scrollIndicatorInsets = contentInset
-////        }
+extension TSPTPInputVC {
+    // MARK: - 键盘弹出时滚动到 TextView
+     @objc func keyboardWillShow(_ notification: Notification) {
+         guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
+         let textView = customTextView
+         guard let scrollView = collectionComponent.collectionView else { return }
+         // 1. 计算键盘高度(减去安全区域)
+         let keyboardHeight = keyboardFrame.height - view.safeAreaInsets.bottom
+         dePrint("keyboardHeight = \(keyboardHeight )")
+         // 2. 直接获取 TextView 在 ScrollView 中的位置
+         let textViewFrame = scrollView.convert(textView.frame, from: textView.superview)
+         dePrint("textViewFrame = \(textViewFrame)")
+         // 3. 计算需要滚动的距离(TextView 底部 - (屏幕高度 - 键盘高度))
+         var scrollDistance = textViewFrame.maxY - (scrollView.bounds.height - keyboardHeight)
+         dePrint("scrollDistance = \(scrollDistance)")
+         // 4. 如果需要滚动,调整 contentOffset
+         var y = scrollDistance
+         scrollView.setContentOffset(CGPoint(x: 0, y: y),animated: true)
+     }
+    
+    // MARK: - 键盘隐藏时恢复
+    @objc private func keyboardWillHide(_ notification: Notification) {
+        self.collectionComponent.collectionView.contentOffset = CGPoint(x: 0, y: -cusStackViewH)
     }
-    
-    
 }

+ 1 - 1
AIEmoji/Business/TSPTPGeneratorVC/TSPTPInputVC/VM/TSPTPInputVM.swift

@@ -34,7 +34,7 @@ class TSPTPInputVM {
         }
     }
     
-    var selectedStyleIndex:Int = 0
+    var selectedStyleIndex:Int = 1
     
     //选择类型组
     lazy var ptpStyleModels: [TSGenerateStyleModel] = {

+ 8 - 0
AIEmoji/Res/photo_to_photo_style.json

@@ -1,5 +1,13 @@
 [
     {
+        "imageName": "ptp_style_none",
+        "imageText": "None",
+        "prompt":"",
+        "specialStyle":0,
+        "specialStyle":0,
+        "style":"No Style",
+        "isVip": false
+    },{
         "imageName": "ptp_style_10",
         "imageText": "Anime",
         "prompt":"Studio Ghibli-inspired anime aesthetic, Hayao Miyazaki style, vibrant yet soft color palette, detailed hand-painted textures, whimsical dreamlike atmosphere, soft cel-shading, watercolor wash effect, subtle grain texture, preserving original composition. Style strength: 85%",