mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
Inject AvatarViewMode as EnvironmentObject
This commit is contained in:
@@ -20,10 +20,14 @@ import Foundation
|
||||
|
||||
/// Simple ViewModel that supports loading an avatar image
|
||||
class AvatarViewModel: InjectableObject, ObservableObject {
|
||||
@Inject var avatarService: AvatarServiceProtocol
|
||||
private let avatarService: AvatarServiceProtocol
|
||||
|
||||
@Published private(set) var viewState = AvatarViewState.empty
|
||||
|
||||
init(avatarService: AvatarServiceProtocol) {
|
||||
self.avatarService = avatarService
|
||||
}
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
/// Load an avatar
|
||||
@@ -58,3 +62,9 @@ class AvatarViewModel: InjectableObject, ObservableObject {
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
}
|
||||
|
||||
extension AvatarViewModel {
|
||||
static func withMockedServices() -> AvatarViewModel {
|
||||
.init(avatarService: MockAvatarService.example)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user