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.";
"PeerInfo.Gifts.Collections.All" = "All Gifts";
"PeerInfo.Gifts.Collections.Add" = "Add Collection";
"PeerInfo.Gifts.AddGiftsButton" = "Add Gifts";
"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)
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 {

View File

@ -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,