Various improvements

This commit is contained in:
Ilya Laktyushin 2025-01-23 06:46:50 +04:00
parent 8cf054ef30
commit 0485aed646
17 changed files with 117 additions and 64 deletions

View File

@ -13474,6 +13474,7 @@ Sorry for the inconvenience.";
"Conversation.ContextMenuSendGiftTo" = "Send Gift to %@";
"Conversation.ContextMenuSendAnotherGift" = "Send Another Gift";
"Conversation.ContextMenuBuyGift" = "Buy Yourself a Gift";
"Gift.View.Status" = "Status";
"Gift.View.Status.NonUnique" = "Non-Unique";

View File

@ -1055,7 +1055,7 @@ public protocol SharedAccountContext: AnyObject {
func makeStarsGiftController(context: AccountContext, birthdays: [EnginePeer.Id: TelegramBirthday]?, completion: @escaping (([EnginePeer.Id]) -> Void)) -> ViewController
func makePremiumGiftController(context: AccountContext, source: PremiumGiftSource, completion: (([EnginePeer.Id]) -> Void)?) -> ViewController
func makeGiftOptionsController(context: AccountContext, peerId: EnginePeer.Id, premiumOptions: [CachedPremiumGiftOption], hasBirthday: Bool) -> ViewController
func makeGiftOptionsController(context: AccountContext, peerId: EnginePeer.Id, premiumOptions: [CachedPremiumGiftOption], hasBirthday: Bool, completion: (() -> Void)?) -> ViewController
func makePremiumPrivacyControllerController(context: AccountContext, subject: PremiumPrivacySubject, peerId: EnginePeer.Id) -> ViewController
func makePremiumBoostLevelsController(context: AccountContext, peerId: EnginePeer.Id, subject: BoostSubject, boostStatus: ChannelBoostStatus, myBoostStatus: MyBoostStatus, forceDark: Bool, openStats: (() -> Void)?) -> ViewController
@ -1101,8 +1101,8 @@ public protocol SharedAccountContext: AnyObject {
func makeStarsGiftScreen(context: AccountContext, message: EngineMessage) -> ViewController
func makeStarsGiveawayBoostScreen(context: AccountContext, peerId: EnginePeer.Id, boost: ChannelBoostersContext.State.Boost) -> ViewController
func makeStarsIntroScreen(context: AccountContext) -> ViewController
func makeGiftViewScreen(context: AccountContext, message: EngineMessage, shareStory: (() -> Void)?) -> ViewController
func makeGiftViewScreen(context: AccountContext, gift: StarGift.UniqueGift, shareStory: (() -> Void)?, dismissed: (() -> Void)?) -> ViewController
func makeGiftViewScreen(context: AccountContext, message: EngineMessage, shareStory: ((StarGift.UniqueGift) -> Void)?) -> ViewController
func makeGiftViewScreen(context: AccountContext, gift: StarGift.UniqueGift, shareStory: ((StarGift.UniqueGift) -> Void)?, dismissed: (() -> Void)?) -> ViewController
func makeGiftWearPreviewScreen(context: AccountContext, gift: StarGift.UniqueGift) -> ViewController
func makeStorySharingScreen(context: AccountContext, subject: StorySharingSubject, parentController: ViewController) -> ViewController

View File

@ -1742,7 +1742,7 @@ public final class ChatListNode: ListView {
|> filter { !$0.isEmpty }
|> deliverOnMainQueue).start(next: { giftOptions in
let premiumOptions = giftOptions.filter { $0.users == 1 }.map { CachedPremiumGiftOption(months: $0.months, currency: $0.currency, amount: $0.amount, botUrl: "", storeProductId: $0.storeProductId) }
let controller = self.context.sharedContext.makeGiftOptionsController(context: self.context, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: true)
let controller = self.context.sharedContext.makeGiftOptionsController(context: self.context, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: true, completion: nil)
controller.navigationPresentation = .modal
self.push?(controller)
})

View File

@ -971,12 +971,12 @@ private final class ProfileGiftsContextImpl {
}
func reload() {
gifts = []
dataState = .ready(canLoadMore: true, nextOffset: nil)
self.loadMore()
self.gifts = []
self.dataState = .ready(canLoadMore: true, nextOffset: nil)
self.loadMore(reload: true)
}
func loadMore() {
func loadMore(reload: Bool = false) {
let peerId = self.peerId
let accountPeerId = self.account.peerId
let network = self.account.network
@ -1012,8 +1012,10 @@ private final class ProfileGiftsContextImpl {
} else {
self.dataState = .loading
}
self.pushState()
if !reload {
self.pushState()
}
let signal: Signal<([ProfileGiftsContext.State.StarGift], Int32, String?, Bool?), NoError> = self.account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
@ -1077,7 +1079,7 @@ private final class ProfileGiftsContextImpl {
return
}
if isFiltered {
if initialNextOffset == nil {
if initialNextOffset == nil || reload {
self.filteredGifts = gifts
} else {
for gift in gifts {
@ -1089,7 +1091,7 @@ private final class ProfileGiftsContextImpl {
self.filteredCount = updatedCount
self.filteredDataState = .ready(canLoadMore: count != 0 && updatedCount > self.filteredGifts.count && nextOffset != nil, nextOffset: nextOffset)
} else {
if initialNextOffset == nil {
if initialNextOffset == nil || reload {
self.gifts = gifts
self.cacheDisposable.set(self.account.postbox.transaction { transaction in
if let entry = CodableEntry(CachedProfileGifts(gifts: gifts, count: count, notificationsEnabled: notificationsEnabled)) {

View File

@ -2789,7 +2789,7 @@ public final class EmojiPagerContentComponent: Component {
self.longPressItem = item.1
if #available(iOS 13.0, *) {
if #available(iOS 13.0, *), item.0.itemFile != nil {
self.continuousHaptic = try? ContinuousHaptic(duration: longPressDuration)
}

View File

@ -358,6 +358,27 @@ final class GiftSetupScreenComponent: Component {
}
let _ = (component.context.engine.payments.sendStarsPaymentForm(formId: inputData.form.id, source: source)
|> deliverOnMainQueue).start(next: { [weak self] result in
if let self, peerId.namespace == Namespaces.Peer.CloudChannel, let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController {
var controllers = navigationController.viewControllers
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) }
navigationController.setViewControllers(controllers, animated: true)
let tooltipController = UndoOverlayController(
presentationData: presentationData,
content: .sticker(
context: context,
file: starGift.file,
loop: true,
title: nil,
text: presentationData.strings.Gift_Send_Success(self.peerMap[peerId]?.compactDisplayTitle ?? "", presentationData.strings.Gift_Send_Success_Stars(Int32(starGift.price))).string,
undoText: nil,
customAction: nil
),
action: { _ in return true }
)
(navigationController.viewControllers.last as? ViewController)?.present(tooltipController, in: .current)
}
if let completion {
completion()
@ -369,26 +390,7 @@ final class GiftSetupScreenComponent: Component {
return
}
if peerId.namespace == Namespaces.Peer.CloudChannel {
var controllers = navigationController.viewControllers
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) }
navigationController.setViewControllers(controllers, animated: true)
let tooltipController = UndoOverlayController(
presentationData: presentationData,
content: .sticker(
context: context,
file: starGift.file,
loop: true,
title: nil,
text: presentationData.strings.Gift_Send_Success(self.peerMap[peerId]?.compactDisplayTitle ?? "", presentationData.strings.Gift_Send_Success_Stars(Int32(starGift.price))).string,
undoText: nil,
customAction: nil
),
action: { _ in return true }
)
(navigationController.viewControllers.last as? ViewController)?.present(tooltipController, in: .current)
} else {
if peerId.namespace != Namespaces.Peer.CloudChannel {
var controllers = navigationController.viewControllers
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) && !($0 is PeerInfoScreen) && !($0 is ContactSelectionController) }
var foundController = false

View File

@ -320,7 +320,7 @@ private final class GiftViewSheetContent: CombinedComponent {
self.updated(transition: .spring(duration: 0.4))
if let arguments = self.subject.arguments, let peerId = arguments.peerId, peerId.namespace == Namespaces.Peer.CloudChannel {
let _ = self.context.engine.peers.updatePeerEmojiStatus(peerId: peerId, fileId: nil, expirationDate: nil)
let _ = self.context.engine.peers.updatePeerEmojiStatus(peerId: peerId, fileId: nil, expirationDate: nil).startStandalone()
} else {
let _ = self.context.engine.accountData.setEmojiStatus(file: nil, expirationDate: nil).startStandalone()
}
@ -1101,8 +1101,10 @@ private final class GiftViewSheetContent: CombinedComponent {
return nil
}
},
tapAction: { _, _ in
component.openStarsIntro()
tapAction: { attributes, _ in
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
component.openStarsIntro()
}
}
),
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0 - 50.0, height: CGFloat.greatestFiniteMagnitude),
@ -1907,11 +1909,13 @@ private final class GiftViewSheetContent: CombinedComponent {
return nil
}
},
tapAction: { _, _ in
component.updateSavedToProfile(!savedToProfile)
Queue.mainQueue().after(0.6, {
component.cancel(false)
})
tapAction: { attributes, _ in
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
component.updateSavedToProfile(!savedToProfile)
Queue.mainQueue().after(0.6, {
component.cancel(false)
})
}
}
),
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0 - 60.0, height: CGFloat.greatestFiniteMagnitude),
@ -2430,7 +2434,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
convertToStars: (() -> Void)? = nil,
transferGift: ((Bool, EnginePeer.Id) -> Void)? = nil,
upgradeGift: ((Int64?, Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError>)? = nil,
shareStory: (() -> Void)? = nil
shareStory: ((StarGift.UniqueGift) -> Void)? = nil
) {
self.context = context
self.subject = subject
@ -2687,7 +2691,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
|> filter { !$0.isEmpty }
|> deliverOnMainQueue).start(next: { giftOptions in
let premiumOptions = giftOptions.filter { $0.users == 1 }.map { CachedPremiumGiftOption(months: $0.months, currency: $0.currency, amount: $0.amount, botUrl: "", storeProductId: $0.storeProductId) }
let controller = context.sharedContext.makeGiftOptionsController(context: context, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: false)
let controller = context.sharedContext.makeGiftOptionsController(context: context, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: false, completion: nil)
self.push(controller)
})
}
@ -2766,12 +2770,19 @@ public class GiftViewScreen: ViewControllerComponentContainer {
guard let self, let arguments = self.subject.arguments, case let .unique(gift) = arguments.gift else {
return
}
var shareStoryImpl: (() -> Void)?
if let shareStory {
shareStoryImpl = {
shareStory(gift)
}
}
let link = "https://t.me/nft/\(gift.slug)"
let shareController = context.sharedContext.makeShareController(
context: context,
subject: .url(link),
forceExternal: false,
shareStory: shareStory,
shareStory: shareStoryImpl,
enqueued: { peerIds, _ in
let _ = (context.engine.data.get(
EngineDataList(

View File

@ -114,6 +114,7 @@ public final class PeerInfoCoverComponent: Component {
public let avatarScale: CGFloat
public let defaultHeight: CGFloat
public let gradientOnTop: Bool
public let gradientCenter: CGPoint
public let avatarTransitionFraction: CGFloat
public let patternTransitionFraction: CGFloat
@ -126,6 +127,7 @@ public final class PeerInfoCoverComponent: Component {
avatarScale: CGFloat,
defaultHeight: CGFloat,
gradientOnTop: Bool = false,
gradientCenter: CGPoint = CGPoint(x: 0.5, y: 0.5),
avatarTransitionFraction: CGFloat,
patternTransitionFraction: CGFloat
) {
@ -137,6 +139,7 @@ public final class PeerInfoCoverComponent: Component {
self.avatarScale = avatarScale
self.defaultHeight = defaultHeight
self.gradientOnTop = gradientOnTop
self.gradientCenter = gradientCenter
self.avatarTransitionFraction = avatarTransitionFraction
self.patternTransitionFraction = patternTransitionFraction
}
@ -166,6 +169,9 @@ public final class PeerInfoCoverComponent: Component {
if lhs.gradientOnTop != rhs.gradientOnTop {
return false
}
if lhs.gradientCenter != rhs.gradientCenter {
return false
}
if lhs.avatarTransitionFraction != rhs.avatarTransitionFraction {
return false
}
@ -412,7 +418,7 @@ public final class PeerInfoCoverComponent: Component {
} else if case .status = component.subject {
gradientWidth = availableSize.width
self.backgroundView.backgroundColor = secondaryBackgroundColor
self.backgroundGradientLayer.startPoint = CGPoint(x: 0.5, y: component.avatarCenter.y / gradientHeight)
self.backgroundGradientLayer.startPoint = component.gradientCenter
self.backgroundGradientLayer.endPoint = CGPoint(x: 1.0, y: 1.0)
self.backgroundGradientLayer.type = .radial
self.backgroundGradientLayer.colors = [backgroundColor.cgColor, secondaryBackgroundColor.cgColor]

View File

@ -88,7 +88,20 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode {
var colors = AvatarNode.Colors(theme: theme)
let regularNavigationContentsSecondaryColor: UIColor
if let profileColor = peer?.profileColor {
if case let .starGift(_, _, _, _, _, innerColorValue, outerColorValue, _, _) = peer?.emojiStatus?.content {
let innerColor = UIColor(rgb: UInt32(bitPattern: innerColorValue))
let outerColor = UIColor(rgb: UInt32(bitPattern: outerColorValue))
regularNavigationContentsSecondaryColor = UIColor(white: 1.0, alpha: 0.6).blitOver(innerColor.withMultiplied(hue: 1.0, saturation: 2.2, brightness: 1.5), alpha: 1.0)
let baseBackgroundColor = UIColor(white: 1.0, alpha: 0.75)
let topColor = baseBackgroundColor.blendOver(background: innerColor.mixedWith(outerColor, alpha: 0.1)).withMultiplied(hue: 1.0, saturation: 1.2, brightness: 1.5)
let bottomColor = baseBackgroundColor.blendOver(background: outerColor).withMultiplied(hue: 1.0, saturation: 1.2, brightness: 1.5)
colors.unseenColors = [topColor, bottomColor]
colors.unseenCloseFriendsColors = colors.unseenColors
colors.seenColors = colors.unseenColors
} else if let profileColor = peer?.profileColor {
let backgroundColors = self.context.peerNameColors.getProfile(profileColor, dark: theme.overallDarkAppearance)
regularNavigationContentsSecondaryColor = UIColor(white: 1.0, alpha: 0.6).blitOver(backgroundColors.main.withMultiplied(hue: 1.0, saturation: 2.2, brightness: 1.5), alpha: 1.0)

View File

@ -620,6 +620,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
let collapsedHeaderContentButtonForegroundColor = presentationData.theme.list.itemAccentColor
let expandedAvatarContentButtonForegroundColor: UIColor = .white
var hasCoverColor = false
let regularNavigationContentsSecondaryColor: UIColor
if let emojiStatus = peer?.emojiStatus, case let .starGift(_, _, _, _, _, innerColor, outerColor, _, _) = emojiStatus.content {
let mainColor = UIColor(rgb: UInt32(bitPattern: innerColor))
@ -632,8 +633,10 @@ final class PeerInfoHeaderNode: ASDisplayNode {
} else {
baseButtonBackgroundColor = UIColor(white: 1.0, alpha: 0.25)
}
regularContentButtonBackgroundColor = baseButtonBackgroundColor.blendOver(background: mainColor)
regularContentButtonBackgroundColor = baseButtonBackgroundColor.blendOver(background: secondaryColor.mixedWith(mainColor, alpha: 0.1))
regularHeaderButtonBackgroundColor = baseButtonBackgroundColor.blendOver(background: secondaryColor.mixedWith(mainColor, alpha: 0.1))
hasCoverColor = true
} else if let profileColor = peer?.profileColor {
let backgroundColors = self.context.peerNameColors.getProfile(profileColor, dark: presentationData.theme.overallDarkAppearance)
regularNavigationContentsSecondaryColor = UIColor(white: 1.0, alpha: 0.6).blitOver(backgroundColors.main.withMultiplied(hue: 1.0, saturation: 2.2, brightness: 1.5), alpha: 1.0)
@ -646,12 +649,14 @@ final class PeerInfoHeaderNode: ASDisplayNode {
}
regularContentButtonBackgroundColor = baseButtonBackgroundColor.blendOver(background: backgroundColors.main)
regularHeaderButtonBackgroundColor = baseButtonBackgroundColor.blendOver(background: (backgroundColors.secondary ?? backgroundColors.main).mixedWith(backgroundColors.main, alpha: 0.1))
hasCoverColor = true
} else {
regularNavigationContentsSecondaryColor = presentationData.theme.list.itemSecondaryTextColor
regularContentButtonBackgroundColor = presentationData.theme.list.itemBlocksBackgroundColor
regularHeaderButtonBackgroundColor = .clear
}
self.contentButtonBackgroundColor = regularContentButtonBackgroundColor
self.contentButtonBackgroundColor = regularNavigationContentsSecondaryColor.mixedWith(regularContentButtonBackgroundColor, alpha: 0.5)
let collapsedHeaderNavigationContentsSecondaryColor = presentationData.theme.list.itemSecondaryTextColor
let expandedAvatarNavigationContentsSecondaryColor: UIColor = .white
@ -793,7 +798,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
navigationContentsPrimaryColor = regularNavigationContentsPrimaryColor.mixedWith(collapsedHeaderNavigationContentsPrimaryColor, alpha: effectiveTransitionFraction)
navigationContentsSecondaryColor = regularNavigationContentsSecondaryColor.mixedWith(collapsedHeaderNavigationContentsSecondaryColor, alpha: effectiveTransitionFraction)
if peer?.profileColor != nil {
if hasCoverColor {
navigationContentsCanBeExpanded = effectiveTransitionFraction == 1.0
} else {
navigationContentsCanBeExpanded = true
@ -2263,6 +2268,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
let backgroundCoverSubject: PeerInfoCoverComponent.Subject?
var backgroundCoverAnimateIn = false
var backgroundDefaultHeight: CGFloat = 254.0
if let status = peer?.emojiStatus, case .starGift = status.content {
backgroundCoverSubject = .status(status)
if !self.didSetupBackgroundCover {
@ -2271,6 +2277,9 @@ final class PeerInfoHeaderNode: ASDisplayNode {
}
self.didSetupBackgroundCover = true
}
if !buttonKeys.isEmpty {
backgroundDefaultHeight = 327.0
}
} else if let peer {
backgroundCoverSubject = .peer(EnginePeer(peer))
} else {
@ -2286,7 +2295,8 @@ final class PeerInfoHeaderNode: ASDisplayNode {
isDark: presentationData.theme.overallDarkAppearance,
avatarCenter: apparentAvatarFrame.center,
avatarScale: avatarScale,
defaultHeight: 254.0,
defaultHeight: backgroundDefaultHeight,
gradientCenter: CGPoint(x: 0.5, y: buttonKeys.isEmpty ? 0.5 : 0.45),
avatarTransitionFraction: max(0.0, min(1.0, titleCollapseFraction + transitionFraction * 2.0)),
patternTransitionFraction: buttonsTransitionFraction * backgroundTransitionFraction
)),

View File

@ -9821,7 +9821,13 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
context: self.context,
peerId: self.peerId,
premiumOptions: premiumOptions,
hasBirthday: false
hasBirthday: false,
completion: { [weak self] in
guard let self, let profileGiftsContext = self.data?.profileGiftsContext else {
return
}
profileGiftsContext.reload()
}
)
self.controller?.push(controller)
}

View File

@ -265,8 +265,8 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
}
return self.profileGifts.upgradeStarGift(formId: formId, reference: reference, keepOriginalInfo: keepOriginalInfo)
},
shareStory: { [weak self] in
guard let self, case let .unique(uniqueGift) = product.gift, let parentController = self.parentController else {
shareStory: { [weak self] uniqueGift in
guard let self, let parentController = self.parentController else {
return
}
Queue.mainQueue().after(0.15) {
@ -650,7 +650,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
self.chatControllerInteraction.navigationController()?.pushViewController(controller)
})
} else {
let controller = self.context.sharedContext.makeGiftOptionsController(context: self.context, peerId: self.peerId, premiumOptions: [], hasBirthday: false)
let controller = self.context.sharedContext.makeGiftOptionsController(context: self.context, peerId: self.peerId, premiumOptions: [], hasBirthday: false, completion: nil)
self.chatControllerInteraction.navigationController()?.pushViewController(controller)
}
}

View File

@ -1829,7 +1829,7 @@ public class StarsTransactionScreen: ViewControllerComponentContainer {
|> filter { !$0.isEmpty }
|> deliverOnMainQueue).start(next: { giftOptions in
let premiumOptions = giftOptions.filter { $0.users == 1 }.map { CachedPremiumGiftOption(months: $0.months, currency: $0.currency, amount: $0.amount, botUrl: "", storeProductId: $0.storeProductId) }
let controller = context.sharedContext.makeGiftOptionsController(context: context, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: false)
let controller = context.sharedContext.makeGiftOptionsController(context: context, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: false, completion: nil)
self.push(controller)
})
}

View File

@ -4339,7 +4339,7 @@ extension ChatControllerImpl {
let _ = ApplicationSpecificNotice.incrementDismissedPremiumGiftSuggestion(accountManager: self.context.sharedContext.accountManager, peerId: peerId, timestamp: Int32(Date().timeIntervalSince1970)).startStandalone()
}
} else {
let controller = self.context.sharedContext.makeGiftOptionsController(context: self.context, peerId: peerId, premiumOptions: [], hasBirthday: false)
let controller = self.context.sharedContext.makeGiftOptionsController(context: self.context, peerId: peerId, premiumOptions: [], hasBirthday: false, completion: nil)
self.push(controller)
}
}, openPremiumRequiredForMessaging: { [weak self] in

View File

@ -1198,8 +1198,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
strongSelf.push(controller)
return true
case .starGift, .starGiftUnique:
let controller = strongSelf.context.sharedContext.makeGiftViewScreen(context: strongSelf.context, message: EngineMessage(message), shareStory: { [weak self] in
if let self, case let .starGiftUnique(gift, _, _, _, _, _, _, _, _, _) = action.action, case let .unique(uniqueGift) = gift {
let controller = strongSelf.context.sharedContext.makeGiftViewScreen(context: strongSelf.context, message: EngineMessage(message), shareStory: { [weak self] uniqueGift in
if let self {
Queue.mainQueue().after(0.15) {
let controller = self.context.sharedContext.makeStorySharingScreen(context: self.context, subject: .gift(uniqueGift), parentController: self)
self.push(controller)
@ -4577,7 +4577,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return
}
let premiumOptions = giftOptions.filter { $0.users == 1 }.map { CachedPremiumGiftOption(months: $0.months, currency: $0.currency, amount: $0.amount, botUrl: "", storeProductId: $0.storeProductId) }
let controller = self.context.sharedContext.makeGiftOptionsController(context: context, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: false)
let controller = self.context.sharedContext.makeGiftOptionsController(context: context, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: false, completion: nil)
self.push(controller)
})
}, requestMessageUpdate: { [weak self] id, scroll in

View File

@ -1131,7 +1131,9 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
}
}
}
if isIncoming {
if message.id.peerId == context.account.peerId {
sendGiftTitle = chatPresentationInterfaceState.strings.Conversation_ContextMenuBuyGift
} else if isIncoming {
let peerName = message.peers[message.id.peerId].flatMap(EnginePeer.init)?.compactDisplayTitle ?? ""
sendGiftTitle = chatPresentationInterfaceState.strings.Conversation_ContextMenuSendGiftTo(peerName).string
} else {

View File

@ -2648,11 +2648,11 @@ public final class SharedAccountContextImpl: SharedAccountContext {
return controller
}
public func makeGiftOptionsController(context: AccountContext, peerId: EnginePeer.Id, premiumOptions: [CachedPremiumGiftOption], hasBirthday: Bool) -> ViewController {
public func makeGiftOptionsController(context: AccountContext, peerId: EnginePeer.Id, premiumOptions: [CachedPremiumGiftOption], hasBirthday: Bool, completion: (() -> Void)?) -> ViewController {
guard let starsContext = context.starsContext else {
fatalError()
}
let controller = GiftOptionsScreen(context: context, starsContext: starsContext, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: hasBirthday)
let controller = GiftOptionsScreen(context: context, starsContext: starsContext, peerId: peerId, premiumOptions: premiumOptions, hasBirthday: hasBirthday, completion: completion)
controller.navigationPresentation = .modal
return controller
}
@ -3054,11 +3054,11 @@ public final class SharedAccountContextImpl: SharedAccountContext {
return StarsIntroScreen(context: context)
}
public func makeGiftViewScreen(context: AccountContext, message: EngineMessage, shareStory: (() -> Void)?) -> ViewController {
public func makeGiftViewScreen(context: AccountContext, message: EngineMessage, shareStory: ((StarGift.UniqueGift) -> Void)?) -> ViewController {
return GiftViewScreen(context: context, subject: .message(message), shareStory: shareStory)
}
public func makeGiftViewScreen(context: AccountContext, gift: StarGift.UniqueGift, shareStory: (() -> Void)?, dismissed: (() -> Void)?) -> ViewController {
public func makeGiftViewScreen(context: AccountContext, gift: StarGift.UniqueGift, shareStory: ((StarGift.UniqueGift) -> Void)?, dismissed: (() -> Void)?) -> ViewController {
let controller = GiftViewScreen(context: context, subject: .uniqueGift(gift), shareStory: shareStory)
controller.disposed = {
dismissed?()