From 68a13a4c07926ba584b46e70c4d68cd273383e75 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 1 Jan 2023 02:08:27 +0400 Subject: [PATCH] Various fixes --- .../ContextControllerExtractedPresentationNode.swift | 10 ++++++++-- submodules/DrawingUI/Sources/DrawingPenTool.swift | 8 ++++++-- submodules/DrawingUI/Sources/DrawingScreen.swift | 2 +- .../Sources/TGMediaPickerGalleryInterfaceView.m | 4 +++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift b/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift index 40b1117aac..51f519c8f5 100644 --- a/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift +++ b/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift @@ -769,8 +769,14 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo if let reactionContextNode = self.reactionContextNode { additionalVisibleOffsetY += reactionContextNode.visibleExtensionDistance } - if case .reference = self.source { - if actionsFrame.maxY > layout.size.height { + if case let .reference(source) = self.source { + var actionsFrameIsOutOfScreen = false + if let contentAreaInScreenSpace = source.transitionInfo()?.contentAreaInScreenSpace { + if !contentAreaInScreenSpace.contains(actionsFrame) { + actionsFrameIsOutOfScreen = true + } + } + if actionsFrame.maxY > layout.size.height || actionsFrameIsOutOfScreen { actionsFrame.origin.y = contentRect.minY - actionsSize.height - contentActionsSpacing } } diff --git a/submodules/DrawingUI/Sources/DrawingPenTool.swift b/submodules/DrawingUI/Sources/DrawingPenTool.swift index cb7ab9b59b..4569107717 100644 --- a/submodules/DrawingUI/Sources/DrawingPenTool.swift +++ b/submodules/DrawingUI/Sources/DrawingPenTool.swift @@ -237,7 +237,6 @@ final class PenTool: DrawingElement { var renderArrowLineWidth: CGFloat let isEraser: Bool - let isBlur: Bool var arrowStart: CGPoint? @@ -277,7 +276,12 @@ final class PenTool: DrawingElement { } var bounds: CGRect { - return normalizeDrawingRect(boundingRect(from: 0, to: self.segments.count).insetBy(dx: -20.0, dy: -20.0), drawingSize: self.drawingSize) + let segmentsBounds = boundingRect(from: 0, to: self.segments.count).insetBy(dx: -20.0, dy: -20.0) + var combinedBounds = segmentsBounds + if self.hasArrow, let arrowLeftPath, let arrowRightPath { + combinedBounds = combinedBounds.union(arrowLeftPath.bounds).union(arrowRightPath.bounds).insetBy(dx: -20.0, dy: -20.0) + } + return normalizeDrawingRect(combinedBounds, drawingSize: self.drawingSize) } required init(drawingSize: CGSize, color: DrawingColor, lineWidth: CGFloat, hasArrow: Bool, isEraser: Bool, isBlur: Bool, blurredImage: UIImage?) { diff --git a/submodules/DrawingUI/Sources/DrawingScreen.swift b/submodules/DrawingUI/Sources/DrawingScreen.swift index 7591996476..b70a9509ea 100644 --- a/submodules/DrawingUI/Sources/DrawingScreen.swift +++ b/submodules/DrawingUI/Sources/DrawingScreen.swift @@ -359,7 +359,7 @@ private final class ReferenceContentSource: ContextReferenceContentSource { } func transitionInfo() -> ContextControllerReferenceViewInfo? { - return ContextControllerReferenceViewInfo(referenceView: self.sourceView, contentAreaInScreenSpace: self.contentArea, customPosition: customPosition) + return ContextControllerReferenceViewInfo(referenceView: self.sourceView, contentAreaInScreenSpace: self.contentArea, customPosition: self.customPosition) } } diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m index 17f0b3a49b..785952c7c6 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m @@ -363,7 +363,9 @@ _landscapeToolbarView.cancelPressed = toolbarCancelPressed; _landscapeToolbarView.donePressed = toolbarDonePressed; _landscapeToolbarView.doneLongPressed = toolbarDoneLongPressed; - [_wrapperView addSubview:_landscapeToolbarView]; + + if ([UIDevice currentDevice].userInterfaceIdiom != UIUserInterfaceIdiomPad) + [_wrapperView addSubview:_landscapeToolbarView]; } return self; }