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

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

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

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

View File

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

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,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 {

View File

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