mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Remove unused isMultiline binding
This commit is contained in:
committed by
Stefan Ceriu
parent
7b42c75ff9
commit
17b79c1e80
@@ -33,7 +33,6 @@ struct MessageComposer: View {
|
|||||||
let editCancellationAction: () -> Void
|
let editCancellationAction: () -> Void
|
||||||
let onAppearAction: () -> Void
|
let onAppearAction: () -> Void
|
||||||
|
|
||||||
@State private var isMultiline = false
|
|
||||||
@State private var composerTranslation: CGFloat = 0
|
@State private var composerTranslation: CGFloat = 0
|
||||||
private let composerShape = RoundedRectangle(cornerRadius: 21, style: .circular)
|
private let composerShape = RoundedRectangle(cornerRadius: 21, style: .circular)
|
||||||
|
|
||||||
@@ -86,7 +85,6 @@ struct MessageComposer: View {
|
|||||||
} else {
|
} else {
|
||||||
MessageComposerTextField(placeholder: L10n.richTextEditorComposerPlaceholder,
|
MessageComposerTextField(placeholder: L10n.richTextEditorComposerPlaceholder,
|
||||||
text: $plainComposerText,
|
text: $plainComposerText,
|
||||||
isMultiline: $isMultiline,
|
|
||||||
maxHeight: 300,
|
maxHeight: 300,
|
||||||
enterKeyHandler: sendAction,
|
enterKeyHandler: sendAction,
|
||||||
pasteHandler: pasteAction)
|
pasteHandler: pasteAction)
|
||||||
|
|||||||
-25
@@ -18,7 +18,6 @@ import SwiftUI
|
|||||||
struct MessageComposerTextField: View {
|
struct MessageComposerTextField: View {
|
||||||
let placeholder: String
|
let placeholder: String
|
||||||
@Binding var text: NSAttributedString
|
@Binding var text: NSAttributedString
|
||||||
@Binding var isMultiline: Bool
|
|
||||||
|
|
||||||
let maxHeight: CGFloat
|
let maxHeight: CGFloat
|
||||||
let enterKeyHandler: EnterKeyHandler
|
let enterKeyHandler: EnterKeyHandler
|
||||||
@@ -26,7 +25,6 @@ struct MessageComposerTextField: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
UITextViewWrapper(text: $text,
|
UITextViewWrapper(text: $text,
|
||||||
isMultiline: $isMultiline,
|
|
||||||
maxHeight: maxHeight,
|
maxHeight: maxHeight,
|
||||||
enterKeyHandler: enterKeyHandler,
|
enterKeyHandler: enterKeyHandler,
|
||||||
pasteHandler: pasteHandler)
|
pasteHandler: pasteHandler)
|
||||||
@@ -48,7 +46,6 @@ private struct UITextViewWrapper: UIViewRepresentable {
|
|||||||
@Environment(\.roomContext) private var roomContext
|
@Environment(\.roomContext) private var roomContext
|
||||||
|
|
||||||
@Binding var text: NSAttributedString
|
@Binding var text: NSAttributedString
|
||||||
@Binding var isMultiline: Bool
|
|
||||||
|
|
||||||
let maxHeight: CGFloat
|
let maxHeight: CGFloat
|
||||||
|
|
||||||
@@ -62,7 +59,6 @@ private struct UITextViewWrapper: UIViewRepresentable {
|
|||||||
let textView = ElementTextView(usingTextLayoutManager: false)
|
let textView = ElementTextView(usingTextLayoutManager: false)
|
||||||
textView.roomContext = roomContext
|
textView.roomContext = roomContext
|
||||||
|
|
||||||
textView.isMultiline = $isMultiline
|
|
||||||
textView.delegate = context.coordinator
|
textView.delegate = context.coordinator
|
||||||
textView.elementDelegate = context.coordinator
|
textView.elementDelegate = context.coordinator
|
||||||
textView.textColor = .compound.textPrimary
|
textView.textColor = .compound.textPrimary
|
||||||
@@ -167,7 +163,6 @@ private protocol ElementTextViewDelegate: AnyObject {
|
|||||||
|
|
||||||
private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
|
private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
|
||||||
var roomContext: RoomScreenViewModel.Context?
|
var roomContext: RoomScreenViewModel.Context?
|
||||||
var isMultiline: Binding<Bool>?
|
|
||||||
|
|
||||||
weak var elementDelegate: ElementTextViewDelegate?
|
weak var elementDelegate: ElementTextViewDelegate?
|
||||||
|
|
||||||
@@ -186,23 +181,6 @@ private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
|
|||||||
elementDelegate?.textViewDidReceiveEnterKeyPress(self)
|
elementDelegate?.textViewDidReceiveEnterKeyPress(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func layoutSubviews() {
|
|
||||||
super.layoutSubviews()
|
|
||||||
|
|
||||||
guard let isMultiline, let font else { return }
|
|
||||||
|
|
||||||
let numberOfLines = frame.height / font.lineHeight
|
|
||||||
if numberOfLines > 1.5 {
|
|
||||||
if !isMultiline.wrappedValue {
|
|
||||||
isMultiline.wrappedValue = true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if isMultiline.wrappedValue {
|
|
||||||
isMultiline.wrappedValue = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pasting support
|
// Pasting support
|
||||||
|
|
||||||
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
||||||
@@ -266,18 +244,15 @@ struct MessageComposerTextField_Previews: PreviewProvider, TestablePreview {
|
|||||||
|
|
||||||
struct PreviewWrapper: View {
|
struct PreviewWrapper: View {
|
||||||
@State var text: NSAttributedString
|
@State var text: NSAttributedString
|
||||||
@State var isMultiline: Bool
|
|
||||||
|
|
||||||
init(text: String) {
|
init(text: String) {
|
||||||
_text = .init(initialValue: .init(string: text, attributes: [.font: UIFont.preferredFont(forTextStyle: .body),
|
_text = .init(initialValue: .init(string: text, attributes: [.font: UIFont.preferredFont(forTextStyle: .body),
|
||||||
.foregroundColor: UIColor(.compound.textPrimary)]))
|
.foregroundColor: UIColor(.compound.textPrimary)]))
|
||||||
_isMultiline = .init(initialValue: false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
MessageComposerTextField(placeholder: "Placeholder",
|
MessageComposerTextField(placeholder: "Placeholder",
|
||||||
text: $text,
|
text: $text,
|
||||||
isMultiline: $isMultiline,
|
|
||||||
maxHeight: 300,
|
maxHeight: 300,
|
||||||
enterKeyHandler: { },
|
enterKeyHandler: { },
|
||||||
pasteHandler: { _ in })
|
pasteHandler: { _ in })
|
||||||
|
|||||||
Reference in New Issue
Block a user