Various fixes

This commit is contained in:
Ilya Laktyushin 2025-07-21 01:08:46 +02:00
parent 9d703f5b60
commit c9e8fe831a
3 changed files with 31 additions and 16 deletions

View File

@ -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."; "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.AddGiftsButton" = "Add Gifts";
"PeerInfo.Gifts.AddCollection" = "Add Collection"; "PeerInfo.Gifts.AddCollection" = "Add Collection";

View File

@ -114,6 +114,7 @@ final class AddGiftsScreenComponent: Component {
var contentSize = CGSize(width: self.scrollView.bounds.width, height: contentHeight) var contentSize = CGSize(width: self.scrollView.bounds.width, height: contentHeight)
contentSize.height += environment.safeInsets.bottom contentSize.height += environment.safeInsets.bottom
contentSize.height = max(contentSize.height, self.scrollView.bounds.size.height) 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)) transition.setFrame(view: giftsListView, frame: CGRect(origin: CGPoint(), size: contentSize))
if self.scrollView.contentSize != contentSize { if self.scrollView.contentSize != contentSize {

View File

@ -523,13 +523,19 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
var topInset: CGFloat = 60.0 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] = [] var tabSelectorItems: [TabSelectorComponent.Item] = []
tabSelectorItems.append(TabSelectorComponent.Item( tabSelectorItems.append(TabSelectorComponent.Item(
id: AnyHashable(GiftCollection.all.rawValue), id: AnyHashable(GiftCollection.all.rawValue),
title: "All Gifts" title: params.presentationData.strings.PeerInfo_Gifts_Collections_All
)) ))
var effectiveCollections: [StarGiftCollection] = collections var effectiveCollections: [StarGiftCollection] = collections
if let reorderedCollectionIds = self.reorderedCollectionIds { if let reorderedCollectionIds = self.reorderedCollectionIds {
var collectionMap: [Int32: StarGiftCollection] = [:] var collectionMap: [Int32: StarGiftCollection] = [:]
@ -546,6 +552,9 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
} }
for collection in effectiveCollections { for collection in effectiveCollections {
if !canEditCollections && collection.count == 0 {
continue
}
tabSelectorItems.append(TabSelectorComponent.Item( tabSelectorItems.append(TabSelectorComponent.Item(
id: AnyHashable(GiftCollection.collection(collection.id).rawValue), id: AnyHashable(GiftCollection.collection(collection.id).rawValue),
content: .component(AnyComponent( content: .component(AnyComponent(
@ -565,19 +574,21 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
} }
)) ))
} }
tabSelectorItems.append(TabSelectorComponent.Item( if canEditCollections {
id: AnyHashable(GiftCollection.create.rawValue), tabSelectorItems.append(TabSelectorComponent.Item(
content: .component(AnyComponent( id: AnyHashable(GiftCollection.create.rawValue),
CollectionTabItemComponent( content: .component(AnyComponent(
context: self.context, CollectionTabItemComponent(
icon: .add, context: self.context,
title: "Add Collection", icon: .add,
theme: params.presentationData.theme title: params.presentationData.strings.PeerInfo_Gifts_Collections_Add,
) theme: params.presentationData.theme
)), )
isReorderable: false )),
)) isReorderable: false
))
}
let tabSelectorSize = self.tabSelector.update( let tabSelectorSize = self.tabSelector.update(
transition: transition, transition: transition,