Add dependency management, AvatarViewModel and placeholder rendering now in AvatarImage.

This commit is contained in:
David Langley
2021-08-17 10:19:41 +01:00
parent 31b4da8502
commit e09138b572
17 changed files with 103 additions and 72 deletions
@@ -18,8 +18,8 @@ import Foundation
import SwiftUI
/**
UIHostingController that applies some level-app specific configuration
(E.g. vectorContent modifier and themeing to the NavigationController container.
UIHostingController that applies some app-level specific configuration
(E.g. `vectorContent` modifier and themeing to the NavigationController container.
*/
@available(iOS 14.0, *)
class VectorHostingController: UIHostingController<AnyView> {
@@ -27,11 +27,9 @@ class VectorHostingController: UIHostingController<AnyView> {
// MARK: Private
private var theme: Theme
private var dependencyContainer = DependencyContainer()
init<Content>(rootView: Content) where Content: View {
self.theme = ThemeService.shared().theme
super.init(rootView: AnyView(rootView.vectorContent()))
}
@@ -47,10 +45,6 @@ class VectorHostingController: UIHostingController<AnyView> {
self.update(theme: self.theme)
}
func add<T>(dependency: T) {
dependencyContainer.register(dependency: dependency)
}
private func registerThemeServiceDidChangeThemeNotification() {
NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .themeServiceDidChangeTheme, object: nil)
}