Browse Source

1.6(1)
1.修复聊天 messagesCollectionView 底部bottom距离不对的逻辑
2.message label 的高度让其自适应,同时减少计算
3.增加聊天回到底部的出现距离
4.修复冷启动,聊天页面输入框白色一闪而过问题

100Years 1 month ago
parent
commit
d79cadd2ce

+ 4 - 4
AIEmoji.xcodeproj/project.pbxproj

@@ -1193,7 +1193,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 7;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				GENERATE_INFOPLIST_FILE = YES;
@@ -1209,7 +1209,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				MARKETING_VERSION = 1.3;
+				MARKETING_VERSION = 1.6;
 				PRODUCT_BUNDLE_IDENTIFIER = com.girl.music.wallpaper;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
@@ -1232,7 +1232,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 7;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				GENERATE_INFOPLIST_FILE = YES;
@@ -1248,7 +1248,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				MARKETING_VERSION = 1.3;
+				MARKETING_VERSION = 1.6;
 				PRODUCT_BUNDLE_IDENTIFIER = com.girl.music.wallpaper;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";

+ 7 - 4
AIEmoji/Business/AIChat/TSChatViewController/TSChatViewController/TSChatViewController+Keyboard.swift

@@ -45,7 +45,7 @@ extension TSChatViewController{
         let frameHeight = scrollView.frame.size.height
         
         // 判断是否需要显示滚动到底部的按钮
-        if offsetY > contentHeight - frameHeight + inputContainerView.frame.size.height - 40 {
+        if offsetY > contentHeight - frameHeight + inputContainerView.frame.size.height - 60 {//40
             scrollToBottomButton.isHidden = true
         } else {
             scrollToBottomButton.isHidden = false
@@ -58,8 +58,8 @@ extension TSChatViewController{
 
 
 extension TSChatViewController{
-
-    func configureMessageInputBar() {
+    
+    func setUpInputBarType(){
         inputBarBgView.addSubview(inputBarTopView)
         inputBarTopView.snp.makeConstraints { make in
             make.leading.equalTo(0)
@@ -77,7 +77,10 @@ extension TSChatViewController{
             }
         }
         inputBarType = .custom(inputBarBgView)
-        
+    }
+    
+    
+    func configureMessageInputBar() {
         handleKeyBoard()
         configureScrollToBottomButton()
     }

+ 1 - 0
AIEmoji/Business/AIChat/TSChatViewController/TSChatViewController/TSChatViewController+NaviBar.swift

@@ -91,6 +91,7 @@ extension TSChatViewController {
         setTitleText(pageTitle)
         _ = setNavigationItem(backTitle, imageName: "navi_back_white", direction: .left, action: #selector(navBarClickLeftAction))
     }
+    
     @objc public func navBarClickLeftAction() {
         debugPrint("navBarClickLeftAction -> \(type(of: self))")
         pop()

+ 18 - 18
AIEmoji/Business/AIChat/TSChatViewController/TSChatViewController/TSChatViewController+SendMsg.swift

@@ -54,29 +54,29 @@ extension TSChatViewController {
         insertMessage(message)
         NotificationCenter.default.post(name: .kAIAnsweringNotification, object: nil, userInfo: [kIsAIAnswering: true])
 
-//        //每次全部输出
-//        viewModel.sendChatMessage(message: messageString) {[weak self] string in
-//            guard let self = self else { return }
-//            debugPrint("viewModel.AiMDString=\(viewModel.AiMDString)")
-//            message.kind = .attributedText(kMDAttributedString(text: viewModel.AiMDString))
-//            message.sendState = .progress(0.5)
-//
-//            if self.scrollToBottomButton.isHidden == true {
-//                updataAIChatCellUI()
-//                self.messagesCollectionView.scrollToLastItem(animated: false)
-//            }
-//        }
-        
-        //逐字输出
-        var previousAiMDString = ""
+        //每次全部输出
         viewModel.sendChatMessage(message: messageString) {[weak self] string in
             guard let self = self else { return }
             debugPrint("viewModel.AiMDString=\(viewModel.AiMDString)")
+            message.kind = .attributedText(kMDAttributedString(text: viewModel.AiMDString))
             message.sendState = .progress(0.5)
-            delayedOutputAnimation(message: message, previousStr: previousAiMDString, newAddStr: string)
-            previousAiMDString = viewModel.AiMDString
+
+            if self.scrollToBottomButton.isHidden == true {
+                updataAIChatCellUI()
+                self.messagesCollectionView.scrollToLastItem(animated: false)
+            }
         }
         
+//        //逐字输出
+//        var previousAiMDString = ""
+//        viewModel.sendChatMessage(message: messageString) {[weak self] string in
+//            guard let self = self else { return }
+//            debugPrint("viewModel.AiMDString=\(viewModel.AiMDString)")
+//            message.sendState = .progress(0.5)
+//            delayedOutputAnimation(message: message, previousStr: previousAiMDString, newAddStr: string)
+//            previousAiMDString = viewModel.AiMDString
+//        }
+        
         completion: {[weak self] data, error in
             guard let self = self else { return }
             if let _ = data {
@@ -130,7 +130,7 @@ extension TSChatViewController {
 
 extension  TSChatViewController{
     
-    func delayedOutputAnimation(message:TSChatMessage,previousStr:String,newAddStr:String, delay: TimeInterval = 0.05)  {
+    func delayedOutputAnimation(message:TSChatMessage,previousStr:String,newAddStr:String, delay: TimeInterval = 0.07)  {
         var showUIString = previousStr
         let characters = Array(newAddStr)// 将 newText 转换为字符数组
         

+ 3 - 1
AIEmoji/Business/AIChat/TSChatViewController/TSChatViewController/TSChatViewController.swift

@@ -57,8 +57,10 @@ class TSChatViewController: MessagesViewController, MessagesDataSource {
     }()
     
     override func viewDidLoad() {
+        //在父类前先设置好inputBarType,否则会先加载默认白色,再加载自定义黑色,会一闪而过白色默认的
+        setUpInputBarType()
+        
         super.viewDidLoad()
-       
         configureNaviBarView()
         configureMessageCollectionView()
         configureMessageInputBar()