metatext/ViewModels/Sources/ViewModels/PreferencesViewModel.swift

33 lines
1 KiB
Swift
Raw Normal View History

2020-08-07 10:59:48 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
2020-08-31 18:57:02 +00:00
import ServiceLayer
2020-08-07 10:59:48 +00:00
2020-09-01 07:33:49 +00:00
public class PreferencesViewModel: ObservableObject {
public let handle: String
public let shouldShowNotificationTypePreferences: Bool
2020-08-07 10:59:48 +00:00
2020-08-08 23:08:47 +00:00
private let identityService: IdentityService
2020-08-07 10:59:48 +00:00
2020-08-08 23:08:47 +00:00
init(identityService: IdentityService) {
self.identityService = identityService
handle = identityService.identity.handle
shouldShowNotificationTypePreferences = identityService.identity.lastRegisteredDeviceToken != nil
2020-08-07 10:59:48 +00:00
}
}
2020-09-01 07:33:49 +00:00
public extension PreferencesViewModel {
2020-08-07 10:59:48 +00:00
func postingReadingPreferencesViewModel() -> PostingReadingPreferencesViewModel {
2020-08-08 23:08:47 +00:00
PostingReadingPreferencesViewModel(identityService: identityService)
2020-08-07 10:59:48 +00:00
}
2020-08-14 21:41:55 +00:00
func notificationTypesPreferencesViewModel() -> NotificationTypesPreferencesViewModel {
NotificationTypesPreferencesViewModel(identityService: identityService)
}
2020-08-29 10:26:26 +00:00
func filtersViewModel() -> FiltersViewModel {
FiltersViewModel(identityService: identityService)
}
2020-08-07 10:59:48 +00:00
}