From da25e4292ca8c96c3b7f19a28b372a10e026bc52 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 18 Jul 2024 21:56:06 +0400 Subject: [PATCH] Fix story weather item width --- .../Sources/GalleryControllerNode.swift | 4 ++ .../Sources/StoryItemOverlaysView.swift | 37 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/submodules/GalleryUI/Sources/GalleryControllerNode.swift b/submodules/GalleryUI/Sources/GalleryControllerNode.swift index 5393185f88..c0f1930656 100644 --- a/submodules/GalleryUI/Sources/GalleryControllerNode.swift +++ b/submodules/GalleryUI/Sources/GalleryControllerNode.swift @@ -512,6 +512,10 @@ open class GalleryControllerNode: ASDisplayNode, ASScrollViewDelegate, ASGesture } } else { self.scrollView.setContentOffset(CGPoint(x: 0.0, y: self.scrollView.contentSize.height / 3.0), animated: true) + + if let chatController = self.baseNavigationController()?.topViewController as? ChatController { + chatController.updatePushedTransition(1.0, transition: .animated(duration: 0.45, curve: .customSpring(damping: 180.0, initialVelocity: 0.0))) + } } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemOverlaysView.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemOverlaysView.swift index 6b9d6d2220..0a2dd06b11 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemOverlaysView.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemOverlaysView.swift @@ -567,11 +567,7 @@ final class StoryItemOverlaysView: UIView { size: CGSize, cornerRadius: CGFloat, isActive: Bool - ) { - self.backgroundView.backgroundColor = flags.contains(.isDark) ? UIColor(rgb: 0x000000) : UIColor(rgb: 0xffffff) - self.backgroundView.frame = CGRect(origin: .zero, size: size) - self.backgroundView.layer.cornerRadius = cornerRadius - + ) -> CGSize { let itemSize = CGSize(width: floor(size.height * 0.71), height: floor(size.height * 0.71)) if self.file?.fileId != emojiFile?.fileId, let file = emojiFile { @@ -615,14 +611,19 @@ final class StoryItemOverlaysView: UIView { MultilineTextComponent(text: .plain(string)) ), environment: {}, - containerSize: size + containerSize: CGSize(width: .greatestFiniteMagnitude, height: size.height) ) + let leftInset = size.height * 0.058 + let rightInset = size.height * 0.2 + let spacing = size.height * 0.205 + let contentWidth: CGFloat = leftInset + itemSize.width + spacing + textSize.width + rightInset + if let view = self.text.view { if view.superview == nil { self.addSubview(view) } - let textFrame = CGRect(origin: CGPoint(x: size.width - textSize.width - size.height * 0.2, y: floorToScreenPixels((size.height - textSize.height) / 2.0)), size: textSize) + let textFrame = CGRect(origin: CGPoint(x: contentWidth - textSize.width - rightInset, y: floorToScreenPixels((size.height - textSize.height) / 2.0)), size: textSize) let textTransition = ComponentTransition.immediate textTransition.setFrame(view: view, frame: textFrame) } @@ -632,7 +633,7 @@ final class StoryItemOverlaysView: UIView { self.addSubview(directStickerView) } - let stickerFrame = itemSize.centered(around: CGPoint(x: size.height * 0.5 + size.height * 0.058, y: size.height * 0.5)) + let stickerFrame = itemSize.centered(around: CGPoint(x: size.height * 0.5 + leftInset, y: size.height * 0.5)) let stickerTransition = ComponentTransition.immediate stickerTransition.setPosition(view: directStickerView, position: stickerFrame.center) @@ -640,6 +641,14 @@ final class StoryItemOverlaysView: UIView { directStickerView.externalShouldPlay = isActive } + + let contentSize = CGSize(width: contentWidth, height: size.height) + + self.backgroundView.backgroundColor = flags.contains(.isDark) ? UIColor(rgb: 0x000000) : UIColor(rgb: 0xffffff) + self.backgroundView.frame = CGRect(origin: .zero, size: contentSize) + self.backgroundView.layer.cornerRadius = cornerRadius + + return contentSize } } @@ -758,12 +767,8 @@ final class StoryItemOverlaysView: UIView { self.itemViews[itemId] = itemView self.addSubview(itemView) } - - transition.setPosition(view: itemView, position: itemFrame.center) - transition.setBounds(view: itemView, bounds: CGRect(origin: CGPoint(), size: itemFrame.size)) - transition.setTransform(view: itemView, transform: CATransform3DMakeRotation(itemRotation, 0.0, 0.0, 1.0)) - - itemView.update( + + let itemSize = itemView.update( context: context, emoji: emoji, emojiFile: context.animatedEmojiStickersValue[emoji]?.first?.file, @@ -775,6 +780,10 @@ final class StoryItemOverlaysView: UIView { isActive: isActive ) + transition.setPosition(view: itemView, position: itemFrame.center) + transition.setBounds(view: itemView, bounds: CGRect(origin: CGPoint(), size: itemSize)) + transition.setTransform(view: itemView, transform: CATransform3DMakeRotation(itemRotation, 0.0, 0.0, 1.0)) + nextId += 1 default: break