From ab042530aee140e274bfbf2a901104ccbcb55cca Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 13 Feb 2024 17:12:38 -0400 Subject: [PATCH 1/7] Various fixes --- .../Sources/PremiumBoostLevelsScreen.swift | 14 +++++++------- .../Sources/ChannelStatsController.swift | 2 +- .../Sources/ChannelAppearanceScreen.swift | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift b/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift index 9102055055..82569555ae 100644 --- a/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift @@ -2234,12 +2234,12 @@ public class PremiumBoostLevelsScreen: ViewController { self.myBoostCount += 1 let _ = (context.engine.peers.applyChannelBoost(peerId: peerId, slots: [availableBoost.slot]) - |> deliverOnMainQueue).startStandalone(completed: { [weak self] in + |> deliverOnMainQueue).startStandalone(next: { [weak self] myBoostStatus in self?.updatedState.set(context.engine.peers.getChannelBoostStatus(peerId: peerId) - |> beforeNext { [weak self] status in - if let self, let status { + |> beforeNext { [weak self] boostStatus in + if let self, let boostStatus, let myBoostStatus { Queue.mainQueue().async { - self.controller?.boostStatusUpdated(status) + self.controller?.boostStatusUpdated(boostStatus, myBoostStatus) } } } @@ -2293,8 +2293,8 @@ public class PremiumBoostLevelsScreen: ViewController { ).startStandalone(next: { boostStatus, myBoostStatus in dismissReplaceImpl?() - if let boostStatus { - boostStatusUpdated(boostStatus) + if let boostStatus, let myBoostStatus { + boostStatusUpdated(boostStatus, myBoostStatus) } let levelsController = PremiumBoostLevelsScreen( @@ -2466,7 +2466,7 @@ public class PremiumBoostLevelsScreen: ViewController { private var currentLayout: ContainerViewLayout? - public var boostStatusUpdated: (ChannelBoostStatus) -> Void = { _ in } + public var boostStatusUpdated: (ChannelBoostStatus, MyBoostStatus) -> Void = { _, _ in } public var disposed: () -> Void = {} public init( diff --git a/submodules/StatisticsUI/Sources/ChannelStatsController.swift b/submodules/StatisticsUI/Sources/ChannelStatsController.swift index 2c8c6cd556..1e28116b26 100644 --- a/submodules/StatisticsUI/Sources/ChannelStatsController.swift +++ b/submodules/StatisticsUI/Sources/ChannelStatsController.swift @@ -1525,7 +1525,7 @@ public func channelStatsController(context: AccountContext, updatedPresentationD controller?.push(giveawayController) } ) - boostController.boostStatusUpdated = { boostStatus in + boostController.boostStatusUpdated = { boostStatus, _ in boostDataPromise.set(.single(boostStatus)) } controller?.push(boostController) diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift index 44bf0809e3..5be45a1482 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift @@ -304,6 +304,7 @@ final class ChannelAppearanceScreenComponent: Component { private var premiumConfiguration: PremiumConfiguration? private var boostLevel: Int? private var boostStatus: ChannelBoostStatus? + private var myBoostStatus: MyBoostStatus? private var boostStatusDisposable: Disposable? private var isApplyingSettings: Bool = false @@ -656,6 +657,7 @@ final class ChannelAppearanceScreenComponent: Component { peerId: component.peerId, mode: .owner(subject: subject), status: status, + myBoostStatus: myBoostStatus, openStats: { [weak self] in guard let self else { return @@ -670,6 +672,14 @@ final class ChannelAppearanceScreenComponent: Component { self.environment?.controller()?.push(controller) } ) + controller.boostStatusUpdated = { [weak self] boostStatus, myBoostStatus in + if let self { + self.boostStatus = boostStatus + self.boostLevel = boostStatus.level + self.myBoostStatus = myBoostStatus + self.state?.updated(transition: .immediate) + } + } self.environment?.controller()?.push(controller) HapticFeedback().impact(.light) @@ -924,13 +934,16 @@ final class ChannelAppearanceScreenComponent: Component { }) } if self.boostStatusDisposable == nil { - self.boostStatusDisposable = (component.context.engine.peers.getChannelBoostStatus(peerId: component.peerId) - |> deliverOnMainQueue).start(next: { [weak self] boostStatus in + self.boostStatusDisposable = combineLatest(queue: Queue.mainQueue(), + component.context.engine.peers.getChannelBoostStatus(peerId: component.peerId), + component.context.engine.peers.getMyBoostStatus() + ).start(next: { [weak self] boostStatus, myBoostStatus in guard let self else { return } self.boostLevel = boostStatus?.level self.boostStatus = boostStatus + self.myBoostStatus = myBoostStatus if !self.isUpdating { self.state?.updated(transition: .immediate) From 6753671c31199338e42659b94058933584dd5099 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 13 Feb 2024 18:20:58 -0400 Subject: [PATCH 2/7] Update localization --- Telegram/Telegram-iOS/en.lproj/Localizable.strings | 4 ++++ submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index a647271629..18d1574745 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -11307,3 +11307,7 @@ Sorry for the inconvenience."; "Story.GroupCommentingRestrictedPlaceholder" = "Comments restricted. Boost the group to unlock."; "Story.GroupCommentingRestrictedPlaceholderAction" = "Learn More..."; + +"GroupBoost.Table.Group.VoiceToText" = "Voice-to-Text Conversion"; +"GroupBoost.Table.Group.EmojiPack" = "Custom Emojipack"; + diff --git a/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift b/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift index 82569555ae..1c97beee06 100644 --- a/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift @@ -271,9 +271,9 @@ private final class LevelSectionComponent: CombinedComponent { case .customWallpaper: return isGroup ? strings.ChannelBoost_Table_Group_CustomWallpaper : strings.ChannelBoost_Table_CustomWallpaper case .audioTranscription: - return "Voice-to-Text Conversion" + return strings.GroupBoost_Table_Group_VoiceToText case .emojiPack: - return "Custom Emojipack" + return strings.GroupBoost_Table_Group_EmojiPack } } From 26e15ebe406b98fd1f6195b050ba3b0be84f2670 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 15 Feb 2024 08:56:55 -0400 Subject: [PATCH 3/7] Various fixes --- submodules/AttachmentUI/Sources/AttachmentPanel.swift | 1 + .../Sources/ChatPanelInterfaceInteraction.swift | 4 ++++ .../Sources/ChatRecentActionsController.swift | 1 + .../PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift | 1 + .../Sources/PeerSelectionControllerNode.swift | 1 + submodules/TelegramUI/Sources/ChatController.swift | 4 ++++ .../Sources/ChatRecordingPreviewInputPanelNode.swift | 6 ++++-- 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/submodules/AttachmentUI/Sources/AttachmentPanel.swift b/submodules/AttachmentUI/Sources/AttachmentPanel.swift index 7bbc49b32c..77938c59f7 100644 --- a/submodules/AttachmentUI/Sources/AttachmentPanel.swift +++ b/submodules/AttachmentUI/Sources/AttachmentPanel.swift @@ -983,6 +983,7 @@ final class AttachmentPanel: ASDisplayNode, UIScrollViewDelegate { }, openPremiumGift: { }, openPremiumRequiredForMessaging: { }, openBoostToUnrestrict: { + }, updateVideoTrimRange: { _, _, _, _ in }, updateHistoryFilter: { _ in }, updateDisplayHistoryFilterAsList: { _ in }, requestLayout: { _ in diff --git a/submodules/ChatPresentationInterfaceState/Sources/ChatPanelInterfaceInteraction.swift b/submodules/ChatPresentationInterfaceState/Sources/ChatPanelInterfaceInteraction.swift index efdb69cdfb..02ad1afa74 100644 --- a/submodules/ChatPresentationInterfaceState/Sources/ChatPanelInterfaceInteraction.swift +++ b/submodules/ChatPresentationInterfaceState/Sources/ChatPanelInterfaceInteraction.swift @@ -176,6 +176,7 @@ public final class ChatPanelInterfaceInteraction { public let updateHistoryFilter: ((ChatPresentationInterfaceState.HistoryFilter?) -> ChatPresentationInterfaceState.HistoryFilter?) -> Void public let updateDisplayHistoryFilterAsList: (Bool) -> Void public let openBoostToUnrestrict: () -> Void + public let updateVideoTrimRange: (Double, Double, Bool, Bool) -> Void public let requestLayout: (ContainedViewLayoutTransition) -> Void public let chatController: () -> ViewController? public let statuses: ChatPanelInterfaceInteractionStatuses? @@ -286,6 +287,7 @@ public final class ChatPanelInterfaceInteraction { openPremiumGift: @escaping () -> Void, openPremiumRequiredForMessaging: @escaping () -> Void, openBoostToUnrestrict: @escaping () -> Void, + updateVideoTrimRange: @escaping (Double, Double, Bool, Bool) -> Void, updateHistoryFilter: @escaping ((ChatPresentationInterfaceState.HistoryFilter?) -> ChatPresentationInterfaceState.HistoryFilter?) -> Void, updateDisplayHistoryFilterAsList: @escaping (Bool) -> Void, requestLayout: @escaping (ContainedViewLayoutTransition) -> Void, @@ -397,6 +399,7 @@ public final class ChatPanelInterfaceInteraction { self.openPremiumGift = openPremiumGift self.openPremiumRequiredForMessaging = openPremiumRequiredForMessaging self.openBoostToUnrestrict = openBoostToUnrestrict + self.updateVideoTrimRange = updateVideoTrimRange self.updateHistoryFilter = updateHistoryFilter self.updateDisplayHistoryFilterAsList = updateDisplayHistoryFilterAsList self.requestLayout = requestLayout @@ -516,6 +519,7 @@ public final class ChatPanelInterfaceInteraction { }, openPremiumGift: { }, openPremiumRequiredForMessaging: { }, openBoostToUnrestrict: { + }, updateVideoTrimRange: { _, _, _, _ in }, updateHistoryFilter: { _ in }, updateDisplayHistoryFilterAsList: { _ in }, requestLayout: { _ in diff --git a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsController.swift b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsController.swift index 5ddd2090b0..76bab24066 100644 --- a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsController.swift +++ b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsController.swift @@ -169,6 +169,7 @@ public final class ChatRecentActionsController: TelegramBaseController { }, openPremiumGift: { }, openPremiumRequiredForMessaging: { }, openBoostToUnrestrict: { + }, updateVideoTrimRange: { _, _, _, _ in }, updateHistoryFilter: { _ in }, updateDisplayHistoryFilterAsList: { _ in }, requestLayout: { _ in diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 4a7aa3cf5d..b25119e8fa 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -419,6 +419,7 @@ final class PeerInfoSelectionPanelNode: ASDisplayNode { }, openPremiumGift: { }, openPremiumRequiredForMessaging: { }, openBoostToUnrestrict: { + }, updateVideoTrimRange: { _, _, _, _ in }, updateHistoryFilter: { _ in }, updateDisplayHistoryFilterAsList: { _ in }, requestLayout: { _ in diff --git a/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift b/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift index 6cb9794bee..a062fe259d 100644 --- a/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift +++ b/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift @@ -733,6 +733,7 @@ final class PeerSelectionControllerNode: ASDisplayNode { }, openPremiumGift: { }, openPremiumRequiredForMessaging: { }, openBoostToUnrestrict: { + }, updateVideoTrimRange: { _, _, _, _ in }, updateHistoryFilter: { _ in }, updateDisplayHistoryFilterAsList: { _ in }, requestLayout: { _ in diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 6ea3fb7ff7..8bb7463ceb 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -11096,6 +11096,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G ) self.push(boostController) }) + }, updateVideoTrimRange: { [weak self] start, end, updatedEnd, apply in + if let videoRecorder = self?.videoRecorderValue { + videoRecorder.updateTrimRange(start: start, end: end, updatedEnd: updatedEnd, apply: apply) + } }, updateHistoryFilter: { [weak self] update in guard let self else { return diff --git a/submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift index 3789f17201..6f11af4fe4 100644 --- a/submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift @@ -328,8 +328,10 @@ final class ChatRecordingPreviewInputPanelNode: ChatInputPanelNode { ) ], positionUpdated: { _, _ in }, - trackTrimUpdated: { _, start, end, updatedEnd, apply in -// video.control.updateTrimRange(start, end, updatedEnd, apply) + trackTrimUpdated: { [weak self] _, start, end, updatedEnd, apply in + if let self { + self.interfaceInteraction?.updateVideoTrimRange(start, end, updatedEnd, apply) + } }, trackOffsetUpdated: { _, _, _ in }, trackLongPressed: { _, _ in } From e81e745c939aa0c91ce5bb4915e1797d9bea199e Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 15 Feb 2024 10:02:59 -0400 Subject: [PATCH 4/7] Update localization --- Telegram/Telegram-iOS/en.lproj/Localizable.strings | 4 ++++ submodules/StatisticsUI/Sources/BoostHeaderItem.swift | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 18d1574745..bb57aa4961 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -11311,3 +11311,7 @@ Sorry for the inconvenience."; "GroupBoost.Table.Group.VoiceToText" = "Voice-to-Text Conversion"; "GroupBoost.Table.Group.EmojiPack" = "Custom Emojipack"; +"ChannelBoost.Header.Boost" = "boost"; +"ChannelBoost.Header.Giveaway" = "giveaway"; +"ChannelBoost.Header.Features" = "features"; + diff --git a/submodules/StatisticsUI/Sources/BoostHeaderItem.swift b/submodules/StatisticsUI/Sources/BoostHeaderItem.swift index 722a0f0384..afa0504a35 100644 --- a/submodules/StatisticsUI/Sources/BoostHeaderItem.swift +++ b/submodules/StatisticsUI/Sources/BoostHeaderItem.swift @@ -399,7 +399,7 @@ private final class BoostHeaderComponent: CombinedComponent { content: AnyComponent( BoostButtonComponent( iconName: "Premium/Boosts/Boost", - title: "boost" + title: component.strings.ChannelBoost_Header_Boost ) ), effectAlignment: .center, @@ -419,7 +419,7 @@ private final class BoostHeaderComponent: CombinedComponent { content: AnyComponent( BoostButtonComponent( iconName: "Premium/Boosts/Giveaway", - title: "giveaway" + title: component.strings.ChannelBoost_Header_Giveaway ) ), effectAlignment: .center, @@ -439,7 +439,7 @@ private final class BoostHeaderComponent: CombinedComponent { content: AnyComponent( BoostButtonComponent( iconName: "Premium/Boosts/Features", - title: "features" + title: component.strings.ChannelBoost_Header_Features ) ), effectAlignment: .center, From 11bd9bb5564b62e8b4993c0e50c7d85e428c72b0 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 15 Feb 2024 10:28:37 -0400 Subject: [PATCH 5/7] Various fixes --- submodules/ChatListUI/Sources/ChatListController.swift | 5 ++++- .../PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 7bf10600ba..7ac1f2f4a5 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -2905,14 +2905,17 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController }))) } else if case let .channel(channel) = peer { let openTitle: String + let openIcon: String switch channel.info { case .broadcast: openTitle = self.presentationData.strings.ChatList_ContextOpenChannel + openIcon = "Chat/Context Menu/Channels" case .group: openTitle = self.presentationData.strings.ChatList_ContextOpenGroup + openIcon = "Chat/Context Menu/Groups" } items.append(.action(ContextMenuActionItem(text: openTitle, icon: { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Channels"), color: theme.contextMenu.primaryColor) + return generateTintedImage(image: UIImage(bundleImageName: openIcon), color: theme.contextMenu.primaryColor) }, action: { [weak self] c, _ in c.dismiss(completion: { guard let self else { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index b25119e8fa..575cb91b27 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -1728,7 +1728,7 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL } } - if let cachedData = data.cachedData as? CachedChannelData, cachedData.flags.contains(.canViewStats) { + if let cachedData = data.cachedData as? CachedChannelData, isCreator || cachedData.flags.contains(.canViewStats) { items[.peerAdditionalSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemStats, label: .none, text: presentationData.strings.Channel_Info_Stats, icon: UIImage(bundleImageName: "Chat/Info/StatsIcon"), action: { interaction.openStats(false) })) From 77d45e60bcb6bc2d81c19e722cb735ffa147f2b8 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 15 Feb 2024 16:15:48 -0400 Subject: [PATCH 6/7] Various fixes --- .../AvatarNode/Sources/AvatarNode.swift | 24 +++++++++++++++---- .../AvatarStoryIndicatorComponent.swift | 22 ++++++++++++----- .../Sources/VideoMessageCameraScreen.swift | 12 +++++----- .../TelegramUI/Sources/ChatController.swift | 2 +- .../Sources/ChatControllerNode.swift | 2 +- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/submodules/AvatarNode/Sources/AvatarNode.swift b/submodules/AvatarNode/Sources/AvatarNode.swift index b9428f29a9..565946d3e0 100644 --- a/submodules/AvatarNode/Sources/AvatarNode.swift +++ b/submodules/AvatarNode/Sources/AvatarNode.swift @@ -277,13 +277,16 @@ public final class AvatarNode: ASDisplayNode { private struct Params: Equatable { let peerId: EnginePeer.Id? let resourceId: String? + let clipStyle: AvatarNodeClipStyle init( peerId: EnginePeer.Id?, - resourceId: String? + resourceId: String?, + clipStyle: AvatarNodeClipStyle ) { self.peerId = peerId self.resourceId = resourceId + self.clipStyle = clipStyle } } @@ -315,6 +318,15 @@ public final class AvatarNode: ASDisplayNode { private var params: Params? private var loadDisposable: Disposable? + var clipStyle: AvatarNodeClipStyle { + if let params = self.params { + return params.clipStyle + } else if case let .peerAvatar(_, _, _, _, clipStyle) = self.state { + return clipStyle + } + return .none + } + public var badgeView: AvatarBadgeView? { didSet { if self.badgeView !== oldValue { @@ -516,6 +528,7 @@ public final class AvatarNode: ASDisplayNode { } else if peer?.restrictionText(platform: "ios", contentSettings: contentSettings) == nil { representation = peer?.smallProfileImage } + let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? EnginePeer.Id(0), peer?.nameColor, peer?.displayLetters ?? [], representation, clipStyle) if updatedState != self.state || overrideImage != self.overrideImage || theme !== self.theme { self.state = updatedState @@ -599,7 +612,8 @@ public final class AvatarNode: ASDisplayNode { let smallProfileImage = peer?.smallProfileImage let params = Params( peerId: peer?.id, - resourceId: smallProfileImage?.resource.id.stringRepresentation + resourceId: smallProfileImage?.resource.id.stringRepresentation, + clipStyle: clipStyle ) if self.params == params { return @@ -689,6 +703,7 @@ public final class AvatarNode: ASDisplayNode { } else if peer?.restrictionText(platform: "ios", contentSettings: genericContext.currentContentSettings.with { $0 }) == nil { representation = peer?.smallProfileImage } + let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? EnginePeer.Id(0), peer?.nameColor, peer?.displayLetters ?? [], representation, clipStyle) if updatedState != self.state || overrideImage != self.overrideImage || theme !== self.theme { self.state = updatedState @@ -1236,7 +1251,7 @@ public final class AvatarNode: ASDisplayNode { } let size = self.bounds.size - + if let storyStats = self.storyStats { let activeLineWidth = storyPresentationParams.lineWidth let inactiveLineWidth = storyPresentationParams.inactiveLineWidth @@ -1274,7 +1289,8 @@ public final class AvatarNode: ASDisplayNode { totalCount: storyStats.totalCount, unseenCount: storyStats.unseenCount ), - progress: mappedProgress + progress: mappedProgress, + isRoundedRect: self.contentNode.clipStyle == .roundedRect )), environment: {}, containerSize: indicatorSize diff --git a/submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent/Sources/AvatarStoryIndicatorComponent.swift b/submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent/Sources/AvatarStoryIndicatorComponent.swift index 2c86f95315..ebe68f2d33 100644 --- a/submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent/Sources/AvatarStoryIndicatorComponent.swift +++ b/submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent/Sources/AvatarStoryIndicatorComponent.swift @@ -50,6 +50,7 @@ public final class AvatarStoryIndicatorComponent: Component { public let inactiveLineWidth: CGFloat public let counters: Counters? public let progress: Progress? + public let isRoundedRect: Bool public init( hasUnseen: Bool, @@ -58,7 +59,8 @@ public final class AvatarStoryIndicatorComponent: Component { activeLineWidth: CGFloat, inactiveLineWidth: CGFloat, counters: Counters?, - progress: Progress? = nil + progress: Progress? = nil, + isRoundedRect: Bool = false ) { self.hasUnseen = hasUnseen self.hasUnseenCloseFriendsItems = hasUnseenCloseFriendsItems @@ -67,6 +69,7 @@ public final class AvatarStoryIndicatorComponent: Component { self.inactiveLineWidth = inactiveLineWidth self.counters = counters self.progress = progress + self.isRoundedRect = isRoundedRect } public static func ==(lhs: AvatarStoryIndicatorComponent, rhs: AvatarStoryIndicatorComponent) -> Bool { @@ -91,6 +94,9 @@ public final class AvatarStoryIndicatorComponent: Component { if lhs.progress != rhs.progress { return false } + if lhs.isRoundedRect != rhs.isRoundedRect { + return false + } return true } @@ -211,7 +217,7 @@ public final class AvatarStoryIndicatorComponent: Component { } } - func update(size: CGSize, radius: CGFloat, lineWidth: CGFloat, value: Value, transition: Transition) { + func update(size: CGSize, radius: CGFloat, isRoundedRect: Bool, lineWidth: CGFloat, value: Value, transition: Transition) { let params = Params( size: size, lineWidth: lineWidth, @@ -295,7 +301,7 @@ public final class AvatarStoryIndicatorComponent: Component { var locations: [CGFloat] = [0.0, 1.0] - if let counters = component.counters, counters.totalCount > 1 { + if let counters = component.counters, counters.totalCount > 1, !component.isRoundedRect { let center = CGPoint(x: size.width * 0.5, y: size.height * 0.5) let spacing: CGFloat = component.activeLineWidth * 2.0 let angularSpacing: CGFloat = spacing / radius @@ -347,7 +353,11 @@ public final class AvatarStoryIndicatorComponent: Component { } else { let lineWidth: CGFloat = component.hasUnseen ? component.activeLineWidth : component.inactiveLineWidth context.setLineWidth(lineWidth) - context.addEllipse(in: CGRect(origin: CGPoint(x: size.width * 0.5 - diameter * 0.5, y: size.height * 0.5 - diameter * 0.5), size: size).insetBy(dx: lineWidth * 0.5, dy: lineWidth * 0.5)) + if component.isRoundedRect { + context.addPath(UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: size.width * 0.5 - diameter * 0.5, y: size.height * 0.5 - diameter * 0.5), size: size).insetBy(dx: lineWidth * 0.5, dy: lineWidth * 0.5), cornerRadius: floor(diameter * 0.25)).cgPath) + } else { + context.addEllipse(in: CGRect(origin: CGPoint(x: size.width * 0.5 - diameter * 0.5, y: size.height * 0.5 - diameter * 0.5), size: size).insetBy(dx: lineWidth * 0.5, dy: lineWidth * 0.5)) + } context.replacePathWithStrokedPath() context.clip() @@ -369,7 +379,7 @@ public final class AvatarStoryIndicatorComponent: Component { transition.setFrame(view: self.indicatorView, frame: indicatorFrame) let progressTransition = Transition(animation: .curve(duration: 0.3, curve: .easeInOut)) - if let progress = component.progress { + if let progress = component.progress, !component.isRoundedRect { let colorLayer: SimpleGradientLayer if let current = self.colorLayer { colorLayer = current @@ -415,7 +425,7 @@ public final class AvatarStoryIndicatorComponent: Component { mappedProgress = .progress(value) } - progressLayer.update(size: indicatorFrame.size, radius: radius, lineWidth: lineWidth, value: mappedProgress, transition: .immediate) + progressLayer.update(size: indicatorFrame.size, radius: radius, isRoundedRect: component.isRoundedRect, lineWidth: lineWidth, value: mappedProgress, transition: .immediate) } else { progressTransition.setAlpha(view: self.indicatorView, alpha: 1.0) diff --git a/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/VideoMessageCameraScreen.swift b/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/VideoMessageCameraScreen.swift index 9667631c9d..2bcc721ece 100644 --- a/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/VideoMessageCameraScreen.swift +++ b/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/VideoMessageCameraScreen.swift @@ -966,7 +966,7 @@ public class VideoMessageCameraScreen: ViewController { if let controller = self.controller, let layout = self.validLayout { let insets = layout.insets(options: .input) - if point.y > layout.size.height - insets.bottom - controller.inputPanelFrame.height { + if point.y > layout.size.height - insets.bottom - controller.inputPanelFrame.0.height { if layout.metrics.isTablet { if point.x < layout.size.width * 0.33 { return result @@ -1111,9 +1111,9 @@ public class VideoMessageCameraScreen: ViewController { self.didAppear() } - var backgroundFrame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: controller.inputPanelFrame.minY)) - if backgroundFrame.maxY < layout.size.height - 100.0 && (layout.inputHeight ?? 0.0).isZero { - backgroundFrame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: layout.size.height - layout.intrinsicInsets.bottom - controller.inputPanelFrame.height)) + var backgroundFrame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: controller.inputPanelFrame.0.minY)) + if backgroundFrame.maxY < layout.size.height - 100.0 && (layout.inputHeight ?? 0.0).isZero && !controller.inputPanelFrame.1 { + backgroundFrame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: layout.size.height - layout.intrinsicInsets.bottom - controller.inputPanelFrame.0.height)) } transition.setPosition(view: self.backgroundView, position: backgroundFrame.center) @@ -1266,7 +1266,7 @@ public class VideoMessageCameraScreen: ViewController { private let context: AccountContext private let updatedPresentationData: (initial: PresentationData, signal: Signal)? - private let inputPanelFrame: CGRect + private let inputPanelFrame: (CGRect, Bool) fileprivate var allowLiveUpload: Bool fileprivate var viewOnceAvailable: Bool @@ -1417,7 +1417,7 @@ public class VideoMessageCameraScreen: ViewController { updatedPresentationData: (initial: PresentationData, signal: Signal)?, allowLiveUpload: Bool, viewOnceAvailable: Bool, - inputPanelFrame: CGRect, + inputPanelFrame: (CGRect, Bool), chatNode: ASDisplayNode?, completion: @escaping (EnqueueMessage?, Bool?, Int32?) -> Void ) { diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 8bb7463ceb..041be7de0f 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -14087,7 +14087,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G updatedPresentationData: self.updatedPresentationData, allowLiveUpload: peerId.namespace != Namespaces.Peer.SecretChat, viewOnceAvailable: !isScheduledMessages && peerId.namespace == Namespaces.Peer.CloudUser && peerId != self.context.account.peerId && !isBot, - inputPanelFrame: currentInputPanelFrame, + inputPanelFrame: (currentInputPanelFrame, self.chatDisplayNode.inputNode != nil), chatNode: self.chatDisplayNode.historyNode, completion: { [weak self] message, silentPosting, scheduleTime in guard let self, let videoController = self.videoRecorderValue else { diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index e81b8dfbc0..cdc623626e 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -188,7 +188,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { private let inputContextOverTextPanelContainer: ChatControllerTitlePanelNodeContainer private var overlayContextPanelNode: ChatInputContextPanelNode? - private var inputNode: ChatInputNode? + private(set) var inputNode: ChatInputNode? private var disappearingNode: ChatInputNode? private(set) var textInputPanelNode: ChatTextInputPanelNode? From ba24da05932f634d5d19e647fb3de0d9105dbd7c Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 15 Feb 2024 19:59:30 -0400 Subject: [PATCH 7/7] Various fixes --- submodules/AvatarNode/Sources/AvatarNode.swift | 7 +++++-- .../Sources/PeerInfoAvatarTransformContainerNode.swift | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/submodules/AvatarNode/Sources/AvatarNode.swift b/submodules/AvatarNode/Sources/AvatarNode.swift index 565946d3e0..937be9432c 100644 --- a/submodules/AvatarNode/Sources/AvatarNode.swift +++ b/submodules/AvatarNode/Sources/AvatarNode.swift @@ -1227,15 +1227,18 @@ public final class AvatarNode: ASDisplayNode { public var colors: Colors public var lineWidth: CGFloat public var inactiveLineWidth: CGFloat + public var forceRoundedRect: Bool public init( colors: Colors, lineWidth: CGFloat, - inactiveLineWidth: CGFloat + inactiveLineWidth: CGFloat, + forceRoundedRect: Bool = false ) { self.colors = colors self.lineWidth = lineWidth self.inactiveLineWidth = inactiveLineWidth + self.forceRoundedRect = forceRoundedRect } } @@ -1290,7 +1293,7 @@ public final class AvatarNode: ASDisplayNode { unseenCount: storyStats.unseenCount ), progress: mappedProgress, - isRoundedRect: self.contentNode.clipStyle == .roundedRect + isRoundedRect: self.contentNode.clipStyle == .roundedRect || storyPresentationParams.forceRoundedRect )), environment: {}, containerSize: indicatorSize diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoAvatarTransformContainerNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoAvatarTransformContainerNode.swift index 7eb9cac165..ce140b8747 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoAvatarTransformContainerNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoAvatarTransformContainerNode.swift @@ -126,10 +126,17 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode { progress: storyProgress ) } + + var isForum = false + if let peer, let channel = peer as? TelegramChannel, channel.isForum { + isForum = true + } + self.avatarNode.setStoryStats(storyStats: storyStats, presentationParams: AvatarNode.StoryPresentationParams( colors: colors, lineWidth: 3.0, - inactiveLineWidth: 1.5 + inactiveLineWidth: 1.5, + forceRoundedRect: isForum ), transition: Transition(transition)) }