mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +00:00
Various improvements
This commit is contained in:
parent
7a99577093
commit
711f8f7b46
@ -14787,3 +14787,5 @@ Sorry for the inconvenience.";
|
|||||||
"Stars.SellGift.TonAmountTitle" = "PRICE IN TON";
|
"Stars.SellGift.TonAmountTitle" = "PRICE IN TON";
|
||||||
"Stars.SellGift.OnlyTon" = "Only Accept TON";
|
"Stars.SellGift.OnlyTon" = "Only Accept TON";
|
||||||
"Stars.SellGift.OnlyTonInfo" = "If the buyer pays you in TON, there's no risk of refunds, unlike with Stars payments.";
|
"Stars.SellGift.OnlyTonInfo" = "If the buyer pays you in TON, there's no risk of refunds, unlike with Stars payments.";
|
||||||
|
|
||||||
|
"Chat.ViewCollection" = "VIEW COLLECTION";
|
||||||
|
|||||||
@ -477,8 +477,7 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent
|
|||||||
case "telegram_call":
|
case "telegram_call":
|
||||||
actionTitle = item.presentationData.strings.Chat_ViewGroupCall
|
actionTitle = item.presentationData.strings.Chat_ViewGroupCall
|
||||||
case "telegram_collection":
|
case "telegram_collection":
|
||||||
//TODO:localize
|
actionTitle = item.presentationData.strings.Chat_ViewCollection
|
||||||
actionTitle = "VIEW COLLECTION"
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@ -537,7 +537,8 @@ private final class PeerInfoPendingPane {
|
|||||||
paneDidScroll: @escaping () -> Void,
|
paneDidScroll: @escaping () -> Void,
|
||||||
expandIfNeeded: @escaping () -> Void,
|
expandIfNeeded: @escaping () -> Void,
|
||||||
ensureRectVisible: @escaping (UIView, CGRect) -> Void,
|
ensureRectVisible: @escaping (UIView, CGRect) -> Void,
|
||||||
externalDataUpdated: @escaping (ContainedViewLayoutTransition) -> Void
|
externalDataUpdated: @escaping (ContainedViewLayoutTransition) -> Void,
|
||||||
|
openShareLink: @escaping (String) -> Void
|
||||||
) {
|
) {
|
||||||
var chatLocationPeerId = peerId
|
var chatLocationPeerId = peerId
|
||||||
var chatLocation = chatLocation
|
var chatLocation = chatLocation
|
||||||
@ -578,7 +579,9 @@ private final class PeerInfoPendingPane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paneNode = PeerInfoGiftsPaneNode(context: context, peerId: peerId, chatControllerInteraction: chatControllerInteraction, profileGiftsCollections: data.profileGiftsCollectionsContext!, profileGifts: data.profileGiftsContext!, canManage: canManage, canGift: canGift, initialGiftCollectionId: initialGiftCollectionId)
|
let giftPaneNode = PeerInfoGiftsPaneNode(context: context, peerId: peerId, chatControllerInteraction: chatControllerInteraction, profileGiftsCollections: data.profileGiftsCollectionsContext!, profileGifts: data.profileGiftsContext!, canManage: canManage, canGift: canGift, initialGiftCollectionId: initialGiftCollectionId)
|
||||||
|
giftPaneNode.openShareLink = openShareLink
|
||||||
|
paneNode = giftPaneNode
|
||||||
case .stories, .storyArchive, .botPreview:
|
case .stories, .storyArchive, .botPreview:
|
||||||
var canManage = false
|
var canManage = false
|
||||||
if let peer = data.peer {
|
if let peer = data.peer {
|
||||||
@ -748,6 +751,7 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat
|
|||||||
|
|
||||||
var openMediaCalendar: (() -> Void)?
|
var openMediaCalendar: (() -> Void)?
|
||||||
var openAddStory: (() -> Void)?
|
var openAddStory: (() -> Void)?
|
||||||
|
var openShareLink: ((String) -> Void)?
|
||||||
var paneDidScroll: (() -> Void)?
|
var paneDidScroll: (() -> Void)?
|
||||||
|
|
||||||
var ensurePaneRectVisible: ((UIView, CGRect) -> Void)?
|
var ensurePaneRectVisible: ((UIView, CGRect) -> Void)?
|
||||||
@ -1181,6 +1185,12 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.requestUpdate?(transition)
|
self.requestUpdate?(transition)
|
||||||
|
},
|
||||||
|
openShareLink: { [weak self] url in
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.openShareLink?(url)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.pendingPanes[key] = pane
|
self.pendingPanes[key] = pane
|
||||||
|
|||||||
@ -4103,6 +4103,13 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.paneContainerNode.openShareLink = { [weak self] url in
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.openShareLink(url: url)
|
||||||
|
}
|
||||||
|
|
||||||
self.headerNode.performButtonAction = { [weak self] key, gesture in
|
self.headerNode.performButtonAction = { [weak self] key, gesture in
|
||||||
self?.performButtonAction(key: key, gesture: gesture)
|
self?.performButtonAction(key: key, gesture: gesture)
|
||||||
}
|
}
|
||||||
@ -11392,17 +11399,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
pane.addGiftsToCollection(id: id)
|
pane.addGiftsToCollection(id: id)
|
||||||
}
|
}
|
||||||
})))
|
})))
|
||||||
|
|
||||||
if let addressName = data.peer?.addressName, !addressName.isEmpty {
|
|
||||||
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)
|
|
||||||
if let pane, case let .collection(id) = pane.currentCollection {
|
|
||||||
self?.openShareLink(url: "https://t.me/\(addressName)/c/\(id)")
|
|
||||||
}
|
|
||||||
})))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if canReorder {
|
if canReorder {
|
||||||
@ -11430,6 +11426,20 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let pane, case let .collection(id) = pane.currentCollection, let addressName = data.peer?.addressName, !addressName.isEmpty {
|
||||||
|
let shareAction: ContextMenuItem = .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/\(addressName)/c/\(id)")
|
||||||
|
}))
|
||||||
|
if items.isEmpty {
|
||||||
|
items.append(shareAction)
|
||||||
|
} else {
|
||||||
|
items.insert(shareAction, at: 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !items.isEmpty {
|
if !items.isEmpty {
|
||||||
items.append(.separator)
|
items.append(.separator)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
private let profileGifts: ProfileGiftsContext
|
private let profileGifts: ProfileGiftsContext
|
||||||
private let canManage: Bool
|
private let canManage: Bool
|
||||||
private let canGift: Bool
|
private let canGift: Bool
|
||||||
|
private var peer: EnginePeer?
|
||||||
private let initialGiftCollectionId: Int64?
|
private let initialGiftCollectionId: Int64?
|
||||||
|
|
||||||
private var resultsAreEmpty = false
|
private var resultsAreEmpty = false
|
||||||
@ -130,6 +131,8 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
return self.giftsListView.profileGifts
|
return self.giftsListView.profileGifts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var openShareLink: ((String) -> Void)?
|
||||||
|
|
||||||
private let collectionsMaxCount: Int
|
private let collectionsMaxCount: Int
|
||||||
|
|
||||||
public init(context: AccountContext, peerId: PeerId, chatControllerInteraction: ChatControllerInteraction, profileGiftsCollections: ProfileGiftsCollectionsContext, profileGifts: ProfileGiftsContext, canManage: Bool, canGift: Bool, initialGiftCollectionId: Int64?) {
|
public init(context: AccountContext, peerId: PeerId, chatControllerInteraction: ChatControllerInteraction, profileGiftsCollections: ProfileGiftsCollectionsContext, profileGifts: ProfileGiftsContext, canManage: Bool, canGift: Bool, initialGiftCollectionId: Int64?) {
|
||||||
@ -193,6 +196,15 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
if let initialGiftCollectionId {
|
if let initialGiftCollectionId {
|
||||||
self.setCurrentCollection(collection: .collection(Int32(initialGiftCollectionId)))
|
self.setCurrentCollection(collection: .collection(Int32(initialGiftCollectionId)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] peer in
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.peer = peer
|
||||||
|
self.updateScrolling(transition: .immediate)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
@ -485,8 +497,14 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var canEditCollections = false
|
||||||
|
if self.peerId == self.context.account.peerId || self.canManage {
|
||||||
|
canEditCollections = true
|
||||||
|
}
|
||||||
|
|
||||||
var items: [ContextMenuItem] = []
|
var items: [ContextMenuItem] = []
|
||||||
|
|
||||||
|
if canEditCollections {
|
||||||
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_AddGifts, icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_AddGifts, icon: { theme in
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Peer Info/Gifts/AddGift"), color: theme.actionSheet.primaryTextColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Peer Info/Gifts/AddGift"), color: theme.actionSheet.primaryTextColor)
|
||||||
}, action: { [weak self] _, f in
|
}, action: { [weak self] _, f in
|
||||||
@ -511,19 +529,22 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
self.renameCollection(id: id)
|
self.renameCollection(id: id)
|
||||||
}
|
}
|
||||||
})))
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
|
if let peer = self.peer, let addressName = peer.addressName, !addressName.isEmpty {
|
||||||
|
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)
|
||||||
|
|
||||||
// items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
|
self.openShareLink?("https://t.me/\(addressName)/c/\(id)")
|
||||||
// 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
|
|
||||||
// })))
|
|
||||||
|
|
||||||
|
if canEditCollections {
|
||||||
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_Reorder, icon: { theme in
|
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)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ReorderItems"), color: theme.actionSheet.primaryTextColor)
|
||||||
}, action: { [weak self] c, f in
|
}, action: { [weak self] c, f in
|
||||||
@ -547,6 +568,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
self.deleteCollection(id: id)
|
self.deleteCollection(id: id)
|
||||||
}
|
}
|
||||||
})))
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
let contextController = ContextController(
|
let contextController = ContextController(
|
||||||
presentationData: params.presentationData,
|
presentationData: params.presentationData,
|
||||||
@ -568,6 +590,10 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
if self.peerId == self.context.account.peerId || self.canManage {
|
if self.peerId == self.context.account.peerId || self.canManage {
|
||||||
canEditCollections = true
|
canEditCollections = true
|
||||||
}
|
}
|
||||||
|
var canShare = false
|
||||||
|
if let peer = self.peer, let addressName = peer.addressName, !addressName.isEmpty {
|
||||||
|
canShare = true
|
||||||
|
}
|
||||||
|
|
||||||
let hasNonEmptyCollections = self.collections?.contains(where: { $0.count > 0 }) ?? false
|
let hasNonEmptyCollections = self.collections?.contains(where: { $0.count > 0 }) ?? false
|
||||||
if let collections = self.collections, !collections.isEmpty && (hasNonEmptyCollections || canEditCollections) {
|
if let collections = self.collections, !collections.isEmpty && (hasNonEmptyCollections || canEditCollections) {
|
||||||
@ -607,7 +633,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
isReorderable: collections.count > 1,
|
isReorderable: collections.count > 1,
|
||||||
contextAction: canEditCollections ? { [weak self] sourceNode, gesture in
|
contextAction: canEditCollections || canShare ? { [weak self] sourceNode, gesture in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1037,15 +1037,16 @@ private final class SheetContent: CombinedComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if case let .starGiftResell(giftToMatch, update, _) = self.mode {
|
if case let .starGiftResell(giftToMatch, update, _) = self.mode {
|
||||||
|
let resaleConfiguration = StarsSubscriptionConfiguration.with(appConfiguration: self.context.currentAppConfiguration.with { $0 })
|
||||||
if update {
|
if update {
|
||||||
if giftToMatch.resellForTonOnly {
|
if giftToMatch.resellForTonOnly {
|
||||||
if let resellStars = giftToMatch.resellAmounts?.first(where: { $0.currency == .ton }) {
|
if let resellStars = giftToMatch.resellAmounts?.first(where: { $0.currency == .ton }) {
|
||||||
self.amount = resellStars.amount
|
self.amount = StarsAmount(value: max(resellStars.amount.value, resaleConfiguration.starGiftResaleMinTonAmount), nanos: 0)
|
||||||
}
|
}
|
||||||
self.currency = .ton
|
self.currency = .ton
|
||||||
} else {
|
} else {
|
||||||
if let resellStars = giftToMatch.resellAmounts?.first(where: { $0.currency == .stars }) {
|
if let resellStars = giftToMatch.resellAmounts?.first(where: { $0.currency == .stars }) {
|
||||||
self.amount = resellStars.amount
|
self.amount = StarsAmount(value: max(resellStars.amount.value, resaleConfiguration.starGiftResaleMinStarsAmount), nanos: 0)
|
||||||
}
|
}
|
||||||
self.currency = .stars
|
self.currency = .stars
|
||||||
}
|
}
|
||||||
@ -1067,7 +1068,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if case let .generic(genericGift) = matchingGift, let minResaleStars = genericGift.availability?.minResaleStars {
|
if case let .generic(genericGift) = matchingGift, let minResaleStars = genericGift.availability?.minResaleStars {
|
||||||
self.amount = StarsAmount(value: minResaleStars, nanos: 0)
|
self.amount = StarsAmount(value: max(minResaleStars, resaleConfiguration.starGiftResaleMinStarsAmount), nanos: 0)
|
||||||
self.updated()
|
self.updated()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user