mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Message preview and effect improvements
This commit is contained in:
@@ -1384,6 +1384,7 @@ public final class EmojiPagerContentComponent: Component {
|
||||
|
||||
private var component: EmojiPagerContentComponent?
|
||||
private weak var state: EmptyComponentState?
|
||||
private var isUpdating: Bool = false
|
||||
private var pagerEnvironment: PagerComponentChildEnvironment?
|
||||
private var keyboardChildEnvironment: EntityKeyboardChildEnvironment?
|
||||
private var activeItemUpdated: ActionSlot<(AnyHashable, AnyHashable?, Transition)>?
|
||||
@@ -4055,6 +4056,11 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
func update(component: EmojiPagerContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
self.isUpdating = true
|
||||
defer {
|
||||
self.isUpdating = false
|
||||
}
|
||||
|
||||
let previousComponent = self.component
|
||||
|
||||
self.component = component
|
||||
@@ -4581,6 +4587,10 @@ public final class EmojiPagerContentComponent: Component {
|
||||
Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
}
|
||||
|
||||
if !strongSelf.isUpdating {
|
||||
strongSelf.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
}
|
||||
}, updateQuery: { [weak self] query in
|
||||
guard let strongSelf = self else {
|
||||
|
||||
@@ -213,6 +213,20 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
if let textField = self.textField, let text = textField.text, text.isEmpty {
|
||||
if self.bounds.contains(point), let placeholderContentView = self.placeholderContent.view as? EmojiSearchSearchBarComponent.View {
|
||||
let leftTextPosition = placeholderContentView.leftTextPosition()
|
||||
if point.x >= 0.0 && point.x <= placeholderContentView.frame.minX + leftTextPosition {
|
||||
if let result = placeholderContentView.hitTest(self.convert(point, to: placeholderContentView), with: event) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.hitTest(point, with: event)
|
||||
}
|
||||
|
||||
private func activateTextInput() {
|
||||
guard let params = self.params else {
|
||||
return
|
||||
@@ -226,7 +240,11 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
textField.autocorrectionType = .no
|
||||
textField.returnKeyType = .search
|
||||
self.textField = textField
|
||||
self.insertSubview(textField, belowSubview: self.clearIconView)
|
||||
if let placeholderContentView = self.placeholderContent.view {
|
||||
self.insertSubview(textField, belowSubview: placeholderContentView)
|
||||
} else {
|
||||
self.insertSubview(textField, belowSubview: self.clearIconView)
|
||||
}
|
||||
textField.delegate = self
|
||||
textField.addTarget(self, action: #selector(self.textFieldChanged(_:)), for: .editingChanged)
|
||||
}
|
||||
@@ -244,15 +262,15 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
}
|
||||
|
||||
@objc private func cancelPressed() {
|
||||
let textField = self.textField
|
||||
self.textField = nil
|
||||
|
||||
self.currentPresetSearchTerm = nil
|
||||
self.updateQuery(nil)
|
||||
|
||||
self.clearIconView.isHidden = true
|
||||
self.clearIconTintView.isHidden = true
|
||||
self.clearIconButton.isHidden = true
|
||||
|
||||
let textField = self.textField
|
||||
self.textField = nil
|
||||
|
||||
self.deactivated(textField?.isFirstResponder ?? false)
|
||||
|
||||
@@ -601,7 +619,6 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
}
|
||||
let _ = hasText
|
||||
|
||||
/*self.tintTextView.view?.isHidden = hasText
|
||||
self.textView.view?.isHidden = hasText*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,6 +429,15 @@ final class EmojiSearchSearchBarComponent: Component {
|
||||
return super.hitTest(point, with: event)
|
||||
}
|
||||
|
||||
func leftTextPosition() -> CGFloat {
|
||||
guard let itemLayout = self.itemLayout else {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
let visibleBounds = self.scrollView.bounds
|
||||
return (itemLayout.itemStartX - itemLayout.textSpacing) + visibleBounds.minX
|
||||
}
|
||||
|
||||
private func updateScrolling(transition: Transition, fromScrolling: Bool) {
|
||||
guard let component = self.component, let itemLayout = self.itemLayout else {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user