Various fixes

This commit is contained in:
Ilya Laktyushin 2023-12-20 23:19:04 +04:00
parent 8659a5d6ea
commit cc010a4a39
6 changed files with 50 additions and 14 deletions

View File

@ -3168,10 +3168,13 @@ public final class DrawingToolsInteraction {
newEntity.mirrored = entity.mirrored newEntity.mirrored = entity.mirrored
let newEntityView = self.entitiesView.add(newEntity) let newEntityView = self.entitiesView.add(newEntity)
entityView.selectionView?.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2)
if let newEntityView = newEntityView as? DrawingStickerEntityView { if let newEntityView = newEntityView as? DrawingStickerEntityView {
newEntityView.playCutoffAnimation() newEntityView.playCutoutAnimation()
} }
self.entitiesView.selectEntity(newEntity, animate: false) self.entitiesView.selectEntity(newEntity, animate: false)
newEntityView.selectionView?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
if let entityView = entityView as? DrawingStickerEntityView { if let entityView = entityView as? DrawingStickerEntityView {
entityView.playDissolveAnimation() entityView.playDissolveAnimation()
self.entitiesView.remove(uuid: entity.uuid, animated: false) self.entitiesView.remove(uuid: entity.uuid, animated: false)

View File

@ -519,22 +519,30 @@ public class DrawingStickerEntityView: DrawingEntityView {
} }
let dustEffectLayer = DustEffectLayer() let dustEffectLayer = DustEffectLayer()
dustEffectLayer.position = containerView.bounds.center dustEffectLayer.position = self.center
dustEffectLayer.bounds = CGRect(origin: CGPoint(), size: containerView.bounds.size) dustEffectLayer.bounds = CGRect(origin: CGPoint(), size: containerView.bounds.size)
containerView.layer.insertSublayer(dustEffectLayer, below: self.layer)
dustEffectLayer.animationSpeed = 2.2 dustEffectLayer.animationSpeed = 2.2
dustEffectLayer.becameEmpty = { [weak dustEffectLayer] in dustEffectLayer.becameEmpty = { [weak dustEffectLayer] in
dustEffectLayer?.removeFromSuperlayer() dustEffectLayer?.removeFromSuperlayer()
completion() completion()
} }
containerView.layer.insertSublayer(dustEffectLayer, below: self.layer)
let itemFrame = self.layer.convert(self.bounds, to: dustEffectLayer) let maxSize = CGSize(width: 512.0, height: 512.0)
let itemSize = CGSize(width: self.bounds.width * self.entity.scale, height: self.bounds.height * self.entity.scale)
let fittedSize = itemSize.aspectFittedOrSmaller(maxSize)
let scale = itemSize.width / fittedSize.width
dustEffectLayer.transform = CATransform3DScale(CATransform3DMakeRotation(self.stickerEntity.rotation, 0.0, 0.0, 1.0), scale, scale, 1.0)
let itemFrame = CGRect(origin: CGPoint(x: (containerView.bounds.width - fittedSize.width) / 2.0, y: (containerView.bounds.height - fittedSize.height) / 2.0), size: fittedSize)
dustEffectLayer.addItem(frame: itemFrame, image: scaledImage) dustEffectLayer.addItem(frame: itemFrame, image: scaledImage)
self.isHidden = true self.isHidden = true
} }
public func playCutoffAnimation() { public func playCutoutAnimation() {
let values = [self.entity.scale, self.entity.scale * 1.1, self.entity.scale] let values = [self.entity.scale, self.entity.scale * 1.1, self.entity.scale]
let keyTimes = [0.0, 0.67, 1.0] let keyTimes = [0.0, 0.67, 1.0]
self.layer.animateKeyframes(values: values as [NSNumber], keyTimes: keyTimes as [NSNumber], duration: 0.35, keyPath: "transform.scale") self.layer.animateKeyframes(values: values as [NSNumber], keyTimes: keyTimes as [NSNumber], duration: 0.35, keyPath: "transform.scale")

View File

@ -1624,6 +1624,9 @@ public class StickerPickerScreen: ViewController {
modalProgress = 0.0 modalProgress = 0.0
} }
self.controller?.updateModalStyleOverlayTransitionFactor(modalProgress, transition: transition.containedViewLayoutTransition) self.controller?.updateModalStyleOverlayTransitionFactor(modalProgress, transition: transition.containedViewLayoutTransition)
if self.isDismissing {
return
}
let clipFrame: CGRect let clipFrame: CGRect
let contentFrame: CGRect let contentFrame: CGRect

View File

@ -62,20 +62,31 @@ public enum CodableDrawingEntity: Equatable {
private var coordinates: MediaArea.Coordinates? { private var coordinates: MediaArea.Coordinates? {
var position: CGPoint? var position: CGPoint?
var size: CGSize? var size: CGSize?
var scale: CGFloat?
var rotation: CGFloat? var rotation: CGFloat?
var scale: CGFloat?
switch self { switch self {
case let .location(entity): case let .location(entity):
position = entity.position position = entity.position
size = entity.renderImage?.size size = entity.renderImage?.size
scale = entity.scale
rotation = entity.rotation rotation = entity.rotation
scale = entity.scale
case let .sticker(entity): case let .sticker(entity):
position = entity.position var entityPosition = entity.position
size = entity.baseSize var entitySize = entity.baseSize
scale = entity.scale let entityRotation = entity.rotation
rotation = entity.rotation let entityScale = entity.scale
if case .message = entity.content {
let offset: CGFloat = 16.18 * entityScale //54.0 * entityScale / 3.337
entitySize = CGSize(width: entitySize.width - 38.0, height: entitySize.height - 4.0)
entityPosition = CGPoint(x: entityPosition.x + offset * cos(entityRotation), y: entityPosition.y + offset * sin(entityRotation))
}
position = entityPosition
size = entitySize
rotation = entityRotation
scale = entityScale
default: default:
return nil return nil
} }

View File

@ -3265,6 +3265,7 @@ final class StoryItemSetContainerSendMessage {
}) })
} }
private var selectedMediaArea: MediaArea?
func activateMediaArea(view: StoryItemSetContainerComponent.View, mediaArea: MediaArea, immediate: Bool = false) { func activateMediaArea(view: StoryItemSetContainerComponent.View, mediaArea: MediaArea, immediate: Bool = false) {
guard let component = view.component, let controller = component.controller() else { guard let component = view.component, let controller = component.controller() else {
return return
@ -3350,6 +3351,11 @@ final class StoryItemSetContainerSendMessage {
if immediate { if immediate {
action() action()
return return
} else {
if self.selectedMediaArea == mediaArea {
action()
return
}
} }
actions.append(ContextMenuAction(content: .textWithIcon(title: updatedPresentationData.initial.strings.Story_ViewMessage, icon: generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: .white)), action: { actions.append(ContextMenuAction(content: .textWithIcon(title: updatedPresentationData.initial.strings.Story_ViewMessage, icon: generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: .white)), action: {
action() action()
@ -3358,6 +3364,8 @@ final class StoryItemSetContainerSendMessage {
return return
} }
self.selectedMediaArea = mediaArea
let referenceSize = view.controlsContainerView.frame.size let referenceSize = view.controlsContainerView.frame.size
let size = CGSize(width: 16.0, height: mediaArea.coordinates.height / 100.0 * referenceSize.height * 1.1) let size = CGSize(width: 16.0, height: mediaArea.coordinates.height / 100.0 * referenceSize.height * 1.1)
var frame = CGRect(x: mediaArea.coordinates.x / 100.0 * referenceSize.width - size.width / 2.0, y: mediaArea.coordinates.y / 100.0 * referenceSize.height - size.height / 2.0, width: size.width, height: size.height) var frame = CGRect(x: mediaArea.coordinates.x / 100.0 * referenceSize.width - size.width / 2.0, y: mediaArea.coordinates.y / 100.0 * referenceSize.height - size.height / 2.0, width: size.width, height: size.height)
@ -3368,6 +3376,7 @@ final class StoryItemSetContainerSendMessage {
menuController.centerHorizontally = true menuController.centerHorizontally = true
menuController.dismissed = { [weak self, weak view] in menuController.dismissed = { [weak self, weak view] in
if let self, let view { if let self, let view {
self.selectedMediaArea = nil
Queue.mainQueue().after(0.1) { Queue.mainQueue().after(0.1) {
self.menuController = nil self.menuController = nil
view.updateIsProgressPaused() view.updateIsProgressPaused()

View File

@ -2417,7 +2417,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
var warnAboutPrivate = false var warnAboutPrivate = false
var canShareToStory = false var canShareToStory = false
if case .peer = chatPresentationInterfaceState.chatLocation, let channel = message.peers[message.id.peerId] as? TelegramChannel { if case .peer = chatPresentationInterfaceState.chatLocation, let channel = message.peers[message.id.peerId] as? TelegramChannel {
if case .broadcast = channel.info {
canShareToStory = true canShareToStory = true
}
if channel.addressName == nil { if channel.addressName == nil {
warnAboutPrivate = true warnAboutPrivate = true
} }