mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add gift screen presentation source
This commit is contained in:
parent
6795603c4e
commit
c035b7d376
@ -302,6 +302,7 @@ public enum ResolvedUrl {
|
|||||||
case story(peerId: PeerId, id: Int32)
|
case story(peerId: PeerId, id: Int32)
|
||||||
case boost(peerId: PeerId, status: ChannelBoostStatus?, myBoostStatus: MyBoostStatus?)
|
case boost(peerId: PeerId, status: ChannelBoostStatus?, myBoostStatus: MyBoostStatus?)
|
||||||
case premiumGiftCode(slug: String)
|
case premiumGiftCode(slug: String)
|
||||||
|
case premiumMultiGift(reference: String?)
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ResolveUrlResult {
|
public enum ResolveUrlResult {
|
||||||
@ -941,7 +942,7 @@ public protocol SharedAccountContext: AnyObject {
|
|||||||
func makePremiumIntroController(context: AccountContext, source: PremiumIntroSource, forceDark: Bool, dismissed: (() -> Void)?) -> ViewController
|
func makePremiumIntroController(context: AccountContext, source: PremiumIntroSource, forceDark: Bool, dismissed: (() -> Void)?) -> ViewController
|
||||||
func makePremiumDemoController(context: AccountContext, subject: PremiumDemoSubject, action: @escaping () -> Void) -> ViewController
|
func makePremiumDemoController(context: AccountContext, subject: PremiumDemoSubject, action: @escaping () -> Void) -> ViewController
|
||||||
func makePremiumLimitController(context: AccountContext, subject: PremiumLimitSubject, count: Int32, forceDark: Bool, cancel: @escaping () -> Void, action: @escaping () -> Bool) -> ViewController
|
func makePremiumLimitController(context: AccountContext, subject: PremiumLimitSubject, count: Int32, forceDark: Bool, cancel: @escaping () -> Void, action: @escaping () -> Bool) -> ViewController
|
||||||
func makePremiumGiftController(context: AccountContext) -> ViewController
|
func makePremiumGiftController(context: AccountContext, source: PremiumGiftSource) -> ViewController
|
||||||
|
|
||||||
func makeStickerPackScreen(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, mainStickerPack: StickerPackReference, stickerPacks: [StickerPackReference], loadedStickerPacks: [LoadedStickerPack], parentNavigationController: NavigationController?, sendSticker: ((FileMediaReference, UIView, CGRect) -> Bool)?) -> ViewController
|
func makeStickerPackScreen(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, mainStickerPack: StickerPackReference, stickerPacks: [StickerPackReference], loadedStickerPacks: [LoadedStickerPack], parentNavigationController: NavigationController?, sendSticker: ((FileMediaReference, UIView, CGRect) -> Bool)?) -> ViewController
|
||||||
|
|
||||||
@ -1008,6 +1009,15 @@ public enum PremiumIntroSource {
|
|||||||
case wallpapers
|
case wallpapers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PremiumGiftSource: Equatable {
|
||||||
|
case profile
|
||||||
|
case attachMenu
|
||||||
|
case settings
|
||||||
|
case chatList
|
||||||
|
case channelBoost
|
||||||
|
case deeplink(String?)
|
||||||
|
}
|
||||||
|
|
||||||
public enum PremiumDemoSubject {
|
public enum PremiumDemoSubject {
|
||||||
case doubleLimits
|
case doubleLimits
|
||||||
case moreUpload
|
case moreUpload
|
||||||
|
@ -1612,7 +1612,7 @@ public final class ChatListNode: ListView {
|
|||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let controller = self.context.sharedContext.makePremiumGiftController(context: self.context)
|
let controller = self.context.sharedContext.makePremiumGiftController(context: self.context, source: .chatList)
|
||||||
self.push?(controller)
|
self.push?(controller)
|
||||||
}, openActiveSessions: { [weak self] in
|
}, openActiveSessions: { [weak self] in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
|
@ -236,7 +236,7 @@ public func PremiumBoostScreen(
|
|||||||
actions: [
|
actions: [
|
||||||
TextAlertAction(type: .defaultAction, title: presentationData.strings.ChannelBoost_MoreBoosts_Gift, action: {
|
TextAlertAction(type: .defaultAction, title: presentationData.strings.ChannelBoost_MoreBoosts_Gift, action: {
|
||||||
dismissImpl?()
|
dismissImpl?()
|
||||||
let controller = context.sharedContext.makePremiumGiftController(context: context)
|
let controller = context.sharedContext.makePremiumGiftController(context: context, source: .channelBoost)
|
||||||
pushController(controller)
|
pushController(controller)
|
||||||
}),
|
}),
|
||||||
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Close, action: {})
|
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Close, action: {})
|
||||||
|
@ -21,11 +21,7 @@ import TextFormat
|
|||||||
import UniversalMediaPlayer
|
import UniversalMediaPlayer
|
||||||
import InstantPageCache
|
import InstantPageCache
|
||||||
|
|
||||||
public enum PremiumGiftSource: Equatable {
|
extension PremiumGiftSource {
|
||||||
case profile
|
|
||||||
case attachMenu
|
|
||||||
case settings
|
|
||||||
|
|
||||||
var identifier: String? {
|
var identifier: String? {
|
||||||
switch self {
|
switch self {
|
||||||
case .profile:
|
case .profile:
|
||||||
@ -34,6 +30,16 @@ public enum PremiumGiftSource: Equatable {
|
|||||||
return "attach"
|
return "attach"
|
||||||
case .settings:
|
case .settings:
|
||||||
return "settings"
|
return "settings"
|
||||||
|
case .chatList:
|
||||||
|
return "chats"
|
||||||
|
case .channelBoost:
|
||||||
|
return "channel_boost"
|
||||||
|
case let .deeplink(reference):
|
||||||
|
if let reference = reference {
|
||||||
|
return "deeplink_\(reference)"
|
||||||
|
} else {
|
||||||
|
return "deeplink"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -880,7 +880,7 @@ public class ReplaceBoostScreen: ViewController {
|
|||||||
}
|
}
|
||||||
let navigationController = self.navigationController
|
let navigationController = self.navigationController
|
||||||
self.dismiss(animated: true, completion: {
|
self.dismiss(animated: true, completion: {
|
||||||
let giftController = context.sharedContext.makePremiumGiftController(context: context)
|
let giftController = context.sharedContext.makePremiumGiftController(context: context, source: .channelBoost)
|
||||||
navigationController?.pushViewController(giftController, animated: true)
|
navigationController?.pushViewController(giftController, animated: true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1090,6 +1090,8 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||||||
break
|
break
|
||||||
case .premiumGiftCode:
|
case .premiumGiftCode:
|
||||||
break
|
break
|
||||||
|
case .premiumMultiGift:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
@ -8666,9 +8666,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
case .language:
|
case .language:
|
||||||
push(LocalizationListController(context: self.context))
|
push(LocalizationListController(context: self.context))
|
||||||
case .premium:
|
case .premium:
|
||||||
self.controller?.push(PremiumIntroScreen(context: self.context, modal: false, source: .settings))
|
let controller = self.context.sharedContext.makePremiumIntroController(context: self.context, source: .settings, forceDark: false, dismissed: nil)
|
||||||
|
self.controller?.push(controller)
|
||||||
case .premiumGift:
|
case .premiumGift:
|
||||||
let controller = self.context.sharedContext.makePremiumGiftController(context: self.context)
|
let controller = self.context.sharedContext.makePremiumGiftController(context: self.context, source: .settings)
|
||||||
self.controller?.push(controller)
|
self.controller?.push(controller)
|
||||||
case .stickers:
|
case .stickers:
|
||||||
if let settings = self.data?.globalSettings {
|
if let settings = self.data?.globalSettings {
|
||||||
|
@ -400,7 +400,7 @@ public final class StoryFooterPanelComponent: Component {
|
|||||||
|
|
||||||
var displayViewLists = false
|
var displayViewLists = false
|
||||||
if case let .channel(channel) = component.peer, channel.flags.contains(.isCreator) || component.canViewChannelStats {
|
if case let .channel(channel) = component.peer, channel.flags.contains(.isCreator) || component.canViewChannelStats {
|
||||||
displayViewLists = reactionCount != 0 || forwardCount != 0
|
displayViewLists = true
|
||||||
} else {
|
} else {
|
||||||
displayViewLists = viewCount != 0 && !component.isChannel
|
displayViewLists = viewCount != 0 && !component.isChannel
|
||||||
}
|
}
|
||||||
|
@ -581,7 +581,13 @@ func openResolvedUrlImpl(
|
|||||||
}
|
}
|
||||||
case let .premiumOffer(reference):
|
case let .premiumOffer(reference):
|
||||||
dismissInput()
|
dismissInput()
|
||||||
let controller = PremiumIntroScreen(context: context, source: .deeplink(reference))
|
let controller = context.sharedContext.makePremiumIntroController(context: context, source: .deeplink(reference), forceDark: false, dismissed: nil)
|
||||||
|
if let navigationController = navigationController {
|
||||||
|
navigationController.pushViewController(controller, animated: true)
|
||||||
|
}
|
||||||
|
case let .premiumMultiGift(reference):
|
||||||
|
dismissInput()
|
||||||
|
let controller = context.sharedContext.makePremiumGiftController(context: context, source: .deeplink(reference))
|
||||||
if let navigationController = navigationController {
|
if let navigationController = navigationController {
|
||||||
navigationController.pushViewController(controller, animated: true)
|
navigationController.pushViewController(controller, animated: true)
|
||||||
}
|
}
|
||||||
|
@ -842,6 +842,20 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleResolvedUrl(.premiumOffer(reference: reference))
|
handleResolvedUrl(.premiumOffer(reference: reference))
|
||||||
|
} else if parsedUrl.host == "premium_multigift" {
|
||||||
|
var reference: String?
|
||||||
|
if let components = URLComponents(string: "/?" + query) {
|
||||||
|
if let queryItems = components.queryItems {
|
||||||
|
for queryItem in queryItems {
|
||||||
|
if let value = queryItem.value {
|
||||||
|
if queryItem.name == "ref" {
|
||||||
|
reference = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handleResolvedUrl(.premiumMultiGift(reference: reference))
|
||||||
} else if parsedUrl.host == "addlist" {
|
} else if parsedUrl.host == "addlist" {
|
||||||
if let components = URLComponents(string: "/?" + query) {
|
if let components = URLComponents(string: "/?" + query) {
|
||||||
var slug: String?
|
var slug: String?
|
||||||
|
@ -1805,10 +1805,12 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func makePremiumIntroController(context: AccountContext, source: PremiumIntroSource, forceDark: Bool, dismissed: (() -> Void)?) -> ViewController {
|
public func makePremiumIntroController(context: AccountContext, source: PremiumIntroSource, forceDark: Bool, dismissed: (() -> Void)?) -> ViewController {
|
||||||
|
var modal = true
|
||||||
let mappedSource: PremiumSource
|
let mappedSource: PremiumSource
|
||||||
switch source {
|
switch source {
|
||||||
case .settings:
|
case .settings:
|
||||||
mappedSource = .settings
|
mappedSource = .settings
|
||||||
|
modal = false
|
||||||
case .stickers:
|
case .stickers:
|
||||||
mappedSource = .stickers
|
mappedSource = .stickers
|
||||||
case .reactions:
|
case .reactions:
|
||||||
@ -1872,7 +1874,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
case .wallpapers:
|
case .wallpapers:
|
||||||
mappedSource = .wallpapers
|
mappedSource = .wallpapers
|
||||||
}
|
}
|
||||||
let controller = PremiumIntroScreen(context: context, source: mappedSource, forceDark: forceDark)
|
let controller = PremiumIntroScreen(context: context, modal: modal, source: mappedSource, forceDark: forceDark)
|
||||||
controller.wasDismissed = dismissed
|
controller.wasDismissed = dismissed
|
||||||
return controller
|
return controller
|
||||||
}
|
}
|
||||||
@ -1949,16 +1951,16 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
return PremiumLimitScreen(context: context, subject: mappedSubject, count: count, forceDark: forceDark, cancel: cancel, action: action)
|
return PremiumLimitScreen(context: context, subject: mappedSubject, count: count, forceDark: forceDark, cancel: cancel, action: action)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func makePremiumGiftController(context: AccountContext) -> ViewController {
|
public func makePremiumGiftController(context: AccountContext, source: PremiumGiftSource) -> ViewController {
|
||||||
let options = Promise<[PremiumGiftCodeOption]>()
|
let options = Promise<[PremiumGiftCodeOption]>()
|
||||||
options.set(context.engine.payments.premiumGiftCodeOptions(peerId: nil))
|
options.set(context.engine.payments.premiumGiftCodeOptions(peerId: nil))
|
||||||
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
|
||||||
let limit: Int32 = 10
|
let limit: Int32 = 10
|
||||||
var reachedLimitImpl: ((Int32) -> Void)?
|
var reachedLimitImpl: ((Int32) -> Void)?
|
||||||
let controller = context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams(context: context, mode: .premiumGifting, options: [], isPeerEnabled: { peer in
|
let controller = context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams(context: context, mode: .premiumGifting, options: [], isPeerEnabled: { peer in
|
||||||
if case let .user(user) = peer, user.botInfo == nil {
|
if case let .user(user) = peer, user.botInfo == nil && !peer.isService && !user.flags.contains(.isSupport) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -1990,11 +1992,14 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
guard !peerIds.isEmpty else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let mappedOptions = options.filter { $0.users == 1 }.map { CachedPremiumGiftOption(months: $0.months, currency: $0.currency, amount: $0.amount, botUrl: "", storeProductId: $0.storeProductId) }
|
let mappedOptions = options.filter { $0.users == 1 }.map { CachedPremiumGiftOption(months: $0.months, currency: $0.currency, amount: $0.amount, botUrl: "", storeProductId: $0.storeProductId) }
|
||||||
var pushImpl: ((ViewController) -> Void)?
|
var pushImpl: ((ViewController) -> Void)?
|
||||||
var filterImpl: (() -> Void)?
|
var filterImpl: (() -> Void)?
|
||||||
let giftController = PremiumGiftScreen(context: context, peerIds: peerIds, options: mappedOptions, source: .settings, pushController: { c in
|
let giftController = PremiumGiftScreen(context: context, peerIds: peerIds, options: mappedOptions, source: source, pushController: { c in
|
||||||
pushImpl?(c)
|
pushImpl?(c)
|
||||||
}, completion: {
|
}, completion: {
|
||||||
filterImpl?()
|
filterImpl?()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user