Files
element-x-ios/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/AnalyticsPromptScreenViewModel.swift
T
2026-05-27 17:11:42 +01:00

38 lines
1.3 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
// Copyright 2021-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Combine
import SwiftUI
typealias AnalyticsPromptScreenViewModelType = StateStoreViewModelV2<AnalyticsPromptScreenViewState, AnalyticsPromptScreenViewAction>
class AnalyticsPromptScreenViewModel: AnalyticsPromptScreenViewModelType, AnalyticsPromptScreenViewModelProtocol {
private var actionsSubject: PassthroughSubject<AnalyticsPromptScreenViewModelAction, Never> = .init()
var actions: AnyPublisher<AnalyticsPromptScreenViewModelAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
/// Initialize a view model with the specified prompt type and app display name.
init(termsURL: URL?) {
let promptStrings = AnalyticsPromptScreenStrings(termsURL: termsURL)
super.init(initialViewState: AnalyticsPromptScreenViewState(strings: promptStrings))
}
// MARK: - Public
override func process(viewAction: AnalyticsPromptScreenViewAction) {
switch viewAction {
case .enable:
actionsSubject.send(.enable)
case .disable:
actionsSubject.send(.disable)
}
}
}