Compare commits

..

No commits in common. "2f8c1f35145cad5f82f4ab8dfe761dff3c8174a2" and "b47922694d7915f1442a26b4061b2c7ee09e6c42" have entirely different histories.

View File

@ -7,8 +7,6 @@ struct PrivateChatView: View {
let chat: PrivateChatListItem
let currentUserId: String?
private let bottomAnchorId = "PrivateChatBottomAnchor"
let lineLimitInChat = 6
@StateObject private var viewModel: PrivateChatViewModel
@State private var hasPositionedToBottom: Bool = false
@ -249,9 +247,9 @@ struct PrivateChatView: View {
ZStack(alignment: .bottomTrailing) {
Group {
if #available(iOS 16.0, *) {
if #available(iOS 160.0, *) {
TextField(inputTab.placeholder, text: $draftText, axis: .vertical)
.lineLimit(1...lineLimitInChat)
.lineLimit(1...4)
.focused($isComposerFocused)
.submitLabel(.send)
.disabled(currentUserId == nil)
@ -266,7 +264,7 @@ struct PrivateChatView: View {
),
isEnabled: currentUserId != nil,
minHeight: 10,
maxLines: lineLimitInChat,
maxLines: 4,
calculatedHeight: $legacyComposerHeight,
onSubmit: sendCurrentMessage
)
@ -506,12 +504,7 @@ 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
@ -541,12 +534,7 @@ 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 {
@ -571,18 +559,12 @@ 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 {
let newHeight = clampedHeight
DispatchQueue.main.async {
if abs(result.wrappedValue - newHeight) > 0.5 {
result.wrappedValue = newHeight
}
}
result.wrappedValue = clampedHeight
}
textView.isScrollEnabled = shouldScroll
textView.isScrollEnabled = targetSize.height > maxHeight + 0.5
}
final class Coordinator: NSObject, UITextViewDelegate {