Various improvements

This commit is contained in:
Ilya Laktyushin 2023-07-16 01:45:40 +02:00
parent c9bddb58b5
commit d4bf77376c
4 changed files with 26 additions and 11 deletions

View File

@ -551,6 +551,19 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
return nil
}
public func getView(at point: CGPoint) -> DrawingEntityView? {
for case let view as DrawingEntityView in self.subviews {
if view is DrawingMediaEntityView {
continue
}
if view.frame.contains(point) {
return view
}
}
return nil
}
public func eachView(_ f: (DrawingEntityView) -> Void) {
for case let view as DrawingEntityView in self.subviews {
f(view)
@ -762,9 +775,10 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
}
}
}
// else if gestureRecognizer.numberOfTouches == 1, let viewToSelect = self.entity(at: location) {
// self.selectEntity(viewToSelect.entity)
// }
else if gestureRecognizer.numberOfTouches == 1, let viewToSelect = self.entity(at: location) {
self.selectEntity(viewToSelect.entity)
self.onInteractionUpdated(true)
}
else if gestureRecognizer.numberOfTouches == 2, let mediaEntityView = self.subviews.first(where: { $0 is DrawingEntityMediaView }) as? DrawingEntityMediaView {
mediaEntityView.handlePan(gestureRecognizer)
}

View File

@ -629,7 +629,7 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
self.textView.strokeColor = color
self.textView.frameColor = nil
}
self.textView.tintColor = cursorColor
self.textView.tintColor = self.textView.text.isEmpty ? .white : cursorColor
if case .regular = self.textEntity.style {
self.textView.layer.shadowColor = UIColor.black.cgColor

View File

@ -1774,6 +1774,10 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
self.textView.view?.isHidden = false*/
}
var isActive: Bool {
return self.textField?.isFirstResponder ?? false
}
func deactivate() {
if let text = self.textField?.text, !text.isEmpty {
self.textField?.endEditing(true)
@ -5209,12 +5213,8 @@ public final class EmojiPagerContentComponent: Component {
scrollView.layer.removeAllAnimations()
}
if self.isSearchActivated, let component = self.component, component.searchState == .empty(hasResults: true), !component.searchAlwaysActive, let visibleSearchHeader = self.visibleSearchHeader, visibleSearchHeader.currentPresetSearchTerm == nil {
scrollView.isScrollEnabled = false
DispatchQueue.main.async {
scrollView.isScrollEnabled = true
}
self.visibleSearchHeader?.deactivate()
if let component = self.component, self.isSearchActivated, let visibleSearchHeader = self.visibleSearchHeader, visibleSearchHeader.isActive && !component.searchAlwaysActive {
visibleSearchHeader.deactivate()
}
self.component?.inputInteractionHolder.inputInteraction?.onScroll()
self.component?.inputInteractionHolder.inputInteraction?.scrollingStickersGridPromise.set(true)

View File

@ -2192,7 +2192,8 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
return false
}
if gestureRecognizer === self.dismissPanGestureRecognizer {
if self.isDisplayingTool || self.entitiesView.hasSelection {
let location = gestureRecognizer.location(in: self.entitiesView)
if self.isDisplayingTool || self.entitiesView.hasSelection || self.entitiesView.getView(at: location) != nil {
return false
}
return true