diff --git a/submodules/DrawingUI/Sources/DrawingBubbleEntity.swift b/submodules/DrawingUI/Sources/DrawingBubbleEntity.swift index 585b913720..8a3e30e153 100644 --- a/submodules/DrawingUI/Sources/DrawingBubbleEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingBubbleEntity.swift @@ -330,6 +330,10 @@ final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGe case .changed: rotation = gestureRecognizer.rotation updatedRotation += rotation + + updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) + entity.rotation = updatedRotation + entityView.update() gestureRecognizer.rotation = 0.0 case .ended, .cancelled: @@ -338,11 +342,7 @@ final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGe default: break } - - updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) - entity.rotation = updatedRotation - entityView.update() - + entityView.onPositionUpdated(entity.position) } diff --git a/submodules/DrawingUI/Sources/DrawingEntitiesView.swift b/submodules/DrawingUI/Sources/DrawingEntitiesView.swift index b2cdd7680a..5d56284be7 100644 --- a/submodules/DrawingUI/Sources/DrawingEntitiesView.swift +++ b/submodules/DrawingUI/Sources/DrawingEntitiesView.swift @@ -350,6 +350,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView { } } + let isMediaEntity = entity is DrawingMediaEntity view.onSnapUpdated = { [weak self, weak view] type, snapped in guard let self else { return @@ -380,6 +381,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView { self.hapticFeedback.impact(.light) } transition.updateAlpha(layer: self.angleLayer, alpha: 1.0) + self.angleLayer.isHidden = isMediaEntity } else { transition.updateAlpha(layer: self.angleLayer, alpha: 0.0) } diff --git a/submodules/DrawingUI/Sources/DrawingMediaEntity.swift b/submodules/DrawingUI/Sources/DrawingMediaEntity.swift index 9cb0d183ed..fdb4f60717 100644 --- a/submodules/DrawingUI/Sources/DrawingMediaEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingMediaEntity.swift @@ -49,6 +49,12 @@ public final class DrawingMediaEntityView: DrawingEntityView, DrawingEntityMedia init(context: AccountContext, entity: DrawingMediaEntity) { super.init(context: context, entity: entity) + + self.snapTool.onSnapUpdated = { [weak self] type, snapped in + if let self { + self.onSnapUpdated(type, snapped) + } + } } required init?(coder: NSCoder) { @@ -196,15 +202,15 @@ public final class DrawingMediaEntityView: DrawingEntityView, DrawingEntityMedia self.beganRotating = true gestureRecognizer.rotation = 0.0 } + + updatedRotation = self.snapTool.update(entityView: self, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) + self.mediaEntity.rotation = updatedRotation + self.update(animated: false) case .ended, .cancelled: self.snapTool.rotationReset() self.beganRotating = false default: break } - - updatedRotation = self.snapTool.update(entityView: self, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) - self.mediaEntity.rotation = updatedRotation - self.update(animated: false) } } diff --git a/submodules/DrawingUI/Sources/DrawingScreen.swift b/submodules/DrawingUI/Sources/DrawingScreen.swift index 8c6d230640..41a9b63d09 100644 --- a/submodules/DrawingUI/Sources/DrawingScreen.swift +++ b/submodules/DrawingUI/Sources/DrawingScreen.swift @@ -3031,6 +3031,10 @@ public final class DrawingToolsInteraction { } } + guard !isVideo else { + return + } + let presentationData = self.context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: defaultDarkPresentationTheme) var actions: [ContextMenuAction] = [] actions.append(ContextMenuAction(content: .text(title: presentationData.strings.Paint_Delete, accessibilityLabel: presentationData.strings.Paint_Delete), action: { [weak self, weak entityView] in diff --git a/submodules/DrawingUI/Sources/DrawingSimpleShapeEntity.swift b/submodules/DrawingUI/Sources/DrawingSimpleShapeEntity.swift index 74a0c722bc..f8be53dfdf 100644 --- a/submodules/DrawingUI/Sources/DrawingSimpleShapeEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingSimpleShapeEntity.swift @@ -383,6 +383,10 @@ final class DrawingSimpleShapeEntititySelectionView: DrawingEntitySelectionView, case .changed: rotation = gestureRecognizer.rotation updatedRotation += rotation + + updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) + entity.rotation = updatedRotation + entityView.update() gestureRecognizer.rotation = 0.0 case .ended, .cancelled: @@ -391,11 +395,7 @@ final class DrawingSimpleShapeEntititySelectionView: DrawingEntitySelectionView, default: break } - - updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) - entity.rotation = updatedRotation - entityView.update() - + entityView.onPositionUpdated(entity.position) } diff --git a/submodules/DrawingUI/Sources/DrawingStickerEntity.swift b/submodules/DrawingUI/Sources/DrawingStickerEntity.swift index 4d4370a1ca..065b1280a2 100644 --- a/submodules/DrawingUI/Sources/DrawingStickerEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingStickerEntity.swift @@ -583,6 +583,10 @@ final class DrawingStickerEntititySelectionView: DrawingEntitySelectionView, UIG case .changed: rotation = gestureRecognizer.rotation updatedRotation += rotation + + updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) + entity.rotation = updatedRotation + entityView.update() gestureRecognizer.rotation = 0.0 case .ended, .cancelled: @@ -591,11 +595,7 @@ final class DrawingStickerEntititySelectionView: DrawingEntitySelectionView, UIG default: break } - - updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) - entity.rotation = updatedRotation - entityView.update() - + entityView.onPositionUpdated(entity.position) } @@ -967,9 +967,9 @@ class DrawingEntitySnapTool { let currentTimestamp = CACurrentMediaTime() - let snapDelta: CGFloat = 0.02 - let snapVelocity: CGFloat = snapDelta * 8.0 - let snapSkipRotation: CGFloat = snapDelta * 5.0 + let snapDelta: CGFloat = 0.01 + let snapVelocity: CGFloat = snapDelta * 35.0 + let snapSkipRotation: CGFloat = snapDelta * 40.0 if abs(velocity) < snapVelocity || self.rotationState?.waitForLeave == true { if let (snapRotation, skipped, waitForLeave) = self.rotationState { diff --git a/submodules/DrawingUI/Sources/DrawingTextEntity.swift b/submodules/DrawingUI/Sources/DrawingTextEntity.swift index 410e1bb362..5f8bb676c9 100644 --- a/submodules/DrawingUI/Sources/DrawingTextEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingTextEntity.swift @@ -842,6 +842,10 @@ final class DrawingTextEntititySelectionView: DrawingEntitySelectionView, UIGest rotation = gestureRecognizer.rotation updatedRotation += rotation + updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) + entity.rotation = updatedRotation + entityView.update() + gestureRecognizer.rotation = 0.0 case .ended, .cancelled: self.snapTool.rotationReset() @@ -850,10 +854,6 @@ final class DrawingTextEntititySelectionView: DrawingEntitySelectionView, UIGest break } - updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation) - entity.rotation = updatedRotation - entityView.update() - entityView.onPositionUpdated(entity.position) } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index e092ceef84..7ec1fc10cc 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -892,7 +892,11 @@ final class MediaEditorScreenComponent: Component { let scrubberFrame = CGRect(origin: CGPoint(x: scrubberInset, y: availableSize.height - environment.safeInsets.bottom - scrubberSize.height - 8.0 + controlsBottomInset), size: scrubberSize) if let scrubberView = self.scrubber.view { if scrubberView.superview == nil { - self.addSubview(scrubberView) + if let inputPanelBackgroundView = self.inputPanelBackground.view, inputPanelBackgroundView.superview != nil { + self.insertSubview(scrubberView, belowSubview: inputPanelBackgroundView) + } else { + self.addSubview(scrubberView) + } } transition.setFrame(view: scrubberView, frame: scrubberFrame) if !self.animatingButtons { diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 62ab7b7a73..798d6c3f0e 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -2679,17 +2679,32 @@ public final class StoryItemSetContainerComponent: Component { guard let navigationController = controller.navigationController as? NavigationController else { return } - guard let chatController = component.context.sharedContext.makePeerInfoController(context: component.context, updatedPresentationData: nil, peer: peer._asPeer(), mode: .generic, avatarInitiallyExpanded: false, fromChat: false, requestsContext: nil) else { - return - } - - var viewControllers = navigationController.viewControllers - if let index = viewControllers.firstIndex(where: { $0 === controller }) { - viewControllers.insert(chatController, at: index) + if let messageId { + component.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: component.context, chatLocation: .peer(peer), subject: .message(id: .id(messageId), highlight: false, timecode: nil), keepStack: .always, animated: true, pushController: { [weak controller, weak navigationController] chatController, animated, completion in + guard let controller, let navigationController else { + return + } + var viewControllers = navigationController.viewControllers + if let index = viewControllers.firstIndex(where: { $0 === controller }) { + viewControllers.insert(chatController, at: index) + } else { + viewControllers.append(chatController) + } + navigationController.setViewControllers(viewControllers, animated: animated) + })) } else { - viewControllers.append(chatController) + guard let chatController = component.context.sharedContext.makePeerInfoController(context: component.context, updatedPresentationData: nil, peer: peer._asPeer(), mode: .generic, avatarInitiallyExpanded: false, fromChat: false, requestsContext: nil) else { + return + } + + var viewControllers = navigationController.viewControllers + if let index = viewControllers.firstIndex(where: { $0 === controller }) { + viewControllers.insert(chatController, at: index) + } else { + viewControllers.append(chatController) + } + navigationController.setViewControllers(viewControllers, animated: true) } - navigationController.setViewControllers(viewControllers, animated: true) controller.dismissWithoutTransitionOut() }