Browse Source

去掉多余的 TSCustomTextView

100Years 1 month ago
parent
commit
31c221f627

+ 0 - 4
AIEmoji.xcodeproj/project.pbxproj

@@ -167,7 +167,6 @@
 		A8F7754E2D39E59100AA6E93 /* TSGenmojiModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F7754D2D39E58B00AA6E93 /* TSGenmojiModel.swift */; };
 		A8F775502D39ECED00AA6E93 /* PhotoManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F7754F2D39ECED00AA6E93 /* PhotoManager.swift */; };
 		A8F776212D3A3F0200AA6E93 /* TSEmojisChildVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F776202D3A3F0100AA6E93 /* TSEmojisChildVC.swift */; };
-		A8F776272D3A6EC200AA6E93 /* TSGenmojiTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F776262D3A6EBA00AA6E93 /* TSGenmojiTextView.swift */; };
 		A8F7762B2D3A70B200AA6E93 /* PaddedLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F7762A2D3A70AF00AA6E93 /* PaddedLabel.swift */; };
 		A8F7762D2D3A74A100AA6E93 /* TSGenmojiGennerateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F7762C2D3A748800AA6E93 /* TSGenmojiGennerateCell.swift */; };
 		A8F7762F2D3A765400AA6E93 /* TSGenmojiViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F7762E2D3A764E00AA6E93 /* TSGenmojiViewModel.swift */; };
@@ -358,7 +357,6 @@
 		A8F7754D2D39E58B00AA6E93 /* TSGenmojiModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSGenmojiModel.swift; sourceTree = "<group>"; };
 		A8F7754F2D39ECED00AA6E93 /* PhotoManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoManager.swift; sourceTree = "<group>"; };
 		A8F776202D3A3F0100AA6E93 /* TSEmojisChildVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSEmojisChildVC.swift; sourceTree = "<group>"; };
-		A8F776262D3A6EBA00AA6E93 /* TSGenmojiTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSGenmojiTextView.swift; sourceTree = "<group>"; };
 		A8F7762A2D3A70AF00AA6E93 /* PaddedLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaddedLabel.swift; sourceTree = "<group>"; };
 		A8F7762C2D3A748800AA6E93 /* TSGenmojiGennerateCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSGenmojiGennerateCell.swift; sourceTree = "<group>"; };
 		A8F7762E2D3A764E00AA6E93 /* TSGenmojiViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSGenmojiViewModel.swift; sourceTree = "<group>"; };
@@ -1433,7 +1431,6 @@
 				A8F776342D3A7C1C00AA6E93 /* TSGenmojiColSectionView.swift */,
 				A8F7762C2D3A748800AA6E93 /* TSGenmojiGennerateCell.swift */,
 				A8F776362D3A805700AA6E93 /* TSGenmojiItemCell.swift */,
-				A8F776262D3A6EBA00AA6E93 /* TSGenmojiTextView.swift */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -1785,7 +1782,6 @@
 				A89EA6AC2D5B3EFB000EB181 /* TSRealmManager.swift in Sources */,
 				A80EDDE42D6EB8FA003CD332 /* TSPTPSelectStyleCell.swift in Sources */,
 				A8F775172D38EB7400AA6E93 /* TSTabBarController.swift in Sources */,
-				A8F776272D3A6EC200AA6E93 /* TSGenmojiTextView.swift in Sources */,
 				A80E73E12D533E5800C64288 /* TSPurchaseVC.swift in Sources */,
 				A80EDDE02D6EB1B9003CD332 /* TSPTPGeneratorCell.swift in Sources */,
 				A80EDDDB2D6EB0D0003CD332 /* Untitled.swift in Sources */,

+ 2 - 2
AIEmoji/Business/AIChat/TSChatViewController/TSChatInputBarVC/TSChatInputBarVC.swift

@@ -77,8 +77,8 @@ class TSChatInputBarVC: TSBaseVC, UITextViewDelegate {
     
     private let minHeight: CGFloat = 56//24
     private let maxHeight: CGFloat = 154
-    lazy var textView: TSCustomTextView = {
-        let textView = TSCustomTextView()
+    lazy var textView: TSPlaceholderTextView = {
+        let textView = TSPlaceholderTextView()
         textView.backgroundColor = .clear
         textView.textColor = .white
         textView.delegate = self

+ 2 - 2
AIEmoji/Business/AIChat/TSChatViewController/TSChatInputBarVC/TSChatInputFullScreenVC.swift

@@ -45,8 +45,8 @@ class TSChatInputFullScreenVC: TSBaseVC, UITextViewDelegate {
     
     private let minHeight: CGFloat = 24
     private let maxHeight: CGFloat = 154
-    lazy var textView: TSCustomTextView = {
-        let textView = TSCustomTextView()
+    lazy var textView: TSPlaceholderTextView = {
+        let textView = TSPlaceholderTextView()
         textView.backgroundColor = .clear
         textView.textColor = .white
         textView.delegate = self

+ 2 - 2
AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/View/TSGenmojiGennerateCell.swift

@@ -24,8 +24,8 @@ class TSGenmojiGennerateCell : TSBaseCollectionCell{
         return textBgView
     }()
     
-    lazy var customTextView: TSCustomTextView = {
-        let customTextView = TSCustomTextView(
+    lazy var customTextView: TSPlaceholderTextView = {
+        let customTextView = TSPlaceholderTextView(
             placeholder: "Type your idea here.",
             text: "",
             font: .font(size: 14),

+ 0 - 130
AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/View/TSGenmojiTextView.swift

@@ -1,130 +0,0 @@
-//
-//  TSGenmojiTextView.swift
-//  AIEmoji
-//
-//  Created by 100Years on 2025/1/17.
-//
-
-class TSCustomTextView: UITextView {
-    
-    // Placeholder Label
-    lazy var placeholderLabel: TopLeftLabel = {
-        let placeholderLabel = TopLeftLabel()
-        placeholderLabel.font = font
-        placeholderLabel.textColor = placeholderColor
-        placeholderLabel.text = placeholder
-        placeholderLabel.numberOfLines = 0
-        placeholderLabel.isUserInteractionEnabled = false
-        placeholderLabel.textAlignment = .left
-        return placeholderLabel
-    }()
-    
-    // Placeholder Text
-    var placeholder: String? {
-        didSet {
-            placeholderLabel.text = placeholder
-        }
-    }
-    
-    // Placeholder Color
-    var placeholderColor: UIColor = .lightGray {
-        didSet {
-            placeholderLabel.textColor = placeholderColor
-        }
-    }
-    
-    // Placeholder Insets
-    var textInsets: UIEdgeInsets = .zero {
-        didSet {
-            updateTextContainerInset()
-        }
-    }
-    
-    // Override text property to manage placeholder visibility
-    override var text: String! {
-        didSet {
-            updatePlaceholderVisibility()
-        }
-    }
-    
-    // Initializer
-    init(placeholder: String? = nil,
-         text: String? = nil,
-         font: UIFont? = nil,
-         textColor: UIColor = .black,
-         backgroundColor: UIColor = .white,
-         textInsets: UIEdgeInsets = .zero) {
-        super.init(frame: .zero, textContainer: nil)
-        
-        self.placeholder = placeholder
-        self.font = font
-        self.textColor = textColor
-        self.backgroundColor = backgroundColor
-        self.textInsets = textInsets
-        
-        setupPlaceholder()
-        self.text = text
-    }
-    
-    required init?(coder: NSCoder) {
-        super.init(coder: coder)
-        setupPlaceholder()
-    }
-    
-    // Setup placeholder label
-    private func setupPlaceholder() {
- 
-        addSubview(placeholderLabel)
-        updatePlaceholderVisibility()
-        
-        // Observe text changes to update placeholder
-        NotificationCenter.default.addObserver(self,
-                                               selector: #selector(textDidChange),
-                                               name: UITextView.textDidChangeNotification,
-                                               object: self)
-        
-        // Update text container insets
-        updateTextContainerInset()
-    }
-    
-    deinit {
-        NotificationCenter.default.removeObserver(self)
-    }
-    
-    // Update placeholder visibility
-    private func updatePlaceholderVisibility() {
-        placeholderLabel.isHidden = !text.isEmpty
-    }
-    
-    @objc private func textDidChange() {
-        updatePlaceholderVisibility()
-    }
-    
-    // Update textContainerInset and placeholder frame
-    private func updateTextContainerInset() {
-        textContainerInset = textInsets
-        setNeedsLayout()
-    }
-    
-    // Layout placeholder
-    override func layoutSubviews() {
-        super.layoutSubviews()
-
-        
-        
-        let placeholderX = textInsets.left + 5 // Add padding for placeholder
-        let placeholderY = textInsets.top
-        let placeholderWidth = bounds.width - textInsets.left - textInsets.right - 10 // Adjust for padding
-        let placeholderHeight = bounds.height - textInsets.top - textInsets.bottom
-        
-        
-//        if let font = font {
-//            placeholderHeight = placeholder?.height(ofFont: font, maxWidth: k_ScreenWidth-64)
-//        }
-        
-        placeholderLabel.frame = CGRect(x: placeholderX,
-                                        y: placeholderY,
-                                        width: placeholderWidth,
-                                        height: placeholderHeight)
-    }
-}