mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
Add new loading indicators
This commit is contained in:
@@ -29,6 +29,11 @@
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
if ([self providesCustomActivityIndicator]) {
|
||||
// If a subclass provides custom activity indicator, the default one will not even be initialized.
|
||||
return;
|
||||
}
|
||||
|
||||
// Add default activity indicator
|
||||
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
||||
activityIndicator.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1.0];
|
||||
@@ -56,9 +61,13 @@
|
||||
|
||||
#pragma mark - Activity indicator
|
||||
|
||||
- (BOOL)providesCustomActivityIndicator {
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)startActivityIndicator
|
||||
{
|
||||
if (activityIndicator)
|
||||
if (activityIndicator && ![self providesCustomActivityIndicator])
|
||||
{
|
||||
[self.view bringSubviewToFront:activityIndicator];
|
||||
[activityIndicator startAnimating];
|
||||
@@ -79,5 +88,4 @@
|
||||
[activityIndicator stopAnimating];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -220,7 +220,7 @@
|
||||
if ([MXKRoomDataSourceManager sharedManagerForMatrixSession:mxSession].isServerSyncInProgress)
|
||||
{
|
||||
// sync is in progress for at least one data source, keep running the loading wheel
|
||||
[self.activityIndicator startAnimating];
|
||||
[self startActivityIndicator];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,5 +48,10 @@
|
||||
*/
|
||||
@property CGFloat keyboardHeight;
|
||||
|
||||
/**
|
||||
Returns `YES` if any `MXSession` currently requires the display of an activity indicator.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL shouldShowActivityIndicator;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -492,18 +492,21 @@ const CGFloat MXKViewControllerMaxExternalKeyboardHeight = 80;
|
||||
|
||||
#pragma mark - Activity indicator
|
||||
|
||||
- (void)stopActivityIndicator
|
||||
{
|
||||
// Check whether all conditions are satisfied before stopping loading wheel
|
||||
BOOL isActivityInProgress = NO;
|
||||
- (BOOL)shouldShowActivityIndicator {
|
||||
for (MXSession *mxSession in mxSessionArray)
|
||||
{
|
||||
if (mxSession.shouldShowActivityIndicator)
|
||||
{
|
||||
isActivityInProgress = YES;
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
if (!isActivityInProgress)
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)stopActivityIndicator
|
||||
{
|
||||
// Check whether all conditions are satisfied before stopping loading wheel
|
||||
if (!self.shouldShowActivityIndicator)
|
||||
{
|
||||
[super stopActivityIndicator];
|
||||
}
|
||||
|
||||
@@ -35,6 +35,14 @@
|
||||
*/
|
||||
@property (nonatomic) UIActivityIndicatorView *activityIndicator;
|
||||
|
||||
/**
|
||||
A view controller may choose to implement a completely custom activity indicator (e.g. shared toast notification),
|
||||
|
||||
In this case the default `activityIndicator` will be hidden, and the view controller is responsible for overriding
|
||||
`startActivityIndicator` and `stopActivityIndicator` methods to show / hide the custom activity indicator.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL providesCustomActivityIndicator;
|
||||
|
||||
/**
|
||||
Bring the activity indicator to the front and start it.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user