Various fixes

This commit is contained in:
Ilya Laktyushin 2023-06-28 16:45:55 +02:00
parent fce5f01e66
commit 106ff49522
9 changed files with 67 additions and 36 deletions

View File

@ -331,6 +331,10 @@ final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGe
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:
entityView.onInteractionUpdated(false)
@ -339,10 +343,6 @@ final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGe
break
}
updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation)
entity.rotation = updatedRotation
entityView.update()
entityView.onPositionUpdated(entity.position)
}

View File

@ -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)
}

View File

@ -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)
}
}

View File

@ -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

View File

@ -384,6 +384,10 @@ final class DrawingSimpleShapeEntititySelectionView: DrawingEntitySelectionView,
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()
@ -392,10 +396,6 @@ final class DrawingSimpleShapeEntititySelectionView: DrawingEntitySelectionView,
break
}
updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation)
entity.rotation = updatedRotation
entityView.update()
entityView.onPositionUpdated(entity.position)
}

View File

@ -584,6 +584,10 @@ final class DrawingStickerEntititySelectionView: DrawingEntitySelectionView, UIG
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()
@ -592,10 +596,6 @@ final class DrawingStickerEntititySelectionView: DrawingEntitySelectionView, UIG
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 {

View File

@ -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)
}

View File

@ -892,8 +892,12 @@ 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 {
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 {
transition.setAlpha(view: scrubberView, alpha: component.isDisplayingTool || component.isDismissing || component.isInteractingWithEntities ? 0.0 : 1.0)

View File

@ -2679,6 +2679,20 @@ public final class StoryItemSetContainerComponent: Component {
guard let navigationController = controller.navigationController as? NavigationController else {
return
}
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 {
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
}
@ -2690,6 +2704,7 @@ public final class StoryItemSetContainerComponent: Component {
viewControllers.append(chatController)
}
navigationController.setViewControllers(viewControllers, animated: true)
}
controller.dismissWithoutTransitionOut()
}