Convenience for load screen
re-link framework
This commit is contained in:
parent
9badc9432f
commit
1d7e1be051
@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Returns a navigation controller with the mvm styling. Also sets the navigation controller in the appropriate handlers.
|
||||
+ (nullable instancetype)setupNavigationController;
|
||||
|
||||
// Returns a navigation controller with the mvm styling. Also sets the navigation controller in the appropriate handlers. Adds the default loading overlay screen as well.
|
||||
+ (nullable instancetype)setupWithNavigationControllerAsMainController;
|
||||
|
||||
// Separator at the bottom of the navigation bar used for styling.
|
||||
@property (nullable, weak, nonatomic) SeparatorView *separatorView;
|
||||
@end
|
||||
|
||||
@ -43,4 +43,10 @@
|
||||
return navigationController;
|
||||
}
|
||||
|
||||
+ (nullable instancetype)setupWithNavigationControllerAsMainController {
|
||||
MVMCoreUINavigationControllerViewController *navigationController = [self setupNavigationController];
|
||||
[[MVMCoreUISession sharedGlobal] setupAsStandardLoadViewDelegate:navigationController];
|
||||
return navigationController;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
@import MVMCore.MVMCoreActionDelegateProtocol;
|
||||
@import MVMCore.MVMCoreLoadingOverlayDelegateProtocol;
|
||||
#import <MVMCoreUI/MVMCoreUIPanelProtocol.h>
|
||||
#import <MVMCoreUI/MVMCoreUIPanelButtonProtocol.h>
|
||||
|
||||
@ -23,7 +22,7 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
||||
MFTwoDrawer
|
||||
};
|
||||
|
||||
@interface MVMCoreUISplitViewController : UIViewController <MVMCoreLoadingOverlayDelegateProtocol>
|
||||
@interface MVMCoreUISplitViewController : UIViewController
|
||||
|
||||
// Reference to the panels.
|
||||
@property (nullable, weak, nonatomic, readonly) UIViewController <MVMCoreUIPanelProtocol> *leftPanel;
|
||||
@ -51,6 +50,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
||||
// Returns a split controller with the mvm styling. Also sets the appropriate handlers.
|
||||
+ (nullable instancetype)setup;
|
||||
|
||||
// Returns a split controller with the mvm styling. Also sets the appropriate handlers. Also sets up the default load screen
|
||||
+ (nullable instancetype)setupAsMainController;
|
||||
|
||||
#pragma mark - Panel Functions
|
||||
|
||||
// Sets if the left panel accessible for the view controller. Will show or hide the button.
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
#import "MVMCoreUISplitViewController.h"
|
||||
@import MVMCore.MVMCoreNavigationHandler;
|
||||
@import MVMCore.MVMCoreDispatchUtility;
|
||||
@import MVMCore.MVMCoreViewControllerProtocol;
|
||||
@import MVMCore.MVMCoreViewManagerProtocol;
|
||||
@import MVMCore.MVMCoreObject;
|
||||
@import MVMCore.MVMCoreActionUtility;
|
||||
@ -18,7 +17,6 @@
|
||||
#import "NSLayoutConstraint+MFConvenience.h"
|
||||
#import "MFViewController.h"
|
||||
#import "MFFonts.h"
|
||||
#import "MFLoadingViewController.h"
|
||||
#import <MVMCoreUI/MFSizeObject.h>
|
||||
#import "SeparatorView.h"
|
||||
#import "MVMCoreUISession.h"
|
||||
@ -50,8 +48,6 @@
|
||||
@property (weak, nonatomic) IBOutlet UIProgressView *bottomProgressBar;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomProgressBarHeightConstraint;
|
||||
|
||||
@property (weak, nonatomic) MFLoadingViewController *loadingViewController;
|
||||
|
||||
@property (nonatomic, strong) UIGestureRecognizer *tapToDismissGesture;
|
||||
|
||||
@property (nullable, readwrite, weak, nonatomic) NSObject <MVMCoreUIPanelProtocol> *explictlyShowingPanel;
|
||||
@ -88,6 +84,12 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
return splitViewController;
|
||||
}
|
||||
|
||||
+ (nullable instancetype)setupAsMainController {
|
||||
MVMCoreUISplitViewController *splitViewController = [self setup];
|
||||
[[MVMCoreUISession sharedGlobal] setupAsStandardLoadViewDelegate:splitViewController];
|
||||
return splitViewController;
|
||||
}
|
||||
|
||||
#pragma mark - Main Subclassables
|
||||
|
||||
- (MFNumberOfDrawers)numberOfDrawersShouldShow:(NSNumber *)forWidth {
|
||||
@ -932,39 +934,4 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MVMCoreLoadingOverlayDelegateProtocol
|
||||
|
||||
- (nonnull UIViewController <MVMCoreLoadingViewControllerProtocol> *)getLoadingViewController {
|
||||
|
||||
if (self.loadingViewController) {
|
||||
return self.loadingViewController;
|
||||
} else {
|
||||
MFLoadingViewController *loadingViewController = [[MFLoadingViewController alloc] init];
|
||||
UIView *view = loadingViewController.view;
|
||||
view.hidden = YES;
|
||||
self.loadingViewController = loadingViewController;
|
||||
|
||||
// Adds the overlay to the screen.
|
||||
UIView *viewToPresentOn = self.view;
|
||||
|
||||
[self addChildViewController:loadingViewController];
|
||||
[viewToPresentOn addSubview:view];
|
||||
[loadingViewController didMoveToParentViewController:self];
|
||||
|
||||
// Sets the constraints for autolayout
|
||||
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
[NSLayoutConstraint constraintPinSubviewToSuperview:view];
|
||||
return loadingViewController;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)beginningLoading {
|
||||
// Disables the UI when loading
|
||||
self.view.userInteractionEnabled = NO;
|
||||
}
|
||||
|
||||
- (void)finishedLoading {
|
||||
self.view.userInteractionEnabled = YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -29,6 +29,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Allows a global overload of the title view of navigation item.
|
||||
- (nullable UIView *)titleViewForController:(nonnull MFViewController *)controller;
|
||||
|
||||
// Sets up the session as delegate for standard load view controller. Pass the view controller that will be used to present and will be disabled when load view is presented.
|
||||
- (void)setupAsStandardLoadViewDelegate:(nonnull UIViewController *)mainViewController;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -7,6 +7,16 @@
|
||||
//
|
||||
|
||||
#import "MVMCoreUISession.h"
|
||||
#import "MFLoadingViewController.h"
|
||||
#import "NSLayoutConstraint+MFConvenience.h"
|
||||
@import MVMCore.MVMCoreObject;
|
||||
|
||||
@interface MVMCoreUISession () <MVMCoreLoadingOverlayDelegateProtocol>
|
||||
|
||||
@property (weak, nonatomic, nullable) UIViewController *mainViewController;
|
||||
@property (weak, nonatomic, nullable) MFLoadingViewController *loadingViewController;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MVMCoreUISession
|
||||
|
||||
@ -14,4 +24,43 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setupAsStandardLoadViewDelegate:(nonnull UIViewController *)mainViewController {
|
||||
self.mainViewController = mainViewController;
|
||||
[MVMCoreObject sharedInstance].loadingProtocol = self;
|
||||
}
|
||||
|
||||
#pragma mark - MVMCoreLoadingOverlayDelegateProtocol
|
||||
|
||||
- (nonnull UIViewController <MVMCoreLoadingViewControllerProtocol> *)getLoadingViewController {
|
||||
|
||||
if (self.loadingViewController) {
|
||||
return self.loadingViewController;
|
||||
} else {
|
||||
MFLoadingViewController *loadingViewController = [[MFLoadingViewController alloc] init];
|
||||
UIView *view = loadingViewController.view;
|
||||
view.hidden = YES;
|
||||
self.loadingViewController = loadingViewController;
|
||||
|
||||
// Adds the overlay to the screen.
|
||||
UIView *viewToPresentOn = self.mainViewController.view;
|
||||
[self.mainViewController addChildViewController:loadingViewController];
|
||||
[viewToPresentOn addSubview:view];
|
||||
[loadingViewController didMoveToParentViewController:self.mainViewController];
|
||||
|
||||
// Sets the constraints for autolayout
|
||||
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
[NSLayoutConstraint constraintPinSubviewToSuperview:view];
|
||||
return loadingViewController;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)beginningLoading {
|
||||
// Disables the UI when loading
|
||||
self.mainViewController.view.userInteractionEnabled = NO;
|
||||
}
|
||||
|
||||
- (void)finishedLoading {
|
||||
self.mainViewController.view.userInteractionEnabled = YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user