From c9e8fe831a456fb324ec901b7103af3cb19e5964 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 21 Jul 2025 01:08:46 +0200 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 3 ++ .../Sources/AddGiftsScreen.swift | 1 + .../Sources/PeerInfoGiftsPaneNode.swift | 43 ++++++++++++------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index c369488679..389d6884de 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -14700,6 +14700,9 @@ Sorry for the inconvenience."; "AccessDenied.AgeVerificationCamera" = "Telegram needs access to your camera for age verification.\n\nOpen your device's Settings > Privacy > Camera and set Telegram to ON."; +"PeerInfo.Gifts.Collections.All" = "All Gifts"; +"PeerInfo.Gifts.Collections.Add" = "Add Collection"; + "PeerInfo.Gifts.AddGiftsButton" = "Add Gifts"; "PeerInfo.Gifts.AddCollection" = "Add Collection"; diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/AddGiftsScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/AddGiftsScreen.swift index 23cdd4f560..a1793154c8 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/AddGiftsScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/AddGiftsScreen.swift @@ -114,6 +114,7 @@ final class AddGiftsScreenComponent: Component { var contentSize = CGSize(width: self.scrollView.bounds.width, height: contentHeight) contentSize.height += environment.safeInsets.bottom contentSize.height = max(contentSize.height, self.scrollView.bounds.size.height) + contentSize.height += 50.0 + 24.0 transition.setFrame(view: giftsListView, frame: CGRect(origin: CGPoint(), size: contentSize)) if self.scrollView.contentSize != contentSize { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift index 3011f23546..8d334f5a33 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift @@ -523,13 +523,19 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr var topInset: CGFloat = 60.0 - if let collections = self.collections, !collections.isEmpty { + var canEditCollections = false + if self.peerId == self.context.account.peerId || self.canManage { + canEditCollections = true + } + + let hasNonEmptyCollections = self.collections?.contains(where: { $0.count > 0 }) ?? false + if let collections = self.collections, !collections.isEmpty && (hasNonEmptyCollections || canEditCollections) { var tabSelectorItems: [TabSelectorComponent.Item] = [] tabSelectorItems.append(TabSelectorComponent.Item( id: AnyHashable(GiftCollection.all.rawValue), - title: "All Gifts" + title: params.presentationData.strings.PeerInfo_Gifts_Collections_All )) - + var effectiveCollections: [StarGiftCollection] = collections if let reorderedCollectionIds = self.reorderedCollectionIds { var collectionMap: [Int32: StarGiftCollection] = [:] @@ -546,6 +552,9 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr } for collection in effectiveCollections { + if !canEditCollections && collection.count == 0 { + continue + } tabSelectorItems.append(TabSelectorComponent.Item( id: AnyHashable(GiftCollection.collection(collection.id).rawValue), content: .component(AnyComponent( @@ -565,19 +574,21 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr } )) } - - tabSelectorItems.append(TabSelectorComponent.Item( - id: AnyHashable(GiftCollection.create.rawValue), - content: .component(AnyComponent( - CollectionTabItemComponent( - context: self.context, - icon: .add, - title: "Add Collection", - theme: params.presentationData.theme - ) - )), - isReorderable: false - )) + + if canEditCollections { + tabSelectorItems.append(TabSelectorComponent.Item( + id: AnyHashable(GiftCollection.create.rawValue), + content: .component(AnyComponent( + CollectionTabItemComponent( + context: self.context, + icon: .add, + title: params.presentationData.strings.PeerInfo_Gifts_Collections_Add, + theme: params.presentationData.theme + ) + )), + isReorderable: false + )) + } let tabSelectorSize = self.tabSelector.update( transition: transition,