mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 21:26:57 +02:00
Merge pull request #5690 from vector-im/andy/5603_room_indicators
Room activity indicators
This commit is contained in:
@@ -1772,23 +1772,21 @@
|
||||
|
||||
#pragma mark - activity indicator
|
||||
|
||||
- (void)stopActivityIndicator
|
||||
{
|
||||
- (BOOL)canStopActivityIndicator {
|
||||
// Keep the loading wheel displayed while we are joining the room
|
||||
if (joinRoomRequest)
|
||||
{
|
||||
return;
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Check internal processes before stopping the loading wheel
|
||||
if (isPaginationInProgress || isInputToolbarProcessing)
|
||||
{
|
||||
// Keep activity indicator running
|
||||
return;
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Leave super decide
|
||||
[super stopActivityIndicator];
|
||||
return [super canStopActivityIndicator];
|
||||
}
|
||||
|
||||
#pragma mark - Pagination
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import CommonKit
|
||||
|
||||
final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
|
||||
@@ -29,6 +30,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
private let roomViewController: RoomViewController
|
||||
private let activityIndicatorPresenter: ActivityIndicatorPresenterType
|
||||
private var selectedEventId: String?
|
||||
private var loadingIndicator: UserIndicator?
|
||||
|
||||
private var roomDataSourceManager: MXKRoomDataSourceManager {
|
||||
return MXKRoomDataSourceManager.sharedManager(forMatrixSession: self.parameters.session)
|
||||
@@ -149,7 +151,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
private func loadRoom(withId roomId: String, completion: (() -> Void)?) {
|
||||
|
||||
// Present activity indicator when retrieving roomDataSource for given room ID
|
||||
self.activityIndicatorPresenter.presentActivityIndicator(on: roomViewController.view, animated: false)
|
||||
startLoading()
|
||||
|
||||
let roomDataSourceManager: MXKRoomDataSourceManager = MXKRoomDataSourceManager.sharedManager(forMatrixSession: self.parameters.session)
|
||||
|
||||
@@ -160,7 +162,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
return
|
||||
}
|
||||
|
||||
self.activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
self.stopLoading()
|
||||
|
||||
if let roomDataSource = roomDataSource {
|
||||
self.roomViewController.displayRoom(roomDataSource)
|
||||
@@ -173,7 +175,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
private func loadRoom(withId roomId: String, andEventId eventId: String, completion: (() -> Void)?) {
|
||||
|
||||
// Present activity indicator when retrieving roomDataSource for given room ID
|
||||
self.activityIndicatorPresenter.presentActivityIndicator(on: roomViewController.view, animated: false)
|
||||
startLoading()
|
||||
|
||||
// Open the room on the requested event
|
||||
RoomDataSource.load(withRoomId: roomId,
|
||||
@@ -185,7 +187,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
return
|
||||
}
|
||||
|
||||
self.activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
self.stopLoading()
|
||||
|
||||
guard let roomDataSource = dataSource as? RoomDataSource else {
|
||||
return
|
||||
@@ -204,7 +206,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
private func loadRoom(withId roomId: String, andThreadId threadId: String, eventId: String?, completion: (() -> Void)?) {
|
||||
|
||||
// Present activity indicator when retrieving roomDataSource for given room ID
|
||||
self.activityIndicatorPresenter.presentActivityIndicator(on: roomViewController.view, animated: false)
|
||||
startLoading()
|
||||
|
||||
// Open the thread on the requested event
|
||||
ThreadDataSource.load(withRoomId: roomId,
|
||||
@@ -216,7 +218,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
return
|
||||
}
|
||||
|
||||
self.activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
self.stopLoading()
|
||||
|
||||
guard let threadDataSource = dataSource as? ThreadDataSource else {
|
||||
return
|
||||
@@ -312,6 +314,19 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
navigationRouter?.present(coordinator, animated: true)
|
||||
coordinator.start()
|
||||
}
|
||||
|
||||
private func startLoading() {
|
||||
if let presenter = parameters.userIndicatorPresenter {
|
||||
loadingIndicator = presenter.present(.loading(label: VectorL10n.homeSyncing, isInteractionBlocking: false))
|
||||
} else {
|
||||
activityIndicatorPresenter.presentActivityIndicator(on: roomViewController.view, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
private func stopLoading() {
|
||||
loadingIndicator = nil
|
||||
activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - RoomIdentifiable
|
||||
@@ -421,4 +436,16 @@ extension RoomCoordinator: RoomViewControllerDelegate {
|
||||
func roomViewController(_ roomViewController: RoomViewController, didRequestEditForPollWithStart startEvent: MXEvent) {
|
||||
startEditPollCoordinator(startEvent: startEvent)
|
||||
}
|
||||
|
||||
func roomViewControllerCanDelegateUserIndicators(_ roomViewController: RoomViewController) -> Bool {
|
||||
return BuildSettings.useAppUserIndicators
|
||||
}
|
||||
|
||||
func roomViewControllerDidStartLoading(_ roomViewController: RoomViewController) {
|
||||
startLoading()
|
||||
}
|
||||
|
||||
func roomViewControllerDidStopLoading(_ roomViewController: RoomViewController) {
|
||||
stopLoading()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ struct RoomCoordinatorParameters {
|
||||
/// `navigationRouter` property takes priority on `navigationRouterStore`
|
||||
let navigationRouterStore: NavigationRouterStoreProtocol?
|
||||
|
||||
/// Presenter for displaying loading indicators, success messages and other user indicators
|
||||
let userIndicatorPresenter: UserIndicatorTypePresenterProtocol?
|
||||
|
||||
/// The matrix session in which the room should be available.
|
||||
let session: MXSession
|
||||
|
||||
@@ -50,6 +53,7 @@ struct RoomCoordinatorParameters {
|
||||
|
||||
private init(navigationRouter: NavigationRouterType?,
|
||||
navigationRouterStore: NavigationRouterStoreProtocol?,
|
||||
userIndicatorPresenter: UserIndicatorTypePresenterProtocol?,
|
||||
session: MXSession,
|
||||
roomId: String,
|
||||
eventId: String?,
|
||||
@@ -58,6 +62,7 @@ struct RoomCoordinatorParameters {
|
||||
previewData: RoomPreviewData?) {
|
||||
self.navigationRouter = navigationRouter
|
||||
self.navigationRouterStore = navigationRouterStore
|
||||
self.userIndicatorPresenter = userIndicatorPresenter
|
||||
self.session = session
|
||||
self.roomId = roomId
|
||||
self.eventId = eventId
|
||||
@@ -69,6 +74,7 @@ struct RoomCoordinatorParameters {
|
||||
/// Init to present a joined room
|
||||
init(navigationRouter: NavigationRouterType? = nil,
|
||||
navigationRouterStore: NavigationRouterStoreProtocol? = nil,
|
||||
userIndicatorPresenter: UserIndicatorTypePresenterProtocol? = nil,
|
||||
session: MXSession,
|
||||
roomId: String,
|
||||
eventId: String? = nil,
|
||||
@@ -77,6 +83,7 @@ struct RoomCoordinatorParameters {
|
||||
|
||||
self.init(navigationRouter: navigationRouter,
|
||||
navigationRouterStore: navigationRouterStore,
|
||||
userIndicatorPresenter: userIndicatorPresenter,
|
||||
session: session,
|
||||
roomId: roomId,
|
||||
eventId: eventId,
|
||||
@@ -92,6 +99,7 @@ struct RoomCoordinatorParameters {
|
||||
|
||||
self.init(navigationRouter: navigationRouter,
|
||||
navigationRouterStore: navigationRouterStore,
|
||||
userIndicatorPresenter: nil,
|
||||
session: previewData.mxSession,
|
||||
roomId: previewData.roomId,
|
||||
eventId: nil,
|
||||
|
||||
@@ -41,6 +41,8 @@ final class RoomInfoListViewController: UIViewController {
|
||||
private var theme: Theme!
|
||||
private var errorPresenter: MXKErrorPresentation!
|
||||
private var activityPresenter: ActivityIndicatorPresenterType!
|
||||
private var indicatorPresenter: UserIndicatorTypePresenterProtocol!
|
||||
private var loadingIndicator: UserIndicator?
|
||||
private var isRoomDirect: Bool = false
|
||||
private var screenTimer = AnalyticsScreenTimer(screen: .roomDetails)
|
||||
|
||||
@@ -116,14 +118,10 @@ final class RoomInfoListViewController: UIViewController {
|
||||
// Do any additional setup after loading the view.
|
||||
|
||||
self.setupViews()
|
||||
if BuildSettings.useAppUserIndicators {
|
||||
self.activityPresenter = FullscreenActivityIndicatorPresenter(
|
||||
label: VectorL10n.roomParticipantsLeaveProcessing,
|
||||
viewController: self
|
||||
)
|
||||
} else {
|
||||
self.activityPresenter = ActivityIndicatorPresenter()
|
||||
}
|
||||
|
||||
self.activityPresenter = ActivityIndicatorPresenter()
|
||||
self.indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: self)
|
||||
|
||||
self.errorPresenter = MXKErrorAlertPresentation()
|
||||
|
||||
self.registerThemeServiceDidChangeThemeNotification()
|
||||
@@ -152,7 +150,7 @@ final class RoomInfoListViewController: UIViewController {
|
||||
override func viewDidDisappear(_ animated: Bool) {
|
||||
super.viewDidDisappear(animated)
|
||||
screenTimer.stop()
|
||||
activityPresenter.removeCurrentActivityIndicator(animated: animated)
|
||||
stopLoading()
|
||||
}
|
||||
|
||||
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||
@@ -272,19 +270,36 @@ final class RoomInfoListViewController: UIViewController {
|
||||
}
|
||||
|
||||
private func renderLoading() {
|
||||
self.activityPresenter.presentActivityIndicator(on: self.view, animated: true)
|
||||
if BuildSettings.useAppUserIndicators {
|
||||
loadingIndicator = indicatorPresenter.present(
|
||||
.loading(
|
||||
label: VectorL10n.roomParticipantsLeaveProcessing,
|
||||
isInteractionBlocking: true
|
||||
)
|
||||
)
|
||||
} else {
|
||||
activityPresenter.presentActivityIndicator(on: self.view, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
private func renderLoaded(viewData: RoomInfoListViewData) {
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
stopLoading()
|
||||
self.updateSections(with: viewData)
|
||||
}
|
||||
|
||||
private func render(error: Error) {
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
stopLoading()
|
||||
self.errorPresenter.presentError(from: self, forError: error, animated: true, handler: nil)
|
||||
}
|
||||
|
||||
private func stopLoading() {
|
||||
if BuildSettings.useAppUserIndicators {
|
||||
loadingIndicator?.cancel()
|
||||
} else {
|
||||
activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@objc private func closeButtonTapped(_ sender: Any) {
|
||||
|
||||
@@ -234,6 +234,30 @@ canEditPollWithEventIdentifier:(NSString *)eventIdentifier;
|
||||
- (void)roomViewController:(RoomViewController *)roomViewController
|
||||
didRequestEditForPollWithStartEvent:(MXEvent *)startEvent;
|
||||
|
||||
/**
|
||||
Checks whether the delegate supports handling of activity indicators
|
||||
|
||||
Note: This is a transition API whilst `RoomViewController` contains legacy activity indicators
|
||||
as well as using a newer user interaction presenters.
|
||||
*/
|
||||
- (BOOL)roomViewControllerCanDelegateUserIndicators:(RoomViewController *)roomViewController;
|
||||
|
||||
/**
|
||||
Indicate to the delegate that loading should start
|
||||
|
||||
Note: Only called if the controller can delegate user indicators rather than managing
|
||||
loading indicators internally
|
||||
*/
|
||||
- (void)roomViewControllerDidStartLoading:(RoomViewController *)roomViewController;
|
||||
|
||||
/**
|
||||
Indicate to the delegate that loading should stop
|
||||
|
||||
Note: Only called if the controller can delegate user indicators rather than managing
|
||||
loading indicators internally
|
||||
*/
|
||||
- (void)roomViewControllerDidStopLoading:(RoomViewController *)roomViewController;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -570,6 +570,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
isAppeared = NO;
|
||||
|
||||
[VoiceMessageMediaServiceProvider.sharedProvider pauseAllServices];
|
||||
[self stopActivityIndicator];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
@@ -931,6 +932,18 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
self.updateRoomReadMarker = NO;
|
||||
}
|
||||
|
||||
- (BOOL)providesCustomActivityIndicator {
|
||||
return [self.delegate roomViewControllerCanDelegateUserIndicators:self];
|
||||
}
|
||||
|
||||
- (void)startActivityIndicator {
|
||||
if ([self providesCustomActivityIndicator]) {
|
||||
[self.delegate roomViewControllerDidStartLoading:self];
|
||||
} else {
|
||||
[super startActivityIndicator];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopActivityIndicator
|
||||
{
|
||||
if (notificationTaskProfile)
|
||||
@@ -939,8 +952,13 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
[MXSDKOptions.sharedInstance.profiler stopMeasuringTaskWithProfile:notificationTaskProfile];
|
||||
notificationTaskProfile = nil;
|
||||
}
|
||||
|
||||
[super stopActivityIndicator];
|
||||
if ([self providesCustomActivityIndicator]) {
|
||||
if ([self canStopActivityIndicator]) {
|
||||
[self.delegate roomViewControllerDidStopLoading:self];
|
||||
}
|
||||
} else {
|
||||
[super stopActivityIndicator];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)displayRoom:(MXKRoomDataSource *)dataSource
|
||||
|
||||
Reference in New Issue
Block a user