mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-01 23:35:59 +00:00
56 lines
1.3 KiB
Objective-C
56 lines
1.3 KiB
Objective-C
//
|
|
// LoadingFrameViewController.m
|
|
// Moonlight
|
|
//
|
|
// Created by Diego Waxemberg on 2/24/15.
|
|
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
|
|
//
|
|
|
|
#import "LoadingFrameViewController.h"
|
|
|
|
@implementation LoadingFrameViewController {
|
|
BOOL presented;
|
|
};
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// center the loading spinner
|
|
self.loadingSpinner.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2);
|
|
}
|
|
|
|
- (UIViewController*) activeViewController {
|
|
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
|
|
|
|
while (topController.presentedViewController) {
|
|
topController = topController.presentedViewController;
|
|
}
|
|
|
|
return topController;
|
|
}
|
|
|
|
- (void)showLoadingFrame:(void (^)(void))completion {
|
|
if (!presented) {
|
|
presented = YES;
|
|
[[self activeViewController] presentViewController:self animated:NO completion:completion];
|
|
}
|
|
else if (completion) {
|
|
completion();
|
|
}
|
|
}
|
|
|
|
- (void)dismissLoadingFrame:(void (^)(void))completion {
|
|
if (presented) {
|
|
presented = NO;
|
|
[self dismissViewControllerAnimated:NO completion:completion];
|
|
}
|
|
else if (completion) {
|
|
completion();
|
|
}
|
|
}
|
|
|
|
- (BOOL)isShown {
|
|
return presented;
|
|
}
|
|
|
|
@end
|