mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
8659a5d6ea
commit
cc010a4a39
@ -3158,7 +3158,7 @@ public final class DrawingToolsInteraction {
|
||||
actions.append(ContextMenuAction(content: .text(title: presentationData.strings.Paint_CutOut, accessibilityLabel: presentationData.strings.Paint_CutOut), action: { [weak self, weak entityView] in
|
||||
if let self, let entityView, let entity = entityView.entity as? DrawingStickerEntity, case let .image(image, _) = entity.content {
|
||||
let _ = (cutoutStickerImage(from: image)
|
||||
|> deliverOnMainQueue).start(next: { [weak entity] result in
|
||||
|> deliverOnMainQueue).start(next: { [weak entity] result in
|
||||
if let result, let entity {
|
||||
let newEntity = DrawingStickerEntity(content: .image(result, .sticker))
|
||||
newEntity.referenceDrawingSize = entity.referenceDrawingSize
|
||||
@ -3168,10 +3168,13 @@ public final class DrawingToolsInteraction {
|
||||
newEntity.mirrored = entity.mirrored
|
||||
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 {
|
||||
newEntityView.playCutoffAnimation()
|
||||
newEntityView.playCutoutAnimation()
|
||||
}
|
||||
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 {
|
||||
entityView.playDissolveAnimation()
|
||||
self.entitiesView.remove(uuid: entity.uuid, animated: false)
|
||||
|
@ -519,22 +519,30 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
}
|
||||
|
||||
let dustEffectLayer = DustEffectLayer()
|
||||
dustEffectLayer.position = containerView.bounds.center
|
||||
dustEffectLayer.position = self.center
|
||||
dustEffectLayer.bounds = CGRect(origin: CGPoint(), size: containerView.bounds.size)
|
||||
containerView.layer.insertSublayer(dustEffectLayer, below: self.layer)
|
||||
|
||||
dustEffectLayer.animationSpeed = 2.2
|
||||
dustEffectLayer.becameEmpty = { [weak dustEffectLayer] in
|
||||
dustEffectLayer?.removeFromSuperlayer()
|
||||
completion()
|
||||
}
|
||||
containerView.layer.insertSublayer(dustEffectLayer, below: self.layer)
|
||||
|
||||
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
|
||||
|
||||
let itemFrame = self.layer.convert(self.bounds, to: dustEffectLayer)
|
||||
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)
|
||||
|
||||
self.isHidden = true
|
||||
}
|
||||
|
||||
public func playCutoffAnimation() {
|
||||
public func playCutoutAnimation() {
|
||||
let values = [self.entity.scale, self.entity.scale * 1.1, self.entity.scale]
|
||||
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")
|
||||
|
@ -1624,7 +1624,10 @@ public class StickerPickerScreen: ViewController {
|
||||
modalProgress = 0.0
|
||||
}
|
||||
self.controller?.updateModalStyleOverlayTransitionFactor(modalProgress, transition: transition.containedViewLayoutTransition)
|
||||
|
||||
if self.isDismissing {
|
||||
return
|
||||
}
|
||||
|
||||
let clipFrame: CGRect
|
||||
let contentFrame: CGRect
|
||||
if layout.metrics.widthClass == .compact {
|
||||
|
@ -62,20 +62,31 @@ public enum CodableDrawingEntity: Equatable {
|
||||
private var coordinates: MediaArea.Coordinates? {
|
||||
var position: CGPoint?
|
||||
var size: CGSize?
|
||||
var scale: CGFloat?
|
||||
var rotation: CGFloat?
|
||||
var scale: CGFloat?
|
||||
|
||||
switch self {
|
||||
case let .location(entity):
|
||||
position = entity.position
|
||||
size = entity.renderImage?.size
|
||||
scale = entity.scale
|
||||
rotation = entity.rotation
|
||||
scale = entity.scale
|
||||
case let .sticker(entity):
|
||||
position = entity.position
|
||||
size = entity.baseSize
|
||||
scale = entity.scale
|
||||
rotation = entity.rotation
|
||||
var entityPosition = entity.position
|
||||
var entitySize = entity.baseSize
|
||||
let entityRotation = 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:
|
||||
return nil
|
||||
}
|
||||
|
@ -3265,6 +3265,7 @@ final class StoryItemSetContainerSendMessage {
|
||||
})
|
||||
}
|
||||
|
||||
private var selectedMediaArea: MediaArea?
|
||||
func activateMediaArea(view: StoryItemSetContainerComponent.View, mediaArea: MediaArea, immediate: Bool = false) {
|
||||
guard let component = view.component, let controller = component.controller() else {
|
||||
return
|
||||
@ -3350,6 +3351,11 @@ final class StoryItemSetContainerSendMessage {
|
||||
if immediate {
|
||||
action()
|
||||
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: {
|
||||
action()
|
||||
@ -3358,6 +3364,8 @@ final class StoryItemSetContainerSendMessage {
|
||||
return
|
||||
}
|
||||
|
||||
self.selectedMediaArea = mediaArea
|
||||
|
||||
let referenceSize = view.controlsContainerView.frame.size
|
||||
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)
|
||||
@ -3368,6 +3376,7 @@ final class StoryItemSetContainerSendMessage {
|
||||
menuController.centerHorizontally = true
|
||||
menuController.dismissed = { [weak self, weak view] in
|
||||
if let self, let view {
|
||||
self.selectedMediaArea = nil
|
||||
Queue.mainQueue().after(0.1) {
|
||||
self.menuController = nil
|
||||
view.updateIsProgressPaused()
|
||||
|
@ -2417,7 +2417,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var warnAboutPrivate = false
|
||||
var canShareToStory = false
|
||||
if case .peer = chatPresentationInterfaceState.chatLocation, let channel = message.peers[message.id.peerId] as? TelegramChannel {
|
||||
canShareToStory = true
|
||||
if case .broadcast = channel.info {
|
||||
canShareToStory = true
|
||||
}
|
||||
if channel.addressName == nil {
|
||||
warnAboutPrivate = true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user