Files
session-ios/SessionUIKit/Types/SessionProUIManagerType.swift
Morgan Pretty 7dfa2a77ae Merge remote-tracking branch 'upstream/dev' into feature/libsession-message-wrapping
# Conflicts:
#	Session.xcodeproj/project.pbxproj
#	Session/Conversations/ConversationVC+Interaction.swift
#	Session/Conversations/ConversationVC.swift
#	Session/Conversations/Settings/ThreadSettingsViewModel.swift
#	Session/Home/App Review/AppReviewPromptModel.swift
#	Session/Home/HomeViewModel.swift
#	Session/Media Viewing & Editing/MessageInfoScreen.swift
#	Session/Meta/AppDelegate.swift
#	Session/Settings/DeveloperSettings/DeveloperSettingsProViewModel.swift
#	Session/Settings/SettingsViewModel.swift
#	Session/Shared/BaseVC.swift
#	Session/Utilities/UIContextualAction+Utilities.swift
#	SessionMessagingKit/Database/Models/SessionThread.swift
#	SessionMessagingKit/SessionPro/SessionProPaymentScreenContent.swift
#	SessionMessagingKit/SessionPro/SessionProSettingsViewModel.swift
#	SessionMessagingKit/SessionPro/SessionProState.swift
#	SessionMessagingKit/Shared Models/SessionThreadViewModel.swift
#	SessionNotificationServiceExtension/NotificationServiceExtension.swift
#	SessionUIKit/Components/Input View/InputView.swift
#	SessionUIKit/Components/SwiftUI/ProCTAModal.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+CancelPlan.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+Models.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+Purchase.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+Renew.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+RequestRefund.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+UpdatePlan.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPlanUpdatedScreen.swift
#	SessionUIKit/Style Guide/Constants+Apple.swift
#	SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentApprovalViewController.swift
#	SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentTextToolbar.swift
2025-12-17 09:36:05 +11:00

99 lines
3.1 KiB
Swift

// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
import UIKit
public protocol SessionProUIManagerType: Actor {
nonisolated var characterLimit: Int { get }
nonisolated var pinnedConversationLimit: Int { get }
nonisolated var currentUserIsCurrentlyPro: Bool { get }
nonisolated var currentUserIsPro: AsyncStream<Bool> { get }
nonisolated func numberOfCharactersLeft(for content: String) -> Int
@discardableResult @MainActor func showSessionProCTAIfNeeded(
_ variant: ProCTAModal.Variant,
dismissType: Modal.DismissType,
onConfirm: (() -> Void)?,
onCancel: (() -> Void)?,
afterClosed: (() -> Void)?,
presenting: ((UIViewController) -> Void)?
) -> Bool
@MainActor func showSessionProBottomSheetIfNeeded(
afterClosed: (() -> Void)?,
presenting: ((UIViewController) -> Void)?
)
func purchasePro(productId: String) async throws
}
// MARK: - Convenience
public extension SessionProUIManagerType {
@discardableResult @MainActor func showSessionProCTAIfNeeded(
_ variant: ProCTAModal.Variant,
dismissType: Modal.DismissType = .recursive,
onConfirm: (() -> Void)? = nil,
onCancel: (() -> Void)? = nil,
afterClosed: (() -> Void)? = nil,
presenting: ((UIViewController) -> Void)? = nil
) -> Bool {
showSessionProCTAIfNeeded(
variant,
dismissType: dismissType,
onConfirm: onConfirm,
onCancel: onCancel,
afterClosed: afterClosed,
presenting: presenting
)
}
@MainActor func showSessionProBottomSheetIfNeeded(presenting: ((UIViewController) -> Void)?) {
showSessionProBottomSheetIfNeeded(
afterClosed: nil,
presenting: presenting
)
}
}
// MARK: - Noop
internal actor NoopSessionProUIManager: SessionProUIManagerType {
private let isPro: Bool
nonisolated public let characterLimit: Int
nonisolated public let pinnedConversationLimit: Int
nonisolated public let currentUserIsCurrentlyPro: Bool
nonisolated public var currentUserIsPro: AsyncStream<Bool> {
AsyncStream(unfolding: { return self.isPro })
}
init(
isPro: Bool = false,
characterLimit: Int = 2000,
pinnedConversationLimit: Int = 5
) {
self.isPro = isPro
self.characterLimit = characterLimit
self.pinnedConversationLimit = pinnedConversationLimit
self.currentUserIsCurrentlyPro = isPro
}
nonisolated public func numberOfCharactersLeft(for content: String) -> Int { 0 }
@discardableResult @MainActor func showSessionProCTAIfNeeded(
_ variant: ProCTAModal.Variant,
dismissType: Modal.DismissType,
afterClosed: (() -> Void)?,
presenting: ((UIViewController) -> Void)?
) -> Bool {
return false
}
@MainActor func showSessionProBottomSheetIfNeeded(
afterClosed: (() -> Void)?,
presenting: ((UIViewController) -> Void)?
) {}
public func purchasePro(productId: String) async throws {}
}