metatext/iOS/View Models/SecondaryNavigationViewModel.swift

25 lines
775 B
Swift
Raw Normal View History

2020-07-31 21:40:57 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
2020-08-07 03:57:52 +00:00
class SecondaryNavigationViewModel: ObservableObject {
2020-08-04 20:26:09 +00:00
@Published private(set) var identity: Identity
2020-08-07 22:18:54 +00:00
private let identityRepository: IdentityRepository
2020-07-31 21:40:57 +00:00
2020-08-07 22:18:54 +00:00
init(identityRepository: IdentityRepository) {
self.identityRepository = identityRepository
identity = identityRepository.identity
identityRepository.$identity.dropFirst().assign(to: &$identity)
2020-07-31 21:40:57 +00:00
}
}
2020-08-04 20:26:09 +00:00
2020-08-07 03:57:52 +00:00
extension SecondaryNavigationViewModel {
2020-08-04 20:26:09 +00:00
func identitiesViewModel() -> IdentitiesViewModel {
2020-08-07 22:18:54 +00:00
IdentitiesViewModel(identityRepository: identityRepository)
2020-08-04 20:26:09 +00:00
}
2020-08-07 10:14:14 +00:00
2020-08-07 10:59:48 +00:00
func preferencesViewModel() -> PreferencesViewModel {
2020-08-07 22:18:54 +00:00
PreferencesViewModel(identityRepository: identityRepository)
2020-08-07 10:14:14 +00:00
}
2020-08-04 20:26:09 +00:00
}