Update environment object setup and view model context wrapping to restore SwiftUI UI tests

This commit is contained in:
aringenbach
2023-03-23 15:45:31 +01:00
parent b26e0ccea3
commit 9ea625e470
8 changed files with 30 additions and 26 deletions
@@ -30,16 +30,12 @@ struct UserSuggestionCoordinatorParameters {
let room: MXRoom
}
/// Defines a shared context providing the ability to use a single `UserSuggestionViewModel` for multiple
/// `UserSuggestionList` e.g. the list component can then be displayed seemlessly in both `RoomViewController`
/// UIKit hosted context, and in Rich-Text-Editor's SwiftUI fullscreen mode, without need to reload data.
final class UserSuggestionSharedContext: NSObject {
/// Wrapper around `UserSuggestionViewModelType.Context` to pass it through obj-c.
final class UserSuggestionViewModelContextWrapper: NSObject {
let context: UserSuggestionViewModelType.Context
let mediaManager: MXMediaManager
init(context: UserSuggestionViewModelType.Context, mediaManager: MXMediaManager) {
init(context: UserSuggestionViewModelType.Context) {
self.context = context
self.mediaManager = mediaManager
}
}
@@ -118,9 +114,8 @@ final class UserSuggestionCoordinator: Coordinator, Presentable {
userSuggestionHostingController
}
func sharedContext() -> UserSuggestionSharedContext {
UserSuggestionSharedContext(context: userSuggestionViewModel.sharedContext,
mediaManager: parameters.mediaManager)
func sharedContext() -> UserSuggestionViewModelContextWrapper {
UserSuggestionViewModelContextWrapper(context: userSuggestionViewModel.sharedContext)
}
// MARK: - Private
@@ -53,7 +53,7 @@ final class UserSuggestionCoordinatorBridge: NSObject {
userSuggestionCoordinator.toPresentable()
}
func sharedContext() -> UserSuggestionSharedContext {
func sharedContext() -> UserSuggestionViewModelContextWrapper {
userSuggestionCoordinator.sharedContext()
}
}
@@ -17,6 +17,9 @@
import Foundation
protocol UserSuggestionViewModelProtocol {
/// Defines a shared context providing the ability to use a single `UserSuggestionViewModel` for multiple
/// `UserSuggestionList` e.g. the list component can then be displayed seemlessly in both `RoomViewController`
/// UIKit hosted context, and in Rich-Text-Editor's SwiftUI fullscreen mode, without need to reload the data.
var sharedContext: UserSuggestionViewModelType.Context { get }
var completion: ((UserSuggestionViewModelResult) -> Void)? { get set }
}