100Years 1 month ago
parent
commit
3caa1bea49

+ 2 - 2
AIEmoji.xcodeproj/project.pbxproj

@@ -1676,7 +1676,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 2;
+				CURRENT_PROJECT_VERSION = 3;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				GENERATE_INFOPLIST_FILE = YES;
@@ -1715,7 +1715,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 2;
+				CURRENT_PROJECT_VERSION = 3;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				GENERATE_INFOPLIST_FILE = YES;

+ 14 - 6
AIEmoji/Business/AIChat/TSChatViewController/Models/TSLayoutSizeCalculator.swift

@@ -87,12 +87,20 @@ class TSLayoutSizeCalculator: MessageSizeCalculator {//CellSizeCalculator {
                 height+=uiBaseModel.height
             }
 
-            //消息底部工具栏,是ai 机器人,且是ai 回答问题,且回答已经结束
-            if msgModel.messageType == .aiRobotResponse,
-               msgModel.sendState.isResult
-//                ,msgModel.user.idType == .aiRobot
-            {
-                height = height + Self.cellMessageToolViewH
+            
+            
+            let isLast = TSMessageContentCell.kIsChatLast(message: message, dataSource: messagesDataSource)
+            //ai接口失败,只显示刷新;ai失败,且不是最后一个,工具不显示
+            if isLast == false,msgModel.sendState.reslutSuccess == false{
+                
+            }else{
+                //消息底部工具栏,是ai 机器人,且是ai 回答问题,且回答已经结束
+                if msgModel.messageType == .aiRobotResponse,
+                   msgModel.sendState.isResult
+    //                ,msgModel.user.idType == .aiRobot
+                {
+                    height = height + Self.cellMessageToolViewH
+                }
             }
         }
         

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

@@ -44,7 +44,7 @@ extension TSChatViewController{
         let contentHeight = scrollView.contentSize.height
         let frameHeight = scrollView.frame.size.height
         // 判断是否需要显示滚动到底部的按钮
-        let h = contentHeight - frameHeight + inputContainerView.frame.size.height - 60
+        let h = contentHeight - frameHeight + inputContainerView.frame.size.height - 80//60
         debugPrint("scrollViewDidScroll offsetY=\(offsetY),contentHeight=\(contentHeight),frameHeight=\(frameHeight),h=\(h)")
         
         if offsetY > h {

+ 1 - 1
AIEmoji/Business/AIChat/TSChatViewController/Views/TSCellView/TSChatMsgToolView.swift

@@ -42,7 +42,7 @@ class TSChatMsgToolView: TSChatMsgBaseView {
     
 
     lazy var stackView: TSCustomStackView = {
-        let stackView = TSCustomStackView(axis: .horizontal,spacing: 10)
+        let stackView = TSCustomStackView(axis: .horizontal,spacing: 16)
         return stackView
     }()
 

+ 15 - 28
AIEmoji/Business/AIChat/TSChatViewController/Views/TSMessageContentCell.swift

@@ -294,7 +294,7 @@ class TSMessageContentCell: MessageCollectionViewCell {
             if msgModel.sendState.isResult {
                 var isHiddenReload = true
 
-                let isLast = kIsChatLast(message: message, dataSource: dataSource)
+                let isLast = Self.kIsChatLast(message: message, dataSource: dataSource)
                 
                 //重试只在显示在最后一个 cell,历史记录中,不能显示重试
                 if isLast == true , chatVC.viewModel.uiStyle != .history {
@@ -346,33 +346,20 @@ extension TSMessageContentCell {
         return false
     }
     
-    
-//    func isLast(message: MessageType,dataSource: MessagesDataSource)->Bool{
-//        if let chatVC = dataSource as? TSChatViewController,
-//           let msg = message as? TSChatMessage
-//        {
-//            let array = chatVC.messageList
-//            // 判断对象是否在数组中是最后一个元素
-//            if let index = array.firstIndex(where: { $0 === msg }), index == array.count - 1 {
-//                return true
-//            }
-//        }
-//        
-//        return false
-//    }
-}
-
-
-func kIsChatLast(message: MessageType,dataSource: MessagesDataSource)->Bool{
-    if let chatVC = dataSource as? TSChatViewController,
-       let msg = message as? TSChatMessage
-    {
-        let array = chatVC.messageList
-        // 判断对象是否在数组中是最后一个元素
-        if let index = array.firstIndex(where: { $0 === msg }), index == array.count - 1 {
-            return true
+    static func kIsChatLast(message: MessageType,dataSource: MessagesDataSource)->Bool{
+        if let chatVC = dataSource as? TSChatViewController,
+           let msg = message as? TSChatMessage
+        {
+            let array = chatVC.messageList
+            // 判断对象是否在数组中是最后一个元素
+            if let index = array.firstIndex(where: { $0 === msg }), index == array.count - 1 {
+                return true
+            }
         }
+        
+        return false
     }
-    
-    return false
+
 }
+
+

+ 61 - 10
AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/View/TSGenmojiGennerateCell.swift

@@ -17,22 +17,26 @@ class TSGenmojiGennerateCell : TSBaseCollectionCell{
         return textPicker
     }()
     
+    lazy var textBgView: UIView = {
+        let textBgView = UIView()
+        textBgView.backgroundColor = "#333333".uiColor
+        textBgView.cornerRadius = 12
+        return textBgView
+    }()
+    
     lazy var customTextView: TSCustomTextView = {
         let customTextView = TSCustomTextView(
             placeholder: "Type your idea here.",
             text: "",
             font: .font(size: 14),
             textColor: .white,
-            backgroundColor: "#333333".uiColor,
-            textInsets: UIEdgeInsets(top: 21, left: 16, bottom: 21, right: 16)
+            backgroundColor: "#333333".uiColor
         )
         customTextView.delegate = self
-        customTextView.layer.cornerRadius = 12
         customTextView.returnKeyType = .send
         return customTextView
     }()
     
-    
     lazy var submitBtn: UIButton = {
         let submitBtn = kCreateNormalSubmitBtn(title: "Generate".localized) { [weak self]  in
             guard let self = self else { return }
@@ -72,29 +76,69 @@ class TSGenmojiGennerateCell : TSBaseCollectionCell{
             make.width.height.equalTo(82)
         }
         
-        contentView.addSubview(customTextView)
-        customTextView.snp.makeConstraints { make in
+        contentView.addSubview(textBgView)
+        textBgView.snp.makeConstraints { make in
             make.top.equalTo(57)
             make.leading.equalTo(0)
             make.trailing.equalTo(0)
             make.height.equalTo(182.0*kDesignScale)
         }
+   
+        textBgView.addSubview(customTextView)
+        customTextView.snp.makeConstraints { make in
+            make.top.equalTo(21)
+            make.leading.equalTo(16)
+            make.trailing.equalTo(-16)
+            make.bottom.equalTo(-21)
+        }
         
-        contentView.addSubview(inspirationBtn)
+        textBgView.addSubview(inspirationBtn)
         inspirationBtn.snp.makeConstraints { make in
             make.height.equalTo(28)
-            make.bottom.equalTo(customTextView.snp.bottom).offset(-8)
-            make.trailing.equalTo(customTextView.snp.trailing).offset(-8)
+            make.bottom.equalTo(-16)
+            make.trailing.equalTo(-16)
         }
         
         contentView.addSubview(submitBtn)
         submitBtn.snp.makeConstraints { make in
-            make.top.equalTo(customTextView.snp.bottom).offset(16)
+            make.top.equalTo(textBgView.snp.bottom).offset(16)
             make.leading.equalTo(0)
             make.trailing.equalTo(0)
             make.height.equalTo(48)
         }
     }
+//    override func creatUI() {
+//        
+//        contentView.addSubview(robotImageView)
+//        robotImageView.snp.makeConstraints { make in
+//            make.top.equalTo(0)
+//            make.leading.equalTo(0)
+//            make.width.height.equalTo(82)
+//        }
+//        
+//        contentView.addSubview(customTextView)
+//        customTextView.snp.makeConstraints { make in
+//            make.top.equalTo(57)
+//            make.leading.equalTo(0)
+//            make.trailing.equalTo(0)
+//            make.height.equalTo(182.0*kDesignScale)
+//        }
+//        
+//        contentView.addSubview(inspirationBtn)
+//        inspirationBtn.snp.makeConstraints { make in
+//            make.height.equalTo(28)
+//            make.bottom.equalTo(customTextView.snp.bottom).offset(-8)
+//            make.trailing.equalTo(customTextView.snp.trailing).offset(-8)
+//        }
+//        
+//        contentView.addSubview(submitBtn)
+//        submitBtn.snp.makeConstraints { make in
+//            make.top.equalTo(customTextView.snp.bottom).offset(16)
+//            make.leading.equalTo(0)
+//            make.trailing.equalTo(0)
+//            make.height.equalTo(48)
+//        }
+//    }
     
     
     func getVipText()->String{
@@ -112,9 +156,16 @@ class TSGenmojiGennerateCell : TSBaseCollectionCell{
             if itemModel.style == .generate{
                 title = "Generate (\(kPurchaseDefault.freeNum(type: .generatePic)))"
                 inspirationBtn.isHidden = true
+                customTextView.snp.updateConstraints { make in
+                    make.bottom.equalTo(-21)
+                }
             }else if itemModel.style == .textPicGenerate{
                 title = "Generate (\(kPurchaseDefault.freeNum(type: .textGeneratePic)))"
                 inspirationBtn.isHidden = false
+                customTextView.snp.updateConstraints { make in
+                    make.bottom.equalTo(-50)
+                }
+                
             }
         }
         

+ 1 - 0
AIEmoji/Common/View/UIStackView/TSCustomStackView.swift

@@ -83,6 +83,7 @@ class TSCustomStackView: UIView {
         
     func removeViewToStack(_ view: UIView){
         stackView.removeArrangedSubview(view)
+        view.removeFromSuperview()
     }