diff --git a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesDevices.swift b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesDevices.swift index 448102ebe8..3680c72a2a 100644 --- a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesDevices.swift +++ b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesDevices.swift @@ -11,7 +11,7 @@ public struct PresentationResourcesDevices { public static let macbook = renderSettingsIcon(name: "Settings/Devices/Mac", backgroundColors: [colorBlue]) public static let iOS = renderAttachAppIcon(iconImage: UIImage(bundleImageName: "Settings/Devices/iOS")) - public static let android = renderSettingsIcon(name: "Settings/Devices/Watch", backgroundColors: [colorGreen]) + public static let android = renderSettingsIcon(name: "Settings/Devices/Android", backgroundColors: [colorGreen]) public static let safari = renderAttachAppIcon(iconImage: UIImage(bundleImageName: "Settings/Devices/Safari")) public static let chrome = renderSettingsIcon(name: "Settings/Devices/Chrome", backgroundColors: [colorGreen]) diff --git a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesSettings.swift b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesSettings.swift index ddf1e274ac..944b7a2ee4 100644 --- a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesSettings.swift +++ b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesSettings.swift @@ -11,9 +11,6 @@ public func renderSettingsIcon(name: String, scaleFactor: CGFloat = 1.0, backgro context.clear(bounds) if let backgroundColors { - context.addPath(UIBezierPath(roundedRect: CGRect(origin: .zero, size: size), cornerRadius: 8.0).cgPath) - context.clip() - var locations: [CGFloat] = [0.0, 1.0] let colors: [CGColor] = backgroundColors.map(\.cgColor) @@ -22,21 +19,17 @@ public func renderSettingsIcon(name: String, scaleFactor: CGFloat = 1.0, backgro context.drawLinearGradient(gradient, start: CGPoint(x: size.width, y: size.height), end: CGPoint(x: 0.0, y: 0.0), options: CGGradientDrawingOptions()) - context.resetClip() - if let gradientImage, let cgImage = gradientImage.cgImage { - context.saveGState() context.setBlendMode(.plusLighter) context.draw(cgImage, in: CGRect(origin: .zero, size: size)) - context.restoreGState() } if let backdropImage, let cgImage = backdropImage.cgImage { - context.saveGState() context.setBlendMode(.overlay) context.draw(cgImage, in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)) - context.restoreGState() } + + context.setBlendMode(.normal) if let image = UIImage(bundleImageName: name), let maskImage = image.cgImage { let imageSize = CGSize(width: image.size.width * scaleFactor, height: image.size.height * scaleFactor) @@ -48,6 +41,19 @@ public func renderSettingsIcon(name: String, scaleFactor: CGFloat = 1.0, backgro context.fill(imageRect) context.restoreGState() } + + let outerPath = UIBezierPath(rect: CGRect(origin: .zero, size: size)) + let innerPath = UIBezierPath(roundedRect: CGRect(origin: .zero, size: size), cornerRadius: 8.0) + outerPath.append(innerPath) + + context.saveGState() + outerPath.usesEvenOddFillRule = true + context.addPath(outerPath.cgPath) + context.clip(using: .evenOdd) + + context.setBlendMode(.clear) + context.fill(CGRect(origin: .zero, size: size)) + context.restoreGState() } else { if let image = UIImage(bundleImageName: name), let cgImage = image.cgImage { let imageSize: CGSize @@ -66,16 +72,11 @@ public func renderAttachAppIcon(iconImage: UIImage?) -> UIImage? { return generateImage(CGSize(width: 30.0, height: 30.0), contextGenerator: { size, context in let bounds = CGRect(origin: CGPoint(), size: size) context.clear(bounds) - - context.addPath(UIBezierPath(roundedRect: CGRect(origin: .zero, size: size), cornerRadius: 8.0).cgPath) - context.clip() - + if let iconImage, let cgImage = iconImage.cgImage { context.draw(cgImage, in: CGRect(origin: .zero, size: size)) } - context.resetClip() - if let gradientImage, let cgImage = gradientImage.cgImage { context.saveGState() context.setBlendMode(.plusLighter) @@ -89,6 +90,19 @@ public func renderAttachAppIcon(iconImage: UIImage?) -> UIImage? { context.draw(cgImage, in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)) context.restoreGState() } + + let outerPath = UIBezierPath(rect: CGRect(origin: .zero, size: size)) + let innerPath = UIBezierPath(roundedRect: CGRect(origin: .zero, size: size), cornerRadius: 8.0) + outerPath.append(innerPath) + + context.saveGState() + outerPath.usesEvenOddFillRule = true + context.addPath(outerPath.cgPath) + context.clip(using: .evenOdd) + + context.setBlendMode(.clear) + context.fill(CGRect(origin: .zero, size: size)) + context.restoreGState() }) } @@ -156,11 +170,7 @@ public struct PresentationResourcesSettings { public static let premium = generateImage(CGSize(width: 30.0, height: 30.0), contextGenerator: { size, context in let bounds = CGRect(origin: CGPoint(), size: size) context.clear(bounds) - - let path = UIBezierPath(roundedRect: bounds, cornerRadius: 8.0) - context.addPath(path.cgPath) - context.clip() - + let colorsArray: [CGColor] = [ UIColor(rgb: 0x6b93ff).cgColor, UIColor(rgb: 0x6b93ff).cgColor, @@ -173,62 +183,82 @@ public struct PresentationResourcesSettings { context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: size.width, y: size.height), options: CGGradientDrawingOptions()) if let gradientImage, let cgImage = gradientImage.cgImage { - context.saveGState() context.setBlendMode(.plusLighter) context.draw(cgImage, in: CGRect(origin: .zero, size: size)) - context.restoreGState() } if let backdropImage, let cgImage = backdropImage.cgImage { - context.saveGState() context.setBlendMode(.overlay) context.draw(cgImage, in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)) - context.restoreGState() } + context.setBlendMode(.normal) + if let image = generateTintedImage(image: UIImage(bundleImageName: "Item List/Icons/Premium"), color: UIColor(rgb: 0xffffff)), let cgImage = image.cgImage { context.draw(cgImage, in: CGRect(origin: CGPoint(x: floorToScreenPixels((bounds.width - image.size.width) / 2.0), y: floorToScreenPixels((bounds.height - image.size.height) / 2.0)), size: image.size)) } + + let outerPath = UIBezierPath(rect: CGRect(origin: .zero, size: size)) + let innerPath = UIBezierPath(roundedRect: CGRect(origin: .zero, size: size), cornerRadius: 8.0) + outerPath.append(innerPath) + + context.saveGState() + outerPath.usesEvenOddFillRule = true + context.addPath(outerPath.cgPath) + context.clip(using: .evenOdd) + + context.setBlendMode(.clear) + context.fill(CGRect(origin: .zero, size: size)) + context.restoreGState() }) - public static let ton = generateImage(CGSize(width: 30.0, height: 30.0), contextGenerator: { size, context in - let bounds = CGRect(origin: CGPoint(), size: size) - context.clear(bounds) - - let path = UIBezierPath(roundedRect: bounds, cornerRadius: 8.0) - context.addPath(path.cgPath) - context.clip() - - context.setFillColor(UIColor(rgb: 0x32ade6).cgColor) - context.fill(bounds) - - if let gradientImage, let cgImage = gradientImage.cgImage { - context.saveGState() - context.setBlendMode(.plusLighter) - context.draw(cgImage, in: CGRect(origin: .zero, size: size)) - context.restoreGState() - } - - if let backdropImage, let cgImage = backdropImage.cgImage { - context.saveGState() - context.setBlendMode(.overlay) - context.draw(cgImage, in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)) - context.restoreGState() - } - - if let image = generateTintedImage(image: UIImage(bundleImageName: "Ads/TonAbout"), color: UIColor(rgb: 0xffffff)), let cgImage = image.cgImage { - context.draw(cgImage, in: CGRect(origin: CGPoint(x: floorToScreenPixels((bounds.width - image.size.width) / 2.0), y: floorToScreenPixels((bounds.height - image.size.height) / 2.0)), size: image.size)) - } - }) + public static let ton = renderSettingsIcon(name: "Ads/TonAbout", backgroundColors: [UIColor(rgb: 0x32ade6)]) + +// generateImage(CGSize(width: 30.0, height: 30.0), contextGenerator: { size, context in +// let bounds = CGRect(origin: CGPoint(), size: size) +// context.clear(bounds) +// +// context.setFillColor(UIColor(rgb: 0x32ade6).cgColor) +// context.fill(bounds) +// +// if let gradientImage, let cgImage = gradientImage.cgImage { +// context.saveGState() +// context.setBlendMode(.plusLighter) +// context.draw(cgImage, in: CGRect(origin: .zero, size: size)) +// context.restoreGState() +// } +// +// if let backdropImage, let cgImage = backdropImage.cgImage { +// context.saveGState() +// context.setBlendMode(.overlay) +// context.draw(cgImage, in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)) +// context.restoreGState() +// } +// +// context.setBlendMode(.normal) +// +// if let image = generateTintedImage(image: UIImage(bundleImageName: "Ads/TonAbout"), color: UIColor(rgb: 0xffffff)), let cgImage = image.cgImage { +// context.draw(cgImage, in: CGRect(origin: CGPoint(x: floorToScreenPixels((bounds.width - image.size.width) / 2.0), y: floorToScreenPixels((bounds.height - image.size.height) / 2.0)), size: image.size)) +// } +// +// let outerPath = UIBezierPath(rect: CGRect(origin: .zero, size: size)) +// let innerPath = UIBezierPath(roundedRect: CGRect(origin: .zero, size: size), cornerRadius: 8.0) +// outerPath.append(innerPath) +// +// context.saveGState() +// outerPath.usesEvenOddFillRule = true +// context.addPath(outerPath.cgPath) +// context.clip(using: .evenOdd) +// +// context.setBlendMode(.clear) +// context.fill(CGRect(origin: .zero, size: size)) +// context.restoreGState() +// }) public static let stars = generateImage(CGSize(width: 30.0, height: 30.0), contextGenerator: { size, context in let bounds = CGRect(origin: CGPoint(), size: size) context.clear(bounds) - let path = UIBezierPath(roundedRect: bounds, cornerRadius: 7.0) - context.addPath(path.cgPath) - context.clip() - let colorsArray: [CGColor] = [ UIColor(rgb: 0xfec80f).cgColor, UIColor(rgb: 0xdd6f12).cgColor @@ -239,32 +269,39 @@ public struct PresentationResourcesSettings { context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: size.width, y: size.height), options: CGGradientDrawingOptions()) if let gradientImage, let cgImage = gradientImage.cgImage { - context.saveGState() context.setBlendMode(.plusLighter) context.draw(cgImage, in: CGRect(origin: .zero, size: size)) - context.restoreGState() } if let backdropImage, let cgImage = backdropImage.cgImage { - context.saveGState() context.setBlendMode(.overlay) context.draw(cgImage, in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)) - context.restoreGState() } + context.setBlendMode(.normal) + if let image = generateTintedImage(image: UIImage(bundleImageName: "Item List/Icons/Stars"), color: UIColor(rgb: 0xffffff)), let cgImage = image.cgImage { context.draw(cgImage, in: CGRect(origin: CGPoint(x: floorToScreenPixels((bounds.width - image.size.width) / 2.0), y: floorToScreenPixels((bounds.height - image.size.height) / 2.0)), size: image.size)) } + + let outerPath = UIBezierPath(rect: CGRect(origin: .zero, size: size)) + let innerPath = UIBezierPath(roundedRect: CGRect(origin: .zero, size: size), cornerRadius: 8.0) + outerPath.append(innerPath) + + context.saveGState() + outerPath.usesEvenOddFillRule = true + context.addPath(outerPath.cgPath) + context.clip(using: .evenOdd) + + context.setBlendMode(.clear) + context.fill(CGRect(origin: .zero, size: size)) + context.restoreGState() }) public static let premiumGift = generateImage(CGSize(width: 30.0, height: 30.0), contextGenerator: { size, context in let bounds = CGRect(origin: CGPoint(), size: size) context.clear(bounds) - let path = UIBezierPath(roundedRect: bounds, cornerRadius: 8.0) - context.addPath(path.cgPath) - context.clip() - let colorsArray: [CGColor] = [ UIColor(rgb: 0x3ba1f2).cgColor, UIColor(rgb: 0x3ba1f2).cgColor, @@ -277,22 +314,33 @@ public struct PresentationResourcesSettings { context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: size.width, y: size.height), options: CGGradientDrawingOptions()) if let gradientImage, let cgImage = gradientImage.cgImage { - context.saveGState() context.setBlendMode(.plusLighter) context.draw(cgImage, in: CGRect(origin: .zero, size: size)) - context.restoreGState() } if let backdropImage, let cgImage = backdropImage.cgImage { - context.saveGState() context.setBlendMode(.overlay) context.draw(cgImage, in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)) - context.restoreGState() } + context.setBlendMode(.normal) + if let image = generateTintedImage(image: UIImage(bundleImageName: "Item List/Icons/Gift"), color: UIColor(rgb: 0xffffff)), let cgImage = image.cgImage { context.draw(cgImage, in: CGRect(origin: CGPoint(x: floorToScreenPixels((bounds.width - image.size.width) / 2.0), y: floorToScreenPixels((bounds.height - image.size.height) / 2.0)), size: image.size)) } + + let outerPath = UIBezierPath(rect: CGRect(origin: .zero, size: size)) + let innerPath = UIBezierPath(roundedRect: CGRect(origin: .zero, size: size), cornerRadius: 8.0) + outerPath.append(innerPath) + + context.saveGState() + outerPath.usesEvenOddFillRule = true + context.addPath(outerPath.cgPath) + context.clip(using: .evenOdd) + + context.setBlendMode(.clear) + context.fill(CGRect(origin: .zero, size: size)) + context.restoreGState() }) public static let bot = renderSettingsIcon(name: "Item List/Icons/Bot", backgroundColors: [colorBlue]) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift index e13612c2b5..50a72cb79d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift @@ -1346,7 +1346,7 @@ private final class ChatMessagePollOptionNode: ASDisplayNode { node.buttonNode.isAccessibilityElement = shouldHaveRadioNode let previousResultBarWidth = minBarWidth + floor((width - leftInset - rightInset - minBarWidth) * (currentResult?.normalized ?? 0.0)) - let previousFrame = CGRect(origin: CGPoint(x: leftInset, y: contentHeight - 6.0 - 1.0), size: CGSize(width: previousResultBarWidth, height: 6.0)) + let previousFrame = CGRect(origin: CGPoint(x: leftInset, y: contentLayoutHeight - 6.0 - 1.0), size: CGSize(width: previousResultBarWidth, height: 4.0)) node.resultBarNode.layer.animateSpring(from: NSValue(cgPoint: previousFrame.center), to: NSValue(cgPoint: node.resultBarNode.frame.center), keyPath: "position", duration: 0.6, damping: 110.0) node.resultBarNode.layer.animateSpring(from: NSValue(cgRect: CGRect(origin: CGPoint(), size: previousFrame.size)), to: NSValue(cgRect: CGRect(origin: CGPoint(), size: node.resultBarNode.frame.size)), keyPath: "bounds", duration: 0.6, damping: 110.0) @@ -2781,7 +2781,8 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { if let data = item.context.currentAppConfiguration.with({ $0 }).data, let value = data["poll_answers_max"] as? Double { maxPollOptions = Int(value) } - let displayAddOption = poll.openAnswers && !isClosed && poll.pollId.namespace == Namespaces.Media.CloudPoll && orderedPollOptions.count < maxPollOptions + + let displayAddOption = poll.openAnswers && !isClosed && poll.pollId.namespace == Namespaces.Media.CloudPoll && !Namespaces.Message.allScheduled.contains(item.message.id.namespace) && item.message.forwardInfo == nil && orderedPollOptions.count < maxPollOptions if displayAddOption { let addOptionResult = makeAddOptionLayout(item.context, item.presentationData, item.presentationData.strings, incoming, item.controllerInteraction.focusedTextInputIsMedia, currentNewOptionText, currentNewOptionAttachment, constrainedSize.width - layoutConstants.bubble.borderInset * 2.0) boundingSize.width = max(boundingSize.width, addOptionResult.minimumWidth + layoutConstants.bubble.borderInset * 2.0) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift index 8b389de408..06d3b681fe 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift @@ -526,7 +526,10 @@ public final class PeerInfoCoverComponent: Component { let backgroundFrame = CGRect(origin: CGPoint(x: 0.0, y: -1000.0 + availableSize.height), size: CGSize(width: availableSize.width, height: 1000.0)) transition.containedViewLayoutTransition.updateFrameAdditive(view: self.backgroundView, frame: backgroundFrame) - let patternWidth: CGFloat = min(380.0, availableSize.width - 32.0) + var patternWidth: CGFloat = 380.0 + if case .managedBot = component.subject { + patternWidth = min(380.0, availableSize.width - 32.0) + } let avatarPatternFrame = CGSize(width: patternWidth, height: floor(component.defaultHeight * 1.0)).centered(around: component.avatarCenter) transition.setFrame(layer: self.avatarBackgroundPatternContentsLayer, frame: avatarPatternFrame) diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentCaptionComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentCaptionComponent.swift index 49d6030c89..25cefe535d 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentCaptionComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentCaptionComponent.swift @@ -70,7 +70,7 @@ final class StoryContentCaptionComponent: Component { let textSelectionAction: (NSAttributedString, TextSelectionAction) -> Void let controller: () -> ViewController? let openStory: (EnginePeer, EngineStoryItem?) -> Void - let openMusic: (FileMediaReference, UIView) -> Void + let openMusic: (TelegramMediaFile, UIView) -> Void init( externalState: ExternalState, @@ -89,7 +89,7 @@ final class StoryContentCaptionComponent: Component { textSelectionAction: @escaping (NSAttributedString, TextSelectionAction) -> Void, controller: @escaping () -> ViewController?, openStory: @escaping (EnginePeer, EngineStoryItem?) -> Void, - openMusic: @escaping (FileMediaReference, UIView) -> Void + openMusic: @escaping (TelegramMediaFile, UIView) -> Void ) { self.externalState = externalState self.context = context @@ -756,7 +756,7 @@ final class StoryContentCaptionComponent: Component { return } if let sourceView = self.musicPanel?.view { - self.component?.openMusic(.standalone(media: music), sourceView) + self.component?.openMusic(music, sourceView) } }, animateScale: false diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index e1b6ffa7c0..fa1efdfe9e 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -7547,8 +7547,8 @@ public final class StoryItemSetContainerComponent: Component { }) } - private func performMusicAction(file: FileMediaReference, sourceView: UIView, gesture: ContextGesture?) { - guard let component = self.component, let controller = component.controller() else { + private func performMusicAction(file: TelegramMediaFile, sourceView: UIView, gesture: ContextGesture?) { + guard let component = self.component, let controller = component.controller(), let peer = PeerReference(component.slice.peer._asPeer()) else { return } @@ -7556,6 +7556,8 @@ public final class StoryItemSetContainerComponent: Component { let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: component.theme) + let fileReference: FileMediaReference = .story(peer: peer, id: component.slice.item.storyItem.id, media: file) + let items = component.context.engine.peers.savedMusicIds() |> take(1) |> map { [weak self] savedIds -> ContextController.Items in @@ -7580,7 +7582,7 @@ public final class StoryItemSetContainerComponent: Component { return } - let _ = component.context.engine.peers.addSavedMusic(file: file).start() + let _ = component.context.engine.peers.addSavedMusic(file: fileReference).start() guard let controller = component.controller() as? StoryContainerScreen else { return @@ -7638,7 +7640,7 @@ public final class StoryItemSetContainerComponent: Component { return } - let _ = component.context.engine.messages.enqueueOutgoingMessage(to: component.context.account.peerId, replyTo: nil, content: .file(file)).start() + let _ = component.context.engine.messages.enqueueOutgoingMessage(to: component.context.account.peerId, replyTo: nil, content: .file(fileReference)).start() guard let controller = component.controller() as? StoryContainerScreen else { return diff --git a/submodules/TelegramUI/Components/VideoAnimationCache/Sources/VideoAnimationCache.swift b/submodules/TelegramUI/Components/VideoAnimationCache/Sources/VideoAnimationCache.swift index 5eaa7014cb..6c14e57e09 100644 --- a/submodules/TelegramUI/Components/VideoAnimationCache/Sources/VideoAnimationCache.swift +++ b/submodules/TelegramUI/Components/VideoAnimationCache/Sources/VideoAnimationCache.swift @@ -47,7 +47,7 @@ public func cacheVideoAnimation(path: String, hintVP9: Bool, width: Int, height: return frameDuration }, proposedWidth: frame.width, proposedHeight: frame.height, insertKeyframe: false) - if firstFrameOnly { + if firstFrameOnly || frameSource.frameCount == 1 { break } } else { diff --git a/submodules/TelegramUI/Images.xcassets/Item List/Icons/Gradient.imageset/gradient.pdf b/submodules/TelegramUI/Images.xcassets/Item List/Icons/Gradient.imageset/gradient.pdf index c8bc2dbfa6..c1125541bb 100644 Binary files a/submodules/TelegramUI/Images.xcassets/Item List/Icons/Gradient.imageset/gradient.pdf and b/submodules/TelegramUI/Images.xcassets/Item List/Icons/Gradient.imageset/gradient.pdf differ diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollContextMenu.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollContextMenu.swift index 7d9eca234f..fe2a3f3ddc 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollContextMenu.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollContextMenu.swift @@ -15,6 +15,7 @@ import Pasteboard import TelegramStringFormatting import TelegramPresentationData import AvatarNode +import ChatPresentationInterfaceState private enum OptionsId: Hashable { case item @@ -82,7 +83,12 @@ extension ChatControllerImpl { } } - if canReplyInChat(self.presentationInterfaceState, accountPeerId: self.context.account.peerId) { + var canReply = canReplyInChat(self.presentationInterfaceState, accountPeerId: self.context.account.peerId) + if !canSendMessagesToChat(self.presentationInterfaceState) && (self.presentationInterfaceState.copyProtectionEnabled || message.isCopyProtected()) { + canReply = false + } + + if canReply { items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.Chat_Poll_ReplyToOption, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Reply"), color: theme.actionSheet.primaryTextColor) }, action: { [weak self] c, _ in @@ -165,13 +171,15 @@ extension ChatControllerImpl { if let addedByPeer, let date = pollOption.date { var canRemove = false - if poll.isCreator { - canRemove = true - } else if addedByPeer.id == self.context.account.peerId { - let pollConfiguration = PollConfiguration.with(appConfiguration: self.context.currentAppConfiguration.with { $0 }) - let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) - if currentTime < date + pollConfiguration.pollOptionDeletePeriod { + if !poll.isClosed { + if poll.isCreator { canRemove = true + } else if addedByPeer.id == self.context.account.peerId { + let pollConfiguration = PollConfiguration.with(appConfiguration: self.context.currentAppConfiguration.with { $0 }) + let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) + if currentTime < date + pollConfiguration.pollOptionDeletePeriod { + canRemove = true + } } } if canRemove { diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift index c48cef418d..8d88365bd7 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift @@ -15,6 +15,7 @@ import ChatControllerInteraction import Pasteboard import TelegramStringFormatting import TelegramPresentationData +import ChatPresentationInterfaceState private enum OptionsId: Hashable { case item @@ -125,7 +126,12 @@ extension ChatControllerImpl { } } - if canReplyInChat(self.presentationInterfaceState, accountPeerId: self.context.account.peerId) { + var canReply = canReplyInChat(self.presentationInterfaceState, accountPeerId: self.context.account.peerId) + if !canSendMessagesToChat(self.presentationInterfaceState) && (self.presentationInterfaceState.copyProtectionEnabled || message.isCopyProtected()) { + canReply = false + } + + if canReply { items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.Chat_Todo_ReplyToItem, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Reply"), color: theme.actionSheet.primaryTextColor) }, action: { [weak self] c, _ in diff --git a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift index 97d8168aaf..2fe3644275 100644 --- a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift +++ b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift @@ -588,10 +588,11 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu guard let self else { return false } + if self.historyFrameTopOverlayNode.bounds.contains(self.view.convert(point, to: self.historyFrameTopOverlayNode.view)) { + return true + } if self.controlsNode.bounds.contains(self.view.convert(point, to: self.controlsNode.view)) { - if self.controlsNode.frame.maxY <= self.historyNode.frame.minY { - return true - } + return true } return false } @@ -1056,7 +1057,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu if !self.bounds.contains(point) { return nil } - if point.y < self.historyFrameNode.frame.minY { + if self.albumArtBackground.superview == nil && point.y < self.historyFrameNode.frame.minY { return self.dimNode.view } return result diff --git a/submodules/TelegramUI/Sources/OverlayAudioPlayerControlsNode.swift b/submodules/TelegramUI/Sources/OverlayAudioPlayerControlsNode.swift index 295df935ca..fb1bb8ed30 100644 --- a/submodules/TelegramUI/Sources/OverlayAudioPlayerControlsNode.swift +++ b/submodules/TelegramUI/Sources/OverlayAudioPlayerControlsNode.swift @@ -953,6 +953,11 @@ final class OverlayAudioPlayerControlsNode: ASDisplayNode { } profileAudioTransition.updateFrame(view: profileAudioView, frame: profileAudioFrame) } + } else if let profileAudio = self.profileAudio { + self.profileAudio = nil + if let profileAudioView = profileAudio.view { + profileAudioView.removeFromSuperview() + } } return finalPanelHeight