Compare commits
	
		
			2 Commits
		
	
	
		
			b47922694d
			...
			2f8c1f3514
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2f8c1f3514 | |||
| fa1637a5af | 
@ -8,6 +8,8 @@ struct PrivateChatView: View {
 | 
			
		||||
    let currentUserId: String?
 | 
			
		||||
    private let bottomAnchorId = "PrivateChatBottomAnchor"
 | 
			
		||||
    
 | 
			
		||||
    let lineLimitInChat = 6
 | 
			
		||||
 | 
			
		||||
    @StateObject private var viewModel: PrivateChatViewModel
 | 
			
		||||
    @State private var hasPositionedToBottom: Bool = false
 | 
			
		||||
    @State private var scrollToBottomTrigger: UUID = .init()
 | 
			
		||||
@ -247,9 +249,9 @@ struct PrivateChatView: View {
 | 
			
		||||
 | 
			
		||||
                ZStack(alignment: .bottomTrailing) {
 | 
			
		||||
                    Group {
 | 
			
		||||
                        if #available(iOS 160.0, *) {
 | 
			
		||||
                        if #available(iOS 16.0, *) {
 | 
			
		||||
                            TextField(inputTab.placeholder, text: $draftText, axis: .vertical)
 | 
			
		||||
                                .lineLimit(1...4)
 | 
			
		||||
                                .lineLimit(1...lineLimitInChat)
 | 
			
		||||
                                .focused($isComposerFocused)
 | 
			
		||||
                                .submitLabel(.send)
 | 
			
		||||
                                .disabled(currentUserId == nil)
 | 
			
		||||
@ -264,7 +266,7 @@ struct PrivateChatView: View {
 | 
			
		||||
                                ),
 | 
			
		||||
                                isEnabled: currentUserId != nil,
 | 
			
		||||
                                minHeight: 10,
 | 
			
		||||
                                maxLines: 4,
 | 
			
		||||
                                maxLines: lineLimitInChat,
 | 
			
		||||
                                calculatedHeight: $legacyComposerHeight,
 | 
			
		||||
                                onSubmit: sendCurrentMessage
 | 
			
		||||
                            )
 | 
			
		||||
@ -504,7 +506,12 @@ private struct LegacyMultilineTextView: UIViewRepresentable {
 | 
			
		||||
 | 
			
		||||
        context.coordinator.updatePlaceholderVisibility(for: textView)
 | 
			
		||||
        DispatchQueue.main.async {
 | 
			
		||||
            Self.recalculateHeight(for: textView, result: calculatedHeightBinding, minHeight: minHeight, maxLines: maxLines)
 | 
			
		||||
            Self.recalculateHeight(
 | 
			
		||||
                for: textView,
 | 
			
		||||
                result: calculatedHeightBinding,
 | 
			
		||||
                minHeight: minHeight,
 | 
			
		||||
                maxLines: maxLines
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return textView
 | 
			
		||||
@ -534,7 +541,12 @@ private struct LegacyMultilineTextView: UIViewRepresentable {
 | 
			
		||||
            uiView.resignFirstResponder()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Self.recalculateHeight(for: uiView, result: calculatedHeightBinding, minHeight: minHeight, maxLines: maxLines)
 | 
			
		||||
        Self.recalculateHeight(
 | 
			
		||||
            for: uiView,
 | 
			
		||||
            result: calculatedHeightBinding,
 | 
			
		||||
            minHeight: minHeight,
 | 
			
		||||
            maxLines: maxLines
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    func makeCoordinator() -> Coordinator {
 | 
			
		||||
@ -559,12 +571,18 @@ private struct LegacyMultilineTextView: UIViewRepresentable {
 | 
			
		||||
        let lineHeight = textView.font?.lineHeight ?? UIFont.preferredFont(forTextStyle: .body).lineHeight
 | 
			
		||||
        let maxHeight = minHeight + lineHeight * CGFloat(max(maxLines - 1, 0))
 | 
			
		||||
        let clampedHeight = min(max(targetSize.height, minHeight), maxHeight)
 | 
			
		||||
        let shouldScroll = targetSize.height > maxHeight + 0.5
 | 
			
		||||
 | 
			
		||||
        if abs(result.wrappedValue - clampedHeight) > 0.5 {
 | 
			
		||||
            result.wrappedValue = clampedHeight
 | 
			
		||||
            let newHeight = clampedHeight
 | 
			
		||||
            DispatchQueue.main.async {
 | 
			
		||||
                if abs(result.wrappedValue - newHeight) > 0.5 {
 | 
			
		||||
                    result.wrappedValue = newHeight
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        textView.isScrollEnabled = targetSize.height > maxHeight + 0.5
 | 
			
		||||
        textView.isScrollEnabled = shouldScroll
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    final class Coordinator: NSObject, UITextViewDelegate {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user