diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index fc7028e2bc..1d11364e8d 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -2493,6 +2493,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController destinationView: transitionView, destinationRect: transitionView.bounds, destinationCornerRadius: transitionView.bounds.height * 0.5, + destinationIsAvatar: true, completed: {} ) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift index ab48dd6f33..96eda65b42 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift @@ -257,7 +257,7 @@ public final class StoryListContext { if lhsItem.timestamp != rhsItem.timestamp { switch scope { case .all: - return lhsItem.timestamp > rhsItem.timestamp + return lhsItem.timestamp < rhsItem.timestamp case .peer: return lhsItem.timestamp < rhsItem.timestamp } @@ -309,7 +309,7 @@ public final class StoryListContext { } itemSets.sort(by: { lhs, rhs in - guard let lhsItem = lhs.items.first, let rhsItem = rhs.items.first else { + guard let lhsItem = lhs.items.last, let rhsItem = rhs.items.last else { if lhs.items.first != nil { return false } else { @@ -553,7 +553,7 @@ public final class StoryListContext { if lhsItem.timestamp != rhsItem.timestamp { switch scope { case .all: - return lhsItem.timestamp > rhsItem.timestamp + return lhsItem.timestamp < rhsItem.timestamp case .peer: return lhsItem.timestamp < rhsItem.timestamp } @@ -573,7 +573,7 @@ public final class StoryListContext { if lhsItem.timestamp != rhsItem.timestamp { switch scope { case .all: - return lhsItem.timestamp > rhsItem.timestamp + return lhsItem.timestamp < rhsItem.timestamp case .peer: return lhsItem.timestamp < rhsItem.timestamp } @@ -585,8 +585,8 @@ public final class StoryListContext { } itemSets.sort(by: { lhs, rhs in - guard let lhsItem = lhs.items.first, let rhsItem = rhs.items.first else { - if lhs.items.first != nil { + guard let lhsItem = lhs.items.last, let rhsItem = rhs.items.last else { + if lhs.items.last != nil { return false } else { return true diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift index af9963af27..913cbb4d0a 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift @@ -707,8 +707,7 @@ public final class MessageInputPanelComponent: Component { self.mediaRecordingVibrancyContainer.addSubview(mediaRecordingPanelView.vibrancyContainer) } mediaRecordingPanelTransition.setFrame(view: mediaRecordingPanelView, frame: CGRect(origin: CGPoint(), size: size)) - - transition.setFrame(view: self.mediaRecordingVibrancyContainer, frame: CGRect(origin: CGPoint(x: -fieldBackgroundFrame.minX, y: -fieldBackgroundFrame.minY), size: size)) + mediaRecordingPanelTransition.setFrame(view: self.mediaRecordingVibrancyContainer, frame: CGRect(origin: CGPoint(x: -fieldBackgroundFrame.minX, y: -fieldBackgroundFrame.minY), size: size)) if animateIn && !transition.animation.isImmediate { mediaRecordingPanelView.animateIn() @@ -787,8 +786,7 @@ public final class MessageInputPanelComponent: Component { self.mediaRecordingVibrancyContainer.addSubview(mediaPreviewPanelView.vibrancyContainer) } mediaPreviewPanelTransition.setFrame(view: mediaPreviewPanelView, frame: CGRect(origin: CGPoint(), size: size)) - - transition.setFrame(view: self.mediaRecordingVibrancyContainer, frame: CGRect(origin: CGPoint(x: -fieldBackgroundFrame.minX, y: -fieldBackgroundFrame.minY), size: size)) + mediaPreviewPanelTransition.setFrame(view: self.mediaRecordingVibrancyContainer, frame: CGRect(origin: CGPoint(x: -fieldBackgroundFrame.minX, y: -fieldBackgroundFrame.minY), size: size)) if animateIn && !transition.animation.isImmediate { mediaPreviewPanelView.animateIn() diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift index 7a42de06ef..818d89db16 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift @@ -947,6 +947,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr destinationView: self.view, destinationRect: self.itemGrid.view.convert(itemRect, to: self.view), destinationCornerRadius: 0.0, + destinationIsAvatar: false, completed: {} ) } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift index 04ccb133d8..a332c19a96 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift @@ -756,17 +756,20 @@ public class StoryContainerScreen: ViewControllerComponentContainer { public weak var destinationView: UIView? public let destinationRect: CGRect public let destinationCornerRadius: CGFloat + public let destinationIsAvatar: Bool public let completed: () -> Void public init( destinationView: UIView, destinationRect: CGRect, destinationCornerRadius: CGFloat, + destinationIsAvatar: Bool, completed: @escaping () -> Void ) { self.destinationView = destinationView self.destinationRect = destinationRect self.destinationCornerRadius = destinationCornerRadius + self.destinationIsAvatar = destinationIsAvatar self.completed = completed } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 426be1a695..09db25c576 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -568,10 +568,12 @@ public final class StoryItemSetContainerComponent: Component { let innerSourceLocalFrame = CGRect(origin: CGPoint(x: sourceLocalFrame.minX - self.contentContainerView.frame.minX, y: sourceLocalFrame.minY - self.contentContainerView.frame.minY), size: sourceLocalFrame.size) if let rightInfoView = self.rightInfoItem?.view.view { - let positionKeyframes: [CGPoint] = generateParabollicMotionKeyframes(from: CGPoint(x: innerSourceLocalFrame.center.x - rightInfoView.layer.position.x, y: innerSourceLocalFrame.center.y - rightInfoView.layer.position.y), to: CGPoint(), elevation: 0.0, duration: 0.3, curve: .spring, reverse: false) - rightInfoView.layer.animateKeyframes(values: positionKeyframes.map { NSValue(cgPoint: $0) }, duration: 0.3, keyPath: "position", additive: true) - - rightInfoView.layer.animateScale(from: innerSourceLocalFrame.width / rightInfoView.bounds.width, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) + if transitionIn.sourceCornerRadius != 0.0 { + let positionKeyframes: [CGPoint] = generateParabollicMotionKeyframes(from: CGPoint(x: innerSourceLocalFrame.center.x - rightInfoView.layer.position.x, y: innerSourceLocalFrame.center.y - rightInfoView.layer.position.y), to: CGPoint(), elevation: 0.0, duration: 0.3, curve: .spring, reverse: false) + rightInfoView.layer.animateKeyframes(values: positionKeyframes.map { NSValue(cgPoint: $0) }, duration: 0.3, keyPath: "position", additive: true) + + rightInfoView.layer.animateScale(from: innerSourceLocalFrame.width / rightInfoView.bounds.width, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) + } } self.contentContainerView.layer.animatePosition(from: sourceLocalFrame.center, to: self.contentContainerView.center, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) @@ -635,11 +637,13 @@ public final class StoryItemSetContainerComponent: Component { let innerSourceLocalFrame = CGRect(origin: CGPoint(x: sourceLocalFrame.minX - self.contentContainerView.frame.minX, y: sourceLocalFrame.minY - self.contentContainerView.frame.minY), size: sourceLocalFrame.size) if let rightInfoView = self.rightInfoItem?.view.view { - let positionKeyframes: [CGPoint] = generateParabollicMotionKeyframes(from: innerSourceLocalFrame.center, to: rightInfoView.layer.position, elevation: 0.0, duration: 0.3, curve: .spring, reverse: true) - rightInfoView.layer.position = positionKeyframes[positionKeyframes.count - 1] - rightInfoView.layer.animateKeyframes(values: positionKeyframes.map { NSValue(cgPoint: $0) }, duration: 0.3, keyPath: "position", removeOnCompletion: false, additive: false) - - rightInfoView.layer.animateScale(from: 1.0, to: innerSourceLocalFrame.width / rightInfoView.bounds.width, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false) + if transitionOut.destinationIsAvatar { + let positionKeyframes: [CGPoint] = generateParabollicMotionKeyframes(from: innerSourceLocalFrame.center, to: rightInfoView.layer.position, elevation: 0.0, duration: 0.3, curve: .spring, reverse: true) + rightInfoView.layer.position = positionKeyframes[positionKeyframes.count - 1] + rightInfoView.layer.animateKeyframes(values: positionKeyframes.map { NSValue(cgPoint: $0) }, duration: 0.3, keyPath: "position", removeOnCompletion: false, additive: false) + + rightInfoView.layer.animateScale(from: 1.0, to: innerSourceLocalFrame.width / rightInfoView.bounds.width, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false) + } } self.contentContainerView.layer.animatePosition(from: self.contentContainerView.center, to: sourceLocalFrame.center, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false) diff --git a/submodules/TelegramUI/Sources/TelegramRootController.swift b/submodules/TelegramUI/Sources/TelegramRootController.swift index a7924f6d70..b258e9f4a9 100644 --- a/submodules/TelegramUI/Sources/TelegramRootController.swift +++ b/submodules/TelegramUI/Sources/TelegramRootController.swift @@ -363,13 +363,15 @@ public final class TelegramRootController: NavigationController, TelegramRootCon var randomId: Int64 = 0 arc4random_buf(&randomId, 8) let scaledSize = image.size.aspectFittedOrSmaller(CGSize(width: 1920, height: 1920)) - if let scaledImage = scaleImageToPixelSize(image: image, size: scaledSize) { - if let scaledImageData = compressImageToJPEG(scaledImage, quality: 0.6) { - storyListContext.upload(media: .image(dimensions: dimensions, data: scaledImageData), text: caption?.string ?? "", entities: [], privacy: privacy) - Queue.mainQueue().after(0.2, { [weak chatListController] in - chatListController?.animateStoryUploadRipple() - }) - } + var scaledImage: UIImage? = image + if image.size.width > scaledSize.width || image.size.height > scaledSize.height { + scaledImage = scaleImageToPixelSize(image: image, size: scaledSize) + } + if let scaledImage, let scaledImageData = compressImageToJPEG(scaledImage, quality: 0.6) { + storyListContext.upload(media: .image(dimensions: dimensions, data: scaledImageData), text: caption?.string ?? "", entities: [], privacy: privacy) + Queue.mainQueue().after(0.2, { [weak chatListController] in + chatListController?.animateStoryUploadRipple() + }) } case let .video(content, _, values, duration, dimensions, caption): let adjustments: VideoMediaResourceAdjustments