mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 23:18:27 +02:00
* commit '56d9e1f6a55a93dc71149ae429eaa615a98de0d5': (79 commits) finish version++ version++ Translated using Weblate (Hungarian) Translated using Weblate (Italian) Translated using Weblate (Ukrainian) Translated using Weblate (Hungarian) Translated using Weblate (Slovak) Translated using Weblate (Swedish) Translated using Weblate (Indonesian) Translated using Weblate (Albanian) Translated using Weblate (Estonian) Translated using Weblate (Estonian) updated the submodule updated SDK Update the SDK. (#7819) Prepare for new sprint finish version++ version++ fix Changelog. ... # Conflicts: # Config/AppVersion.xcconfig # Podfile # Podfile.lock # Riot.xcworkspace/xcshareddata/swiftpm/Package.resolved # Riot/Managers/Settings/RiotSettings.swift # Riot/Modules/Analytics/Analytics.swift # Riot/Modules/Analytics/DecryptionFailure.swift # Riot/Modules/Analytics/PHGPostHogConfiguration.swift # Riot/Modules/Room/RoomInfo/RoomInfoList/RoomInfoListViewAction.swift # Riot/Modules/Room/RoomInfo/RoomInfoList/RoomInfoListViewModel.swift # Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m # Riot/Modules/Settings/SettingsViewController.m # Riot/Utils/EventFormatter.m # Riot/Utils/Tools.m # RiotNSE/target.yml # fastlane/Fastfile # project.yml
299 lines
12 KiB
Swift
299 lines
12 KiB
Swift
// File created from FlowTemplate
|
|
// $ createRootCoordinator.sh Room2 RoomInfo RoomInfoList
|
|
/*
|
|
Copyright 2020 New Vector Ltd
|
|
Copyright (c) 2021 BWI GmbH
|
|
|
|
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 UIKit
|
|
|
|
@objcMembers
|
|
final class RoomInfoCoordinator: NSObject, RoomInfoCoordinatorType {
|
|
|
|
// MARK: - Properties
|
|
|
|
// MARK: Private
|
|
|
|
private let navigationRouter: NavigationRouterType
|
|
private let session: MXSession
|
|
private let room: MXRoom
|
|
private let parentSpaceId: String?
|
|
private let initialSection: RoomInfoSection
|
|
private let dismissOnCancel: Bool
|
|
private let canAddParticipants: Bool
|
|
private weak var roomSettingsViewController: RoomSettingsViewController?
|
|
|
|
private lazy var segmentedViewController: SegmentedViewController = {
|
|
let controller = SegmentedViewController()
|
|
|
|
let participants = RoomParticipantsViewController()
|
|
participants.finalizeInit()
|
|
participants.enableMention = true
|
|
participants.mxRoom = self.room
|
|
participants.parentSpaceId = self.parentSpaceId
|
|
participants.delegate = self
|
|
participants.screenTracker = AnalyticsScreenTracker(screen: .roomMembers)
|
|
participants.showInviteUserFab = self.canAddParticipants
|
|
|
|
|
|
let files = RoomFilesViewController()
|
|
files.finalizeInit()
|
|
files.screenTracker = AnalyticsScreenTracker(screen: .roomUploads)
|
|
MXKRoomDataSource.load(withRoomId: self.room.roomId, threadId: nil, andMatrixSession: self.session) { (dataSource) in
|
|
guard let dataSource = dataSource as? MXKRoomDataSource else { return }
|
|
dataSource.filterMessagesWithURL = true
|
|
dataSource.finalizeInitialization()
|
|
files.hasRoomDataSourceOwnership = true
|
|
files.displayRoom(dataSource)
|
|
}
|
|
|
|
let settings = RoomSettingsViewController()
|
|
settings.parentSpaceId = parentSpaceId
|
|
settings.delegate = self
|
|
settings.finalizeInit()
|
|
settings.screenTracker = AnalyticsScreenTracker(screen: .roomSettings)
|
|
settings.initWith(self.session, andRoomId: self.room.roomId)
|
|
|
|
if self.room.isDirect {
|
|
controller.title = VectorL10n.roomDetailsTitleForDm
|
|
} else {
|
|
controller.title = VectorL10n.roomDetailsTitle
|
|
}
|
|
controller.initWithTitles([
|
|
VectorL10n.roomDetailsPeople,
|
|
BWIL10n.roomDetailsFiles,
|
|
VectorL10n.roomDetailsSettings
|
|
], viewControllers: [
|
|
participants,
|
|
files,
|
|
settings
|
|
], defaultSelected: 0)
|
|
controller.addMatrixSession(self.session)
|
|
|
|
self.roomSettingsViewController = settings
|
|
|
|
_ = controller.view
|
|
|
|
return controller
|
|
}()
|
|
|
|
// MARK: Public
|
|
|
|
// Must be used only internally
|
|
var childCoordinators: [Coordinator] = []
|
|
|
|
weak var delegate: RoomInfoCoordinatorDelegate?
|
|
|
|
// MARK: - Setup
|
|
|
|
init(parameters: RoomInfoCoordinatorParameters, navigationRouter: NavigationRouterType? = nil) {
|
|
if let navigationRouter = navigationRouter {
|
|
self.navigationRouter = navigationRouter
|
|
} else {
|
|
self.navigationRouter = NavigationRouter(navigationController: RiotNavigationController())
|
|
}
|
|
|
|
self.session = parameters.session
|
|
self.room = parameters.room
|
|
self.parentSpaceId = parameters.parentSpaceId
|
|
self.initialSection = parameters.initialSection
|
|
self.canAddParticipants = parameters.canAddParticipants
|
|
self.dismissOnCancel = parameters.dismissOnCancel
|
|
}
|
|
|
|
// MARK: - Public methods
|
|
|
|
func start() {
|
|
let rootCoordinator = self.createRoomInfoListCoordinator()
|
|
|
|
rootCoordinator.start()
|
|
|
|
self.add(childCoordinator: rootCoordinator)
|
|
|
|
if self.navigationRouter.modules.isEmpty == false {
|
|
// push room info screen non animated if another screen needs to be pushed just after
|
|
let animated = initialSection == .none
|
|
self.navigationRouter.push(rootCoordinator.toPresentable(), animated: animated, popCompletion: nil)
|
|
} else {
|
|
self.navigationRouter.setRootModule(rootCoordinator)
|
|
}
|
|
|
|
switch initialSection {
|
|
case .addParticipants:
|
|
self.showRoomDetails(with: .members, animated: false)
|
|
case .changeAvatar:
|
|
self.showRoomDetails(with: .settings(RoomSettingsViewControllerFieldAvatar), animated: false)
|
|
case .changeTopic:
|
|
self.showRoomDetails(with: .settings(RoomSettingsViewControllerFieldTopic), animated: false)
|
|
case .settings:
|
|
self.showRoomDetails(with: .settings(RoomSettingsViewControllerFieldNone), animated: false)
|
|
case .none:
|
|
break
|
|
}
|
|
}
|
|
|
|
func toPresentable() -> UIViewController {
|
|
return self.navigationRouter.toPresentable()
|
|
}
|
|
|
|
// MARK: - Private methods
|
|
|
|
private func createRoomInfoListCoordinator() -> RoomInfoListCoordinator {
|
|
let coordinator = RoomInfoListCoordinator(session: self.session, room: room)
|
|
coordinator.delegate = self
|
|
return coordinator
|
|
}
|
|
|
|
private func createRoomNotificationSettingsCoordinator() -> RoomNotificationSettingsCoordinator {
|
|
let coordinator = RoomNotificationSettingsCoordinator(room: room, presentedModally: false)
|
|
coordinator.delegate = self
|
|
return coordinator
|
|
}
|
|
|
|
private func createRoomRollsAndRightsCoordinator() -> RoomRollsAndRightsCoordinator {
|
|
let coordinator = RoomRollsAndRightsCoordinator(room: room)
|
|
coordinator.delegate = self
|
|
return coordinator
|
|
}
|
|
|
|
private func showRoomDetails(with target: RoomInfoListTarget, animated: Bool) {
|
|
switch target {
|
|
case .integrations:
|
|
if let modularVC = IntegrationManagerViewController(for: session, inRoom: room.roomId, screen: kIntegrationManagerMainScreen, widgetId: nil) {
|
|
navigationRouter.present(modularVC, animated: true)
|
|
}
|
|
case .search:
|
|
MXKRoomDataSourceManager.sharedManager(forMatrixSession: session)?.roomDataSource(forRoom: self.room.roomId, create: false, onComplete: { (roomDataSource) in
|
|
guard let dataSource = roomDataSource else { return }
|
|
let roomSearchViewController: RoomSearchViewController = RoomSearchViewController.instantiate()
|
|
roomSearchViewController.loadViewIfNeeded()
|
|
roomSearchViewController.roomDataSource = dataSource
|
|
self.navigationRouter.push(roomSearchViewController, animated: animated, popCompletion: nil)
|
|
})
|
|
case .notifications:
|
|
let coordinator = createRoomNotificationSettingsCoordinator()
|
|
coordinator.start()
|
|
self.add(childCoordinator: coordinator)
|
|
self.navigationRouter.push(coordinator, animated: true, popCompletion: nil)
|
|
case .rollsAndRights:
|
|
let coordinator = createRoomRollsAndRightsCoordinator()
|
|
coordinator.start()
|
|
self.add(childCoordinator: coordinator)
|
|
self.navigationRouter.push(coordinator, animated: true, popCompletion: nil)
|
|
case .pollHistory:
|
|
let coordinator: PollHistoryCoordinator = .init(parameters: .init(mode: .active, room: room, navigationRouter: navigationRouter))
|
|
coordinator.start()
|
|
coordinator.completion = { [weak self] event in
|
|
guard let self else { return }
|
|
self.delegate?.roomInfoCoordinator(self, viewEventInTimeline: event)
|
|
}
|
|
push(coordinator: coordinator)
|
|
default:
|
|
guard let tabIndex = target.tabIndex else {
|
|
fatalError("No settings tab index for this target.")
|
|
}
|
|
segmentedViewController.selectedIndex = tabIndex
|
|
|
|
if case .settings(let roomSettingsField) = target {
|
|
roomSettingsViewController?.selectedRoomSettingsField = roomSettingsField
|
|
}
|
|
|
|
navigationRouter.push(segmentedViewController, animated: animated, popCompletion: nil)
|
|
}
|
|
}
|
|
|
|
private func push(coordinator: Coordinator & Presentable, animated: Bool = true) {
|
|
self.add(childCoordinator: coordinator)
|
|
navigationRouter.push(coordinator, animated: animated) {
|
|
self.remove(childCoordinator: coordinator)
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - RoomInfoListCoordinatorDelegate
|
|
extension RoomInfoCoordinator: RoomInfoListCoordinatorDelegate {
|
|
|
|
func roomInfoListCoordinator(_ coordinator: RoomInfoListCoordinatorType, wantsToNavigateTo target: RoomInfoListTarget) {
|
|
self.showRoomDetails(with: target, animated: true)
|
|
}
|
|
|
|
func roomInfoListCoordinatorDidCancel(_ coordinator: RoomInfoListCoordinatorType) {
|
|
self.delegate?.roomInfoCoordinatorDidComplete(self)
|
|
}
|
|
|
|
func roomInfoListCoordinatorDidLeaveRoom(_ coordinator: RoomInfoListCoordinatorType) {
|
|
self.delegate?.roomInfoCoordinatorDidLeaveRoom(self)
|
|
}
|
|
|
|
func roomInfoListCoordinatorDidRequestReportRoom(_ coordinator: RoomInfoListCoordinatorType) {
|
|
self.delegate?.roomInfoCoordinatorDidRequestReportRoom(self)
|
|
}
|
|
}
|
|
|
|
extension RoomInfoCoordinator: RoomParticipantsViewControllerDelegate {
|
|
|
|
func roomParticipantsViewController(_ roomParticipantsViewController: RoomParticipantsViewController!, mention member: MXRoomMember!) {
|
|
self.navigationRouter.popToRootModule(animated: true)
|
|
self.delegate?.roomInfoCoordinator(self, didRequestMentionForMember: member)
|
|
}
|
|
|
|
}
|
|
|
|
extension RoomInfoCoordinator: RoomRollsAndRightsCoordinatorDelegate {
|
|
func roomRollsAndRightsCoordinatorDidComplete(_ coordinator: RoomRollsAndRightsCoordinatorType) {
|
|
self.navigationRouter.popModule(animated: true)
|
|
}
|
|
|
|
func roomRollsAndRightsCoordinatorDidCancel(_ coordinator: RoomRollsAndRightsCoordinatorType) {
|
|
}
|
|
}
|
|
|
|
extension RoomInfoCoordinator: RoomNotificationSettingsCoordinatorDelegate {
|
|
func roomNotificationSettingsCoordinatorDidComplete(_ coordinator: RoomNotificationSettingsCoordinatorType) {
|
|
self.navigationRouter.popModule(animated: true)
|
|
}
|
|
|
|
func roomNotificationSettingsCoordinatorDidCancel(_ coordinator: RoomNotificationSettingsCoordinatorType) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extension RoomInfoCoordinator: RoomSettingsViewControllerDelegate {
|
|
func roomSettingsViewControllerDidCancel(_ controller: RoomSettingsViewController!) {
|
|
if self.dismissOnCancel {
|
|
self.navigationRouter.dismissModule(animated: true, completion: nil)
|
|
} else {
|
|
controller.withdrawViewController(animated: true) {}
|
|
}
|
|
}
|
|
|
|
func roomSettingsViewControllerDidComplete(_ controller: RoomSettingsViewController!) {
|
|
if self.dismissOnCancel {
|
|
self.navigationRouter.dismissModule(animated: true, completion: nil)
|
|
} else {
|
|
controller.withdrawViewController(animated: true) {}
|
|
}
|
|
}
|
|
|
|
func roomSettingsViewController(_ controller: RoomSettingsViewController!, didReplaceRoomWithReplacementId newRoomId: String!) {
|
|
self.delegate?.roomInfoCoordinator(self, didReplaceRoomWithReplacementId: newRoomId)
|
|
}
|
|
|
|
func roomSettingsViewControllerDidLeaveRoom(_ controller: RoomSettingsViewController!) {
|
|
self.delegate?.roomInfoCoordinatorDidLeaveRoom(self)
|
|
}
|
|
}
|