element-ios/Riot/Modules/Room/RoomCoordinatorParameters.swift

129 lines
4.9 KiB
Swift
Raw Normal View History

2021-10-05 07:41:04 +00:00
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
/// RoomCoordinator input parameters
struct RoomCoordinatorParameters {
// MARK: - Properties
/// The navigation router that manage physical navigation
let navigationRouter: NavigationRouterType?
/// The navigation router store that enables to get a NavigationRouter from a navigation controller
/// `navigationRouter` property takes priority on `navigationRouterStore`
let navigationRouterStore: NavigationRouterStoreProtocol?
2022-02-28 10:05:11 +00:00
/// Presenter for displaying loading indicators, success messages and other user indicators
2022-03-23 16:26:44 +00:00
let userIndicatorPresenter: UserIndicatorTypePresenterProtocol
2021-10-05 07:41:04 +00:00
/// The matrix session in which the room should be available.
let session: MXSession
/// The room identifier
let roomId: String
/// The identifier of the parent space. `nil` for home space
let parentSpaceId: String?
2021-10-05 07:41:04 +00:00
/// If not nil, the room will be opened on this event.
let eventId: String?
2021-11-03 23:07:50 +00:00
/// If not nil, specified thread will be opened.
let threadId: String?
/// Display configuration for the room
let displayConfiguration: RoomDisplayConfiguration
2021-10-05 07:41:04 +00:00
/// The data for the room preview.
let previewData: RoomPreviewData?
/// If `true`, the room settings screen will be initially displayed. Default `false`
let showSettingsInitially: Bool
2021-10-05 07:41:04 +00:00
// MARK: - Setup
private init(navigationRouter: NavigationRouterType?,
navigationRouterStore: NavigationRouterStoreProtocol?,
2022-03-23 16:26:44 +00:00
userIndicatorPresenter: UserIndicatorTypePresenterProtocol,
2021-10-05 07:41:04 +00:00
session: MXSession,
roomId: String,
parentSpaceId: String?,
2021-10-05 07:41:04 +00:00
eventId: String?,
2021-11-03 23:07:50 +00:00
threadId: String?,
displayConfiguration: RoomDisplayConfiguration,
previewData: RoomPreviewData?,
showSettingsInitially: Bool) {
2021-10-05 07:41:04 +00:00
self.navigationRouter = navigationRouter
self.navigationRouterStore = navigationRouterStore
self.userIndicatorPresenter = userIndicatorPresenter
2021-10-05 07:41:04 +00:00
self.session = session
self.roomId = roomId
self.parentSpaceId = parentSpaceId
2021-10-05 07:41:04 +00:00
self.eventId = eventId
2021-11-03 23:07:50 +00:00
self.threadId = threadId
self.displayConfiguration = displayConfiguration
2021-10-05 07:41:04 +00:00
self.previewData = previewData
self.showSettingsInitially = showSettingsInitially
2021-10-05 07:41:04 +00:00
}
/// Init to present a joined room
init(navigationRouter: NavigationRouterType? = nil,
navigationRouterStore: NavigationRouterStoreProtocol? = nil,
2022-03-23 16:26:44 +00:00
userIndicatorPresenter: UserIndicatorTypePresenterProtocol,
2021-10-05 07:41:04 +00:00
session: MXSession,
parentSpaceId: String?,
2021-10-05 07:41:04 +00:00
roomId: String,
eventId: String? = nil,
threadId: String? = nil,
showSettingsInitially: Bool,
displayConfiguration: RoomDisplayConfiguration = .default) {
2021-10-05 07:41:04 +00:00
self.init(navigationRouter: navigationRouter,
navigationRouterStore: navigationRouterStore,
userIndicatorPresenter: userIndicatorPresenter,
session: session,
roomId: roomId,
parentSpaceId: parentSpaceId,
eventId: eventId,
threadId: threadId,
displayConfiguration: displayConfiguration,
previewData: nil,
showSettingsInitially: showSettingsInitially)
2021-10-05 07:41:04 +00:00
}
/// Init to present a room preview
init(navigationRouter: NavigationRouterType? = nil,
navigationRouterStore: NavigationRouterStoreProtocol? = nil,
2022-03-23 16:26:44 +00:00
userIndicatorPresenter: UserIndicatorTypePresenterProtocol,
parentSpaceId: String?,
2021-10-05 07:41:04 +00:00
previewData: RoomPreviewData) {
self.init(navigationRouter: navigationRouter,
navigationRouterStore: navigationRouterStore,
2022-03-23 16:26:44 +00:00
userIndicatorPresenter: userIndicatorPresenter,
session: previewData.mxSession,
roomId: previewData.roomId,
parentSpaceId: parentSpaceId,
eventId: nil,
threadId: nil,
displayConfiguration: .default,
previewData: previewData,
showSettingsInitially: false)
2021-10-05 07:41:04 +00:00
}
}