Various fixes

This commit is contained in:
Ilya Laktyushin
2025-09-25 21:47:46 +04:00
parent 98fb98a86e
commit 737f84bb13
13 changed files with 53 additions and 40 deletions

View File

@@ -773,6 +773,26 @@ public final class MessageInputPanelComponent: Component {
return result
}
private var sendMessageAction() {
guard let component = self.component else {
return
}
if let maxLength = component.maxLength, self.textFieldExternalState.textLength > maxLength {
self.animateError()
component.presentTextLengthLimitTooltip?()
} else {
var sendActionTransition: MessageInputPanelComponent.SendActionTransition?
if let snapshotView = self.textClippingView.snapshotView(afterScreenUpdates: false), let backgroundView = self.fieldGlassBackgroundView {
sendActionTransition = MessageInputPanelComponent.SendActionTransition(
textSnapshotView: snapshotView,
globalFrame: backgroundView.convert(backgroundView.bounds, to: nil),
cornerRadius: baseFieldHeight * 0.5
)
}
component.sendMessageAction(sendActionTransition)
}
}
func update(component: MessageInputPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
let previousPlaceholder = self.component?.placeholder
@@ -882,7 +902,10 @@ public final class MessageInputPanelComponent: Component {
},
paste: { data in
component.paste(data)
}
},
returnKeyAction: component.style == .glass ? { [weak self] in
self?.sendMessageAction()
} : nil
)),
environment: {},
containerSize: availableTextFieldSize
@@ -1564,20 +1587,7 @@ public final class MessageInputPanelComponent: Component {
component.sendMessageAction(nil)
} else if case let .text(string) = self.getSendMessageInput(), string.string.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
} else {
if let maxLength = component.maxLength, self.textFieldExternalState.textLength > maxLength {
self.animateError()
component.presentTextLengthLimitTooltip?()
} else {
var sendActionTransition: MessageInputPanelComponent.SendActionTransition?
if let snapshotView = self.textClippingView.snapshotView(afterScreenUpdates: false), let backgroundView = self.fieldGlassBackgroundView {
sendActionTransition = MessageInputPanelComponent.SendActionTransition(
textSnapshotView: snapshotView,
globalFrame: backgroundView.convert(backgroundView.bounds, to: nil),
cornerRadius: baseFieldHeight * 0.5
)
}
component.sendMessageAction(sendActionTransition)
}
self.sendMessageAction()
}
}
case .apply: