fix warning
This commit is contained in:
parent
b47922694d
commit
fa1637a5af
@ -263,7 +263,7 @@ struct PrivateChatView: View {
|
||||
set: { isComposerFocused = $0 }
|
||||
),
|
||||
isEnabled: currentUserId != nil,
|
||||
minHeight: 10,
|
||||
minHeight: 40,
|
||||
maxLines: 4,
|
||||
calculatedHeight: $legacyComposerHeight,
|
||||
onSubmit: sendCurrentMessage
|
||||
@ -504,7 +504,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 +539,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 +569,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