mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-25 11:02:48 +02:00
Display user suggestion list in fullscreen mode with shared context from UserSuggestionCoordinator
This commit is contained in:
@@ -30,6 +30,19 @@ 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 {
|
||||
let context: UserSuggestionViewModelType.Context
|
||||
let mediaManager: MXMediaManager
|
||||
|
||||
init(context: UserSuggestionViewModelType.Context, mediaManager: MXMediaManager) {
|
||||
self.context = context
|
||||
self.mediaManager = mediaManager
|
||||
}
|
||||
}
|
||||
|
||||
final class UserSuggestionCoordinator: Coordinator, Presentable {
|
||||
// MARK: - Properties
|
||||
|
||||
@@ -105,6 +118,11 @@ final class UserSuggestionCoordinator: Coordinator, Presentable {
|
||||
userSuggestionHostingController
|
||||
}
|
||||
|
||||
func sharedContext() -> UserSuggestionSharedContext {
|
||||
UserSuggestionSharedContext(context: userSuggestionViewModel.sharedContext,
|
||||
mediaManager: parameters.mediaManager)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func calculateViewHeight() -> CGFloat {
|
||||
|
||||
+4
@@ -52,6 +52,10 @@ final class UserSuggestionCoordinatorBridge: NSObject {
|
||||
func toPresentable() -> UIViewController? {
|
||||
userSuggestionCoordinator.toPresentable()
|
||||
}
|
||||
|
||||
func sharedContext() -> UserSuggestionSharedContext {
|
||||
userSuggestionCoordinator.sharedContext()
|
||||
}
|
||||
}
|
||||
|
||||
extension UserSuggestionCoordinatorBridge: UserSuggestionCoordinatorDelegate {
|
||||
|
||||
@@ -27,7 +27,11 @@ class UserSuggestionViewModel: UserSuggestionViewModelType, UserSuggestionViewMo
|
||||
private let userSuggestionService: UserSuggestionServiceProtocol
|
||||
|
||||
// MARK: Public
|
||||
|
||||
|
||||
var sharedContext: UserSuggestionViewModelType.Context {
|
||||
return self.context
|
||||
}
|
||||
|
||||
var completion: ((UserSuggestionViewModelResult) -> Void)?
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
@@ -17,5 +17,6 @@
|
||||
import Foundation
|
||||
|
||||
protocol UserSuggestionViewModelProtocol {
|
||||
var sharedContext: UserSuggestionViewModelType.Context { get }
|
||||
var completion: ((UserSuggestionViewModelResult) -> Void)? { get set }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user