Various fixes

This commit is contained in:
Ilya Laktyushin 2025-07-21 13:39:37 +02:00
parent c9e8fe831a
commit 28b0334952
7 changed files with 107 additions and 41 deletions

View File

@ -14731,6 +14731,12 @@ Sorry for the inconvenience.";
"PeerInfo.Gifts.EmptyCollection.Text" = "Add some gifts to this collection.";
"PeerInfo.Gifts.EmptyCollection.Action" = "Add to Collection";
"PeerInfo.Gifts.AddedToCollection" = "The gift has been added to **%@**.";
"PeerInfo.Gifts.RemovedFromCollection" = "The gift has been removed from **%@**.";
"PeerInfo.Gifts.AddedToCollectionUnique" = "**%1$@** has been added to **%2$@**.";
"PeerInfo.Gifts.RemovedFromCollectionUnique" = "**%1$@** has been removed from **%2$@**.";
"AddGifts.Title" = "Add Gifts";
"AddGifts.AddGifts_1" = "Add %@ Gift";
"AddGifts.AddGifts_any" = "Add %@ Gifts";

View File

@ -3097,12 +3097,6 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
}
}
//TODO:release
if let product = availableProducts.first(where: { $0.id.hasSuffix(".annual") }) {
let (currency, price) = product.priceCurrencyAndAmount
products.insert(PremiumProduct(option: PremiumPromoConfiguration.PremiumProductOption(isCurrent: false, months: 24, currency: currency, amount: price * 2, botUrl: "", transactionId: nil, availableForUpgrade: true, storeProductId: "org.telegram.telegramPremium.biannual"), storeProduct: product), at: 0)
}
strongSelf.products = products
strongSelf.isPremium = forceHasPremium || isPremium
strongSelf.otherPeerName = otherPeerName

View File

@ -11364,7 +11364,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
let canReorderEquals = lhs.2 == rhs.2
return filterEquals && sortingEquals && canReorderEquals
})
|> map { [weak self, weak pane, weak giftsContext] filter, sorting, canReorder -> ContextController.Items in
|> map { [weak pane, weak giftsContext] filter, sorting, canReorder -> ContextController.Items in
var items: [ContextMenuItem] = []
if hasVisibility {
@ -11389,13 +11389,12 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
}
})))
items.append(.action(ContextMenuActionItem(text: strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, f in
f(.default)
//TODO:release
self?.openShareLink(url: "https://t.me/")
})))
// items.append(.action(ContextMenuActionItem(text: strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
// return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor)
// }, action: { [weak self] _, f in
// f(.default)
// self?.openShareLink(url: "https://t.me/")
// })))
}
if canReorder {

View File

@ -409,6 +409,13 @@ final class GiftsListView: UIView {
return self.updateScrolling(interactive: interactive, topInset: topInset, visibleBounds: visibleBounds, transition: transition)
}
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
if let topInset = self.topInset, point.y < topInset {
return false
}
return super.point(inside: point, with: event)
}
func updateScrolling(interactive: Bool = false, topInset: CGFloat, visibleBounds: CGRect, transition: ComponentTransition) -> CGFloat {
self.topInset = topInset
self.visibleBounds = visibleBounds

View File

@ -184,7 +184,11 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
self.scrollNode.view.contentInsetAdjustmentBehavior = .never
self.scrollNode.view.delegate = self
self.scrollNode.view.insertSubview(self.giftsListView, at: 0)
if let tabSelectorView = self.tabSelector.view {
self.scrollNode.view.insertSubview(self.giftsListView, aboveSubview: tabSelectorView)
} else {
self.scrollNode.view.insertSubview(self.giftsListView, at: 0)
}
}
private func item(at point: CGPoint) -> (AnyHashable, ComponentView<Empty>)? {
@ -211,6 +215,10 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
}
if let collection {
self.setCurrentCollection(collection: .collection(collection.id))
if let tabSelectorView = self.tabSelector.view as? TabSelectorComponent.View {
tabSelectorView.scrollToEnd()
}
}
})
})
@ -230,6 +238,10 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
self?.setCurrentCollection(collection: .all)
let _ = self?.profileGiftsCollections.deleteCollection(id: id).start()
if let tabSelectorView = self?.tabSelector.view as? TabSelectorComponent.View {
tabSelectorView.scrollToStart()
}
})
]),
ActionSheetItemGroup(items: [
@ -468,21 +480,22 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
}
f(.default)
self.renameCollection(id: id)
})))
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.actionSheet.primaryTextColor)
}, action: { [weak self] _, f in
guard let self else {
return
Queue.mainQueue().after(0.15) {
self.renameCollection(id: id)
}
f(.default)
//TODO:release
let _ = self
})))
// items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
// return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.actionSheet.primaryTextColor)
// }, action: { [weak self] _, f in
// guard let self else {
// return
// }
// f(.default)
//
// let _ = self
// })))
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_Reorder, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ReorderItems"), color: theme.actionSheet.primaryTextColor)
}, action: { [weak self] c, f in
@ -502,7 +515,9 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
}
f(.default)
self.deleteCollection(id: id)
Queue.mainQueue().after(0.15) {
self.deleteCollection(id: id)
}
})))
let contextController = ContextController(
@ -640,7 +655,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
if let tabSelectorView = self.tabSelector.view {
if tabSelectorView.superview == nil {
tabSelectorView.alpha = 1.0
self.scrollNode.view.addSubview(tabSelectorView)
self.scrollNode.view.insertSubview(tabSelectorView, at: 0)
if !transition.animation.isImmediate {
tabSelectorView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
@ -957,10 +972,52 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
}, iconPosition: collection.icon == nil ? .left : .right, action: { [weak self] _, f in
f(.default)
guard let self else {
return
}
if isAdded, let giftReference = gift.reference {
let _ = self?.profileGiftsCollections.removeGifts(id: collection.id, gifts: [giftReference]).start()
let _ = self.profileGiftsCollections.removeGifts(id: collection.id, gifts: [giftReference]).start()
} else {
let _ = self?.profileGiftsCollections.addGifts(id: collection.id, gifts: [gift]).start()
let _ = self.profileGiftsCollections.addGifts(id: collection.id, gifts: [gift]).start()
}
var giftFile: TelegramMediaFile?
var giftTitle: String?
switch gift.gift {
case let .generic(gift):
giftFile = gift.file
case let .unique(uniqueGift):
giftTitle = uniqueGift.title + " #\(presentationStringsFormattedNumber(uniqueGift.number, currentParams.presentationData.dateTimeFormat.groupingSeparator))"
for attribute in uniqueGift.attributes {
if case let .model(_, file, _) = attribute {
giftFile = file
}
}
}
if let giftFile {
let text: String
if let giftTitle {
if isAdded {
text = currentParams.presentationData.strings.PeerInfo_Gifts_RemovedFromCollectionUnique(giftTitle, collection.title).string
} else {
text = currentParams.presentationData.strings.PeerInfo_Gifts_AddedToCollectionUnique(giftTitle, collection.title).string
}
} else {
if isAdded {
text = currentParams.presentationData.strings.PeerInfo_Gifts_RemovedFromCollection(collection.title).string
} else {
text = currentParams.presentationData.strings.PeerInfo_Gifts_AddedToCollection(collection.title).string
}
}
let undoController = UndoOverlayController(
presentationData: currentParams.presentationData,
content: .sticker(context: self.context, file: giftFile, loop: false, title: nil, text: text, undoText: nil, customAction: nil),
action: { _ in return true }
)
self.parentController?.present(undoController, in: .current)
}
})))
}
@ -1370,14 +1427,12 @@ private final class CollectionTabItemComponent: Component {
let titleSize = self.title.update(
transition: .immediate,
component: AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(string: component.title, font: Font.semibold(14.0), textColor: .white))
text: .plain(NSAttributedString(string: component.title, font: Font.semibold(14.0), textColor: component.theme.list.itemSecondaryTextColor))
)),
environment: {},
containerSize: CGSize(width: availableSize.width, height: 100.0)
)
let tintColor = component.theme.list.itemSecondaryTextColor
var iconOffset: CGFloat = 0.0
var iconSize = CGSize()
if let icon = component.icon {
@ -1411,7 +1466,7 @@ private final class CollectionTabItemComponent: Component {
transition: .immediate,
component: AnyComponent(BundleIconComponent(
name: "Chat/Input/Media/PanelBadgeAdd",
tintColor: tintColor
tintColor: component.theme.list.itemSecondaryTextColor
)),
environment: {},
containerSize: CGSize(width: 100.0, height: 100.0)
@ -1447,8 +1502,6 @@ private final class CollectionTabItemComponent: Component {
self.addSubview(titleView)
}
titleView.frame = titleFrame
transition.setTintColor(layer: titleView.layer, color: tintColor)
}
let size: CGSize

View File

@ -483,6 +483,14 @@ public final class TabSelectorComponent: Component {
}
}
public func scrollToStart() {
self.setContentOffset(.zero, animated: true)
}
public func scrollToEnd() {
self.setContentOffset(CGPoint(x: self.contentSize.width - self.bounds.width, y: 0.0), animated: true)
}
func update(component: TabSelectorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
let selectionColorUpdated = component.colors.selection != self.component?.colors.selection

View File

@ -128,8 +128,7 @@ extension ChatControllerImpl {
}
}
if "".isEmpty {
//TODO:release
if canReplyInChat(self.presentationInterfaceState, accountPeerId: self.context.account.peerId) {
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