diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 389d6884de..ff8bcd7404 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -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"; diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index 76fba73534..e0961e864b 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -3096,13 +3096,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent { products.append(PremiumProduct(option: option, storeProduct: product)) } } - - //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 diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 557f3ff470..43cd0843f6 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -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 { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/GiftsListView.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/GiftsListView.swift index b42e5eae26..2a52b933bc 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/GiftsListView.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/GiftsListView.swift @@ -408,6 +408,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 diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift index 8d334f5a33..0c732eb347 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift @@ -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)? { @@ -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,20 +480,21 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr } f(.default) - self.renameCollection(id: id) + Queue.mainQueue().after(0.15) { + 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 - } - 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) @@ -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 diff --git a/submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift b/submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift index 53502dd20c..ef0827e734 100644 --- a/submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift +++ b/submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift @@ -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, transition: ComponentTransition) -> CGSize { let selectionColorUpdated = component.colors.selection != self.component?.colors.selection diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift index 36860380ad..e2dcfb2857 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift @@ -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