Move navigation controller to navigation handler from core object.

Further decoupling of top alert view and types from core.
Global top alert delegate
Move keyboard functions out of core.
Added ability for action sheets.
Made greedy check, pause, unpause for alerts more proper.
This commit is contained in:
Pfeil, Scott Robert 2018-01-03 13:43:48 -05:00
parent 2bd63258ff
commit cb7241cfc9
26 changed files with 150 additions and 350 deletions

View File

@ -45,8 +45,6 @@
AF43A70B1FC4F415008E9347 /* MVMCoreCache.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A7091FC4F415008E9347 /* MVMCoreCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF43A71B1FC5BEBB008E9347 /* MVMCoreViewControllerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A71A1FC5BEBB008E9347 /* MVMCoreViewControllerProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF43A7201FC5D2BA008E9347 /* MVMCoreViewManagerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A71F1FC5D2BA008E9347 /* MVMCoreViewManagerProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF43A7271FC5E80E008E9347 /* MVMCoreTopAlertView.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A7251FC5E80E008E9347 /* MVMCoreTopAlertView.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF43A7281FC5E80E008E9347 /* MVMCoreTopAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = AF43A7261FC5E80E008E9347 /* MVMCoreTopAlertView.m */; };
AF43A7411FC5FA6F008E9347 /* MVMCoreViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A7401FC5FA6F008E9347 /* MVMCoreViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF43A74C1FC6109F008E9347 /* MVMCoreSessionObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A74A1FC6109F008E9347 /* MVMCoreSessionObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF43A74D1FC6109F008E9347 /* MVMCoreSessionObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AF43A74B1FC6109F008E9347 /* MVMCoreSessionObject.m */; };
@ -109,6 +107,8 @@
AFBB96EB1FBA4A260008D868 /* canned.json in Resources */ = {isa = PBXBuildFile; fileRef = AFBB96E81FBA4A260008D868 /* canned.json */; };
AFBB96EC1FBA4A260008D868 /* MFHardCodedServerResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96E91FBA4A260008D868 /* MFHardCodedServerResponse.h */; };
AFBB96ED1FBA4A260008D868 /* MFHardCodedServerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */; };
AFC5FA161FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFC5FA1D1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFC5FA1C1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFED77A11FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFED77991FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFED77A21FCCA29400BAE689 /* MVMCoreViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFED779A1FCCA29300BAE689 /* MVMCoreViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AFED779B1FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.m */; };
@ -170,8 +170,6 @@
AF43A7091FC4F415008E9347 /* MVMCoreCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreCache.h; sourceTree = "<group>"; };
AF43A71A1FC5BEBB008E9347 /* MVMCoreViewControllerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerProtocol.h; sourceTree = "<group>"; };
AF43A71F1FC5D2BA008E9347 /* MVMCoreViewManagerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewManagerProtocol.h; sourceTree = "<group>"; };
AF43A7251FC5E80E008E9347 /* MVMCoreTopAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertView.h; sourceTree = "<group>"; };
AF43A7261FC5E80E008E9347 /* MVMCoreTopAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreTopAlertView.m; sourceTree = "<group>"; };
AF43A7401FC5FA6F008E9347 /* MVMCoreViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewProtocol.h; sourceTree = "<group>"; };
AF43A74A1FC6109F008E9347 /* MVMCoreSessionObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionObject.h; sourceTree = "<group>"; };
AF43A74B1FC6109F008E9347 /* MVMCoreSessionObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreSessionObject.m; sourceTree = "<group>"; };
@ -235,6 +233,8 @@
AFBB96E81FBA4A260008D868 /* canned.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = canned.json; sourceTree = "<group>"; };
AFBB96E91FBA4A260008D868 /* MFHardCodedServerResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFHardCodedServerResponse.h; sourceTree = "<group>"; };
AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFHardCodedServerResponse.m; sourceTree = "<group>"; };
AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreGlobalTopAlertDelegateProtocol.h; sourceTree = "<group>"; };
AFC5FA1C1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertViewProtocol.h; sourceTree = "<group>"; };
AFED77991FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerNibMappingObject.h; sourceTree = "<group>"; };
AFED779A1FCCA29300BAE689 /* MVMCoreViewControllerMappingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerMappingObject.h; sourceTree = "<group>"; };
AFED779B1FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreViewControllerNibMappingObject.m; sourceTree = "<group>"; };
@ -347,8 +347,6 @@
children = (
88D1FBE01FCCCB2C00338A3A /* PanelProtocol.h */,
88D1FBDF1FCCCADC00338A3A /* MVMCoreMainSplitViewProtocol.h */,
AF43A7251FC5E80E008E9347 /* MVMCoreTopAlertView.h */,
AF43A7261FC5E80E008E9347 /* MVMCoreTopAlertView.m */,
);
path = MainStructure;
sourceTree = "<group>";
@ -382,6 +380,7 @@
AF43A7401FC5FA6F008E9347 /* MVMCoreViewProtocol.h */,
AFEEE8181FCDDE6B00B5EDD0 /* MVMCoreLoggingDelegateProtocol.h */,
AF43A7001FC4B227008E9347 /* MVMCoreGlobalLoadProtocol.h */,
AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */,
);
path = MainProtocols;
sourceTree = "<group>";
@ -485,6 +484,7 @@
AFBB96831FBA3A9A0008D868 /* MVMCoreAlertOperation.m */,
AFBB96841FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h */,
AFBB96851FBA3A9A0008D868 /* MVMCoreTopAlertDelegateProtocol.h */,
AFC5FA1C1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h */,
AFBB96861FBA3A9A0008D868 /* MVMCoreTopAlertObject.h */,
AFBB96871FBA3A9A0008D868 /* MVMCoreTopAlertObject.m */,
AFBB96881FBA3A9A0008D868 /* MVMCoreTopAlertOperation.h */,
@ -599,7 +599,6 @@
88D1FBE21FCCCBA500338A3A /* PanelProtocol.h in Headers */,
AFBB968D1FBA3A9A0008D868 /* MVMCoreNavigationHandler.h in Headers */,
AFBB96A51FBA3A9A0008D868 /* MVMCoreTopAlertOperation.h in Headers */,
AF43A7271FC5E80E008E9347 /* MVMCoreTopAlertView.h in Headers */,
AFBB96A11FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */,
AFBB96951FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h in Headers */,
AFED77A51FCCA29400BAE689 /* MVMCoreViewControllerProgrammaticMappingObject.h in Headers */,
@ -612,6 +611,7 @@
AFBB965A1FBA3A570008D868 /* FreeBeeUrlObject.h in Headers */,
AF43A71B1FC5BEBB008E9347 /* MVMCoreViewControllerProtocol.h in Headers */,
AFBB96571FBA3A570008D868 /* FreeBeeAuthObject.h in Headers */,
AFC5FA161FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */,
AFBB96381FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h in Headers */,
AFBB96B01FBA3B590008D868 /* MVMCoreDispatchUtility.h in Headers */,
8876D5E81FB50AB000EB2E3D /* NSArray+MFConvenience.h in Headers */,
@ -622,6 +622,7 @@
AF43A5771FBA5B7C008E9347 /* MVMCoreJSONConstants.h in Headers */,
88D1FBE11FCCCBA100338A3A /* MVMCoreMainSplitViewProtocol.h in Headers */,
AFBB96631FBA3A570008D868 /* MVMCoreLoadRequestOperation.h in Headers */,
AFC5FA1D1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h in Headers */,
AFBB969D1FBA3A9A0008D868 /* MVMCoreAlertObject.h in Headers */,
8876D5CE1FB50A9E00EB2E3D /* MVMCore.h in Headers */,
AFBB965E1FBA3A570008D868 /* MFFreebeeOperation.h in Headers */,
@ -719,7 +720,6 @@
AFED77A71FCCA29400BAE689 /* MVMCoreViewControllerProgrammaticMappingObject.m in Sources */,
AFBB96A01FBA3A9A0008D868 /* MVMCoreAlertOperation.m in Sources */,
AFBB96641FBA3A570008D868 /* MVMCoreLoadHandler.m in Sources */,
AF43A7281FC5E80E008E9347 /* MVMCoreTopAlertView.m in Sources */,
AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */,
AFBB968E1FBA3A9A0008D868 /* MVMCoreNavigationHandler.m in Sources */,
AFBB96991FBA3A9A0008D868 /* MVMCoreAlertController.m in Sources */,

View File

@ -264,7 +264,9 @@ NSString * const KeyActionTypeOpen = @"openPage";
- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
// Collapse the current notification.
[[MVMCoreObject sharedInstance].topAlertView collapseNotification];
if ([[MVMCoreObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) {
[[[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView] collapseNotification];
}
}
- (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {

View File

@ -11,6 +11,7 @@
#import <UIKit/UIKit.h>
#import <MVMCore/MVMCoreActionDelegateProtocol.h>
#import <MVMCore/MVMCoreTopAlertObject.h>
#import <MVMCore/MVMCoreAlertDelegateProtocol.h>
@class MVMCoreAlertObject;
@ -27,7 +28,7 @@
// Returns if a greedy alert is currently showing (even if supressed).
- (BOOL)greedyAlertShowing;
/** Shows the popup with the passed in parameter. This is a convenience method that automatically handles using the proper alert type based on what's available.
/** Shows the popup with the passed in parameter.
* @param title The title of the alert.
* @param message The message of the alert.
* @param actions An array of actions for the alert.
@ -36,6 +37,17 @@
*/
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy;
/** Shows the alert.
* @param title The title of the alert.
* @param message The message of the alert.
* @param actions An array of actions for the alert.
* @param alertStyle Popup or action sheet
* @param isGreedy Sets up a greedy alert. In other words, any alerts currently shown or queued are dismissed.
* @param alertDelegate The delegate to be notified.
* @return Returns the UIAlertController.
*/
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject <MVMCoreAlertDelegateProtocol>*)alertDelegate;
/** Shows the popup with the passed in alert object. This is a convenience method that automatically handles using the proper alert type based on what's available.
* @param alertObject The alert object to use for the alert.
* @return Returns UIAlertController.
@ -64,24 +76,19 @@
// Convenience functions
- (void)showTopAlertErrorWithMessage:(nullable NSString *)message;
- (void)showTopAlertConfirmationWithMessage:(nullable NSString *)message;
- (void)showTopAlertWithType:(MFTopType)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData;
- (void)showTopAlertWithType:(MFTopType)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler;
- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData;
- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler;
// Hides the current alert view.
- (void)hideTopAlertView;
// Hides a persistent alert based on the type string.
- (void)hidePersistentTopAlertViewOfType:(MFTopType)type;
- (void)hidePersistentTopAlertViewOfTypeString:(nullable NSString *)type;
- (void)hidePersistentTopAlertViewOfType:(nullable NSString *)type;
// Removes all top alerts.
- (void)removeAllTopAlerts;
// Returns a top type based on type string and vice versa
+ (MFTopType)topTypeForString:(nullable NSString *)type;
+ (nonnull NSString *)stringForTopType:(MFTopType)type;
/// Returns YES if the persistent type is already registered in the alert queue.
- (BOOL)hasPersistentTopAlertOfType:(MFTopType)type;
- (BOOL)hasPersistentTopAlertOfType:(nullable NSString *)type;
@end

View File

@ -58,7 +58,18 @@
}
- (BOOL)greedyAlertShowing {
return [self alertCurrentlyShowing] && ((MVMCoreAlertOperation *)self.popupAlertQueue.operations[0]).isGreedy;
if ([self alertCurrentlyShowing]) {
NSInteger index = [self.popupAlertQueue.operations indexOfObjectPassingTest:^BOOL(__kindof MVMCoreAlertOperation * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.isExecuting && obj.isGreedy && stop) {
*stop = YES;
return YES;
} else {
return NO;
}
}];
return (index != NSNotFound);
}
return NO;
}
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy {
@ -66,6 +77,10 @@
}
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject <MVMCoreAlertDelegateProtocol>*)alertDelegate {
return [self showAlertWithTitle:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate];
}
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject <MVMCoreAlertDelegateProtocol>*)alertDelegate {
// It's a greedy alert! Clear all alerts that are queued up and the one that is showing
if (isGreedy) {
@ -73,7 +88,7 @@
}
// Create the alert. Adds the actions one by one.
MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:UIAlertControllerStyleAlert];
MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle];
for (NSUInteger i = 0; i < [actions count]; i++) {
UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]];
if (action) {
@ -87,7 +102,7 @@
}
- (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject {
return [self showAlertWithTitle:alertObject.title message:alertObject.message actions:alertObject.actions isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate];
return [self showAlertWithTitle:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate];
}
- (void)removeAllAlertViews {
@ -103,10 +118,9 @@
- (void)supressMFAlerts {
if (!self.mfAlertsSupressed) {
self.mfAlertsSupressed = YES;
if ([self alertCurrentlyShowing]) {
[((MVMCoreAlertOperation *)self.popupAlertQueue.operations[0]) pause];
for (MVMCoreAlertOperation *operation in self.popupAlertQueue.operations) {
[operation pause];
}
for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) {
[operation pause];
}
@ -116,10 +130,9 @@
- (void)unSupressMFAlerts {
if (self.mfAlertsSupressed) {
self.mfAlertsSupressed = NO;
if ([self alertCurrentlyShowing]) {
[((MVMCoreAlertOperation *)self.popupAlertQueue.operations[0]) unpause];
for (MVMCoreAlertOperation *operation in self.popupAlertQueue.operations) {
[operation unpause];
}
for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) {
[operation unpause];
}
@ -130,7 +143,6 @@
- (void)showTopAlertWithObject:(nullable MVMCoreTopAlertObject *)topAlertObject {
// Don't add the operation if there is currently a clear spot top alert and it is of the same type
if (topAlertObject) {
__block MVMCoreTopAlertOperation *alertOperation = [[MVMCoreTopAlertOperation alloc] initWithTopAlertObject:topAlertObject];
@ -158,23 +170,23 @@
- (void)showTopAlertErrorWithMessage:(nullable NSString *)message {
MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:MFTopTypeError message:message];
MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:ValueTypeError message:message];
[self showTopAlertWithObject:topAlertObject];
}
- (void)showTopAlertConfirmationWithMessage:(nullable NSString *)message {
MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:MFTopTypeConfirmation message:message];
MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:ValueTypeSuccess message:message];
[self showTopAlertWithObject:topAlertObject];
}
- (void)showTopAlertWithType:(MFTopType)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData {
- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData {
MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:type message:message subMessage:subMessage persistent:persistent actionMap:actionMap additionalData:additionalData];
[self showTopAlertWithObject:topAlertObject];
}
- (void)showTopAlertWithType:(MFTopType)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler {
- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler {
MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:type message:message subMessage:subMessage persistent:persistent buttonTitle:buttonTitle userActionHandler:userActionHandler];
[self showTopAlertWithObject:topAlertObject];
@ -188,22 +200,17 @@
[currentOperation cancel];
}
- (BOOL)hasPersistentTopAlertOfType:(MFTopType)type {
- (BOOL)hasPersistentTopAlertOfType:(nullable NSString *)type {
BOOL hasAlert = NO;
NSString *stringType = [MVMCoreAlertHandler stringForTopType:type];
for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) {
if (operation.topAlertObject.persistent && [operation.topAlertObject.type isEqualToString:stringType]) {
if (operation.topAlertObject.persistent && [operation.topAlertObject.type isEqualToString:type]) {
hasAlert = YES;
}
}
return hasAlert;
}
- (void)hidePersistentTopAlertViewOfType:(MFTopType)type {
[self hidePersistentTopAlertViewOfTypeString:[MVMCoreAlertHandler stringForTopType:type]];
}
- (void)hidePersistentTopAlertViewOfTypeString:(nullable NSString *)type {
- (void)hidePersistentTopAlertViewOfType:(nullable NSString *)type {
if (type) {
for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) {
@ -220,69 +227,4 @@
[self.topAlertQueue cancelAllOperations];
}
+ (MFTopType)topTypeForString:(nullable NSString *)type {
if ([ValueTypeSuccess isEqualToString:type]) {
return MFTopTypeConfirmation;
} else if ([ValueTypeError isEqualToString:type]) {
return MFTopTypeError;
} else if ([ValueTypeSurvivalMode isEqualToString:type]) {
return MFTopTypeSurvival;
} else if ([ValueTypeClearSpotMain isEqualToString:type]) {
return MFTopTypeClearspotMain;
} else if ([ValueTypeClearSpotEnded isEqualToString:type]) {
return MFTopTypeClearspotFinished;
} else if ([ValueTypeClearSpotProcessing isEqualToString:type]) {
return MFTopTypeClearspotProcessing;
} else if ([ValueTypeLiveChat isEqualToString:type]) {
return MFTopTypeAgentChatInSession;
} else if ([ValueTypeFamilyBaseChild isEqualToString:type]) {
return MFTopTypeFamilyBaseChild;
} else if ([ValueTypeRetailShop isEqualToString:type]) {
return MFTopTypeShop;
} else if ([ValueTypeRemoteIn isEqualToString:type]) {
return MFTopTypeRemoteIn;
} else {
return MFTopTypeOther;
}
}
+ (NSString *)stringForTopType:(MFTopType)type {
switch (type) {
case MFTopTypeConfirmation:
return ValueTypeSuccess;
break;
case MFTopTypeError:
return ValueTypeError;
break;
case MFTopTypeSurvival:
return ValueTypeSurvivalMode;
break;
case MFTopTypeClearspotMain:
return ValueTypeClearSpotMain;
break;
case MFTopTypeClearspotFinished:
return ValueTypeClearSpotEnded;
break;
case MFTopTypeClearspotProcessing:
return ValueTypeClearSpotProcessing;
break;
case MFTopTypeAgentChatInSession:
return ValueTypeLiveChat;
break;
case MFTopTypeFamilyBaseChild:
return ValueTypeFamilyBaseChild;
break;
case MFTopTypeShop:
return ValueTypeRetailShop;
break;
case MFTopTypeRemoteIn:
return ValueTypeRemoteIn;
break;
default:
return @"Other";
break;
}
}
@end

View File

@ -31,6 +31,7 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors);
@property (nullable, strong, nonatomic) NSString *message;
@property (nonnull, strong, nonatomic) NSArray *actions;
@property (nonatomic) BOOL isGreedy;
@property (nonatomic) UIAlertControllerStyle alertStyle;
@property (nonatomic) MFAlertType type;
@property (nonnull, strong, nonatomic) NSArray *fieldErrors;

View File

@ -69,6 +69,7 @@
// Perform a popup.
alert.type = MFAlertTypePopup;
alert.alertStyle = UIAlertControllerStyleAlert;
// Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button).
NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"];
@ -94,6 +95,7 @@
// Default to popup
alert.type = MFAlertTypePopup;
alert.alertStyle = UIAlertControllerStyleAlert;
}
}
return alert;
@ -106,6 +108,7 @@
self.actions = actions;
self.isGreedy = isGreedy;
self.type = MFAlertTypePopup;
self.alertStyle = UIAlertControllerStyleAlert;
}
return self;
}
@ -118,6 +121,7 @@
self.actions = @[[UIAlertAction actionWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedOK] style:UIAlertActionStyleDefault handler:nil]];
self.isGreedy = isGreedy;
self.type = MFAlertTypePopup;
self.alertStyle = UIAlertControllerStyleAlert;
}
return self;
}
@ -130,6 +134,7 @@
self.actions = actions;
self.isGreedy = isGreedy;
self.type = MFAlertTypePopup;
self.alertStyle = UIAlertControllerStyleAlert;
}
return self;
}
@ -141,6 +146,7 @@
alert.message = [page stringForKey:KeyMessage];
alert.isGreedy = isGreedy;
alert.type = MFAlertTypePopup;
alert.alertStyle = UIAlertControllerStyleAlert;
NSArray <NSDictionary *> *actions = [page array:KeyLinks];
NSMutableArray <UIAlertAction *> *actionsForAlert = [NSMutableArray array];

View File

@ -9,23 +9,6 @@
#import <Foundation/Foundation.h>
#import <MVMCore/MVMCoreTopAlertDelegateProtocol.h>
#warning Scott, Drive this from protocol.
typedef NS_ENUM(NSInteger, MFTopType) {
MFTopTypeError,
MFTopTypeConfirmation,
MFTopTypeSurvival,
MFTopTypeShop,
MFTopTypeBlueWithButton,
MFTopTypeClearspotMain,
MFTopTypeClearspotFinished,
MFTopTypeClearspotProcessing,
MFTopTypeRemoteIn,
MFTopTypeAgentChatInSession,
MFTopTypeFamilyBaseChild,
MFTopTypeRewardAlert,
MFTopTypeOther
};
extern NSUInteger const TopAlertDismissTime;
@interface MVMCoreTopAlertObject : NSObject
@ -63,10 +46,10 @@ extern NSUInteger const TopAlertDismissTime;
- (nullable instancetype)initWithResponseInfo:(nullable NSDictionary *)responseInfo;
- (nullable instancetype)initWithType:(MFTopType)type message:(nullable NSString *)message;
- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message;
- (nullable instancetype)initWithType:(MFTopType)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData;
- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData;
- (nullable instancetype)initWithType:(MFTopType)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler;
- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler;
@end

View File

@ -48,15 +48,15 @@ NSUInteger const TopAlertDismissTime = 5;
return self;
}
- (nullable instancetype)initWithType:(MFTopType)type message:(nullable NSString *)message {
- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message {
return [self initWithType:type message:nil subMessage:message persistent:NO actionMap:nil additionalData:nil];
}
- (nullable instancetype)initWithType:(MFTopType)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData {
- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData {
if (self = [super init]) {
self.type = [MVMCoreAlertHandler stringForTopType:type];
self.type = type;
self.persistent = persistent;
self.title = message;
@ -67,11 +67,11 @@ NSUInteger const TopAlertDismissTime = 5;
return self;
}
- (nullable instancetype)initWithType:(MFTopType)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler {
- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler {
if (self = [super init]) {
self.type = [MVMCoreAlertHandler stringForTopType:type];
self.type = type;
self.persistent = persistent;
self.title = message;

View File

@ -10,7 +10,6 @@
#import "MVMCoreTopAlertObject.h"
#import "MVMCoreAlertHandler.h"
#import "MVMCoreObject.h"
#import "MVMCoreTopAlertView.h"
#import "MVMCoreSessionObject.h"
@interface MVMCoreTopAlertOperation () {
@ -56,35 +55,7 @@
self.topAlertObject = topAlertObject;
// Sets the queue priority for various types of alerts.
switch ([MVMCoreAlertHandler topTypeForString:topAlertObject.type]) {
case MFTopTypeSurvival:
self.queuePriority = NSOperationQueuePriorityVeryLow;
break;
case MFTopTypeShop:
self.queuePriority = NSOperationQueuePriorityLow;
break;
case MFTopTypeClearspotProcessing:
self.queuePriority = NSOperationQueuePriorityNormal;
break;
case MFTopTypeClearspotMain:
self.queuePriority = NSOperationQueuePriorityNormal;
break;
case MFTopTypeAgentChatInSession:
self.queuePriority = NSOperationQueuePriorityHigh - 1;
case MFTopTypeRemoteIn:
self.queuePriority = NSOperationQueuePriorityHigh;
break;
case MFTopTypeFamilyBaseChild:
self.queuePriority = NSOperationQueuePriorityHigh + 1;
break;
default:
if (topAlertObject.persistent) {
self.queuePriority = NSOperationQueuePriorityVeryHigh - 1;
} else {
self.queuePriority = NSOperationQueuePriorityVeryHigh;
}
break;
}
self.queuePriority = [[MVMCoreObject sharedInstance].globalTopAlertDelegate priorityForTopAlertByObject:topAlertObject];
}
return self;
}
@ -159,12 +130,13 @@
if (![[MVMCoreAlertHandler sharedAlertHandler] mfAlertsSupressed]) {
// Show
if (![MVMCoreObject sharedInstance].topAlertView) {
if (![[MVMCoreObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) {
// Needs to be a top alert view....
[self markAsFinished];
} else {
[[MVMCoreObject sharedInstance].topAlertView showWithTopAlertObject:self.topAlertObject animationDelegate:self completionHandler:^(BOOL finished) {
UIView <MVMCoreTopAlertViewProtocol>*topAlertView = [[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView];
[topAlertView showWithTopAlertObject:self.topAlertObject animationDelegate:self completionHandler:^(BOOL finished) {
self.displayed = YES;
if (self.isCancelled) {
@ -225,7 +197,7 @@
if (self.isDisplayed && !self.isAnimating) {
// Dismisses.
[[MVMCoreObject sharedInstance].topAlertView hideAlertView:^(BOOL finished) {
[[[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView] hideAlertView:^(BOOL finished) {
self.displayed = NO;
if (andFinish) {

View File

@ -0,0 +1,25 @@
//
// MVMCoreTopAlertViewProtocol.h
// MVMCore
//
// Created by Pfeil, Scott Robert on 1/2/18.
// Copyright © 2018 myverizon. All rights reserved.
//
#import <MVMCore/MVMCoreTopAlertAnimationDelegateProtocol.h>
@class MVMCoreTopAlertObject;
@protocol MVMCoreTopAlertViewProtocol
@optional
// Show based on the object
- (void)showWithTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id <MVMCoreTopAlertAnimationDelegateProtocol>)animationDelegate completionHandler:(void (^ __nullable)(BOOL finished))completionHandler;
// Hides
- (void)hideAlertView:(void (^ __nullable)(BOOL finished))completionHandler;
// Collapses the notification if it has a short top message. Otherwise removes notification.
- (void)collapseNotification;
@end

View File

@ -57,15 +57,6 @@ extern NSString * const ValueTypeError;
extern NSString * const ValueTypeFieldErrors;
extern NSString * const ValueTypeErrorScreen;
extern NSString * const ValueTypeRedirect;
#warning Scott, Drive these from protocol
extern NSString * const ValueTypeSurvivalMode;
extern NSString * const ValueTypeClearSpotMain;
extern NSString * const ValueTypeClearSpotEnded;
extern NSString * const ValueTypeClearSpotProcessing;
extern NSString * const ValueTypeLiveChat;
extern NSString * const ValueTypeFamilyBaseChild;
extern NSString * const ValueTypeRetailShop;
extern NSString * const ValueTypeRemoteIn;
// Server driven message style.
extern NSString * const ValueMessageStylePopup;

View File

@ -57,15 +57,6 @@ NSString * const ValueTypeError = @"GlobalError";
NSString * const ValueTypeFieldErrors = @"FieldErrors";
NSString * const ValueTypeErrorScreen = @"ErrorScreen";
NSString * const ValueTypeRedirect = @"Redirect";
#warning Scott, drive these from protocol.
NSString * const ValueTypeSurvivalMode = @"SurvivalMode";
NSString * const ValueTypeClearSpotMain = @"ClearSpotTopAlertMain";
NSString * const ValueTypeClearSpotEnded = @"ClearSpotTopAlertEnded";
NSString * const ValueTypeClearSpotProcessing = @"ClearSpotProcessing";
NSString * const ValueTypeLiveChat = @"ChatTop";
NSString * const ValueTypeFamilyBaseChild = @"FamilyBaseChild";
NSString * const ValueTypeRetailShop = @"RetailShop";
NSString * const ValueTypeRemoteIn = @"RemoteIn";
// Server driven message style.
NSString * const ValueMessageStylePopup = @"Popup";

View File

@ -366,7 +366,7 @@
loadObject.responseInfoMap = [jsonDictionary dict:KeyResponseInfo];
// Dismiss any top alerts that server wants us to dismiss
[[MVMCoreAlertHandler sharedAlertHandler] hidePersistentTopAlertViewOfTypeString:[loadObject.responseInfoMap string:@"disableType"]];
[[MVMCoreAlertHandler sharedAlertHandler] hidePersistentTopAlertViewOfType:[loadObject.responseInfoMap string:@"disableType"]];
// Adds the modules received from server to any modules we grabbed from the cache.
NSDictionary *modules = [jsonDictionary dict:KeyModuleMap];

View File

@ -45,8 +45,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[];
// Main Structure
#import <MVMCore/MVMCoreMainSplitViewProtocol.h>
#import <MVMCore/PanelProtocol.h>
#import <MVMCore/MVMCoreTopAlertView.h>
// Load Handling
#import <MVMCore/MVMCoreLoadDelegateProtocol.h>
@ -66,6 +64,8 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[];
#import <MVMCore/MVMCoreAlertHandler.h>
#import <MVMCore/MVMCoreTopAlertAnimationDelegateProtocol.h>
#import <MVMCore/MVMCoreTopAlertDelegateProtocol.h>
#import <MVMCore/MVMCoreGlobalTopAlertDelegateProtocol.h>
#import <MVMCore/MVMCoreTopAlertViewProtocol.h>
#import <MVMCore/MVMCoreAlertDelegateProtocol.h>
// Presentation Handling

View File

@ -0,0 +1,21 @@
//
// MVMCoreGlobalTopAlertDelegateProtocol.h
// MVMCore
//
// Created by Pfeil, Scott Robert on 1/2/18.
// Copyright © 2018 myverizon. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <MVMCore/MVMCoreTopAlertViewProtocol.h>
@class MVMCoreTopAlertObject;
@protocol MVMCoreGlobalTopAlertDelegateProtocol <NSObject>
- (NSOperationQueuePriority)priorityForTopAlertByObject:(nonnull MVMCoreTopAlertObject *)object;
@optional
- (nonnull UIView <MVMCoreTopAlertViewProtocol>*)getTopAlertView;
@end

View File

@ -7,7 +7,7 @@
//
#import <MVMCore/PanelProtocol.h>
#import <MVMCore/MVMCoreTopAlertView.h>
#import <MVMCore/MVMCoreViewControllerProtocol.h>
@protocol MVMCoreMainSplitViewProtocol<NSObject>
@ -15,9 +15,4 @@
- (nullable UIViewController <MVMCoreViewControllerProtocol,PanelProtocol> *)getLeftPanel;
- (nullable UIViewController <MVMCoreViewControllerProtocol,PanelProtocol> *)getRightPanel;
@optional
// Provides the top alert view to use.
- (nullable MVMCoreTopAlertView *)getTopAlertView;
@end

View File

@ -1,33 +0,0 @@
//
// MVMCoreTopAlertView.h
// MVMCore
//
// Created by Pfeil, Scott Robert on 11/22/17.
// Copyright © 2017 myverizon. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <MVMCore/MVMCoreViewProtocol.h>
#import <MVMCore/MVMCoreTopAlertAnimationDelegateProtocol.h>
#import <MVMCore/MVMCoreTopAlertObject.h>
@interface MVMCoreTopAlertView : UIView <MVMCoreViewProtocol>
// Delegate for the top alert view
@property (nonatomic, nullable, weak) id <MVMCoreTopAlertAnimationDelegateProtocol> animationDelegate;
// Current top alert object
@property (strong, nullable, nonatomic) MVMCoreTopAlertObject *topAlertObject;
- (void)pinATopViewController:(nonnull UIViewController *)viewController;
// Show based on the object
- (void)showWithTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id <MVMCoreTopAlertAnimationDelegateProtocol>)animationDelegate completionHandler:(void (^ __nullable)(BOOL finished))completionHandler;
// Hides
- (void)hideAlertView:(void (^ __nullable)(BOOL finished))completionHandler;
// Collapses the notification if it has a short top message. Otherwise removes notification.
- (void)collapseNotification;
@end

View File

@ -1,44 +0,0 @@
//
// MVMCoreTopAlertView.m
// MVMCore
//
// Created by Pfeil, Scott Robert on 11/22/17.
// Copyright © 2017 myverizon. All rights reserved.
//
#import "MVMCoreTopAlertView.h"
@implementation MVMCoreTopAlertView
- (instancetype)init {
if (self = [super init]) {
[self setupView];
}
return self;
}
- (void)setupView {
self.clipsToBounds = YES;
}
- (void)pinATopViewController:(UIViewController *)viewController {
}
- (void)updateView:(CGFloat)size {
}
- (void)showWithTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id <MVMCoreTopAlertAnimationDelegateProtocol>)animationDelegate completionHandler:(void (^ __nullable)(BOOL finished))completionHandler {
self.animationDelegate = animationDelegate;
self.topAlertObject = topAlertObject;
completionHandler(NO);
}
- (void)hideAlertView:(void (^ __nullable)(BOOL finished))completionHandler {
completionHandler(NO);
}
- (void)collapseNotification {
}
@end

View File

@ -21,6 +21,10 @@
// Can set the view controller to present on... will use MF if nil.
@property (nullable, nonatomic, weak) UIViewController *viewControllerToPresentOn;
// reference to main navigation controller
@property (nullable, weak, nonatomic) UINavigationController *navigationController;
// Will navigate appropriately based on the load style
- (void)navigateWithLoadObject:(nullable MVMCoreLoadObject *)loadObject viewController:(nonnull UIViewController *)viewController delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock;

View File

@ -264,18 +264,21 @@
- (void)presentViewController:(nonnull UIViewController *)viewController animated:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock {
// Present on the main navigation controller.
MVMCorePresentViewControllerOperation *operation = [[MVMCorePresentViewControllerOperation alloc] initWithPresentingViewController:(self.viewControllerToPresentOn ?: [MVMCoreObject sharedInstance].navigationController) presentedViewController:viewController animated:animated];
operation.delegate = delegate;
operation.completionBlock = completionBlock;
[self.presentationQueue addOperation:operation];
if (!self.viewControllerToPresentOn) {
NSException *exception = [NSException exceptionWithName:@"NoViewControllerToPresentOnException" reason:@"The viewControllerToPresent on property is nil and an attempt was made to present." userInfo:nil];
@throw exception;
} else {
MVMCorePresentViewControllerOperation *operation = [[MVMCorePresentViewControllerOperation alloc] initWithPresentingViewController:self.viewControllerToPresentOn presentedViewController:viewController animated:animated];
operation.delegate = delegate;
operation.completionBlock = completionBlock;
[self.presentationQueue addOperation:operation];
}
}
- (void)dismissTopViewControllerAnimated:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock {
// Dismiss on the main navigation controller.
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissTopViewController:[MVMCoreObject sharedInstance].navigationController animated:animated];
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissTopViewController:self.navigationController animated:animated];
operation.completionBlock = completionBlock;
[[NSOperationQueue mainQueue] addOperation:operation];
}
@ -290,7 +293,7 @@
- (void)dismissToBottom:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock {
// Dismiss on the main navigation controller.
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissViewController:[MVMCoreObject sharedInstance].navigationController animated:animated];
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissViewController:self.navigationController animated:animated];
operation.completionBlock = completionBlock;
[[NSOperationQueue mainQueue] addOperation:operation];
}

View File

@ -7,7 +7,7 @@
//
#import "MVMCoreNavigationObject.h"
#import "MVMCoreObject.h"
#import "MVMCoreNavigationHandler.h"
@implementation MVMCoreNavigationObject
@ -16,7 +16,7 @@
self.viewController = viewController;
UINavigationController *navigationToUse = navigationController ?: [MVMCoreObject sharedInstance].navigationController;
UINavigationController *navigationToUse = navigationController ?: [MVMCoreNavigationHandler sharedNavigationHandler].navigationController;
self.navigationController = navigationToUse;
self.viewControllers = viewControllers;

View File

@ -13,7 +13,6 @@
#import "MVMCoreLoadHandler.h"
#import "MVMCoreLoadingOverlayHandler.h"
#import "MVMCoreGetterUtility.h"
#import "MVMCoreJSONConstants.h"
#import "MVMCoreErrorConstants.h"
#import "MVMCoreErrorObject.h"
#import "MVMCoreRequestParameters.h"

View File

@ -16,6 +16,7 @@
#import <MVMCore/MVMCoreLoadingOverlayDelegateProtocol.h>
#import <MVMCore/MVMCoreMainSplitViewProtocol.h>
#import <MVMCore/MVMCoreLoggingDelegateProtocol.h>
#import <MVMCore/MVMCoreGlobalTopAlertDelegateProtocol.h>
@interface MVMCoreObject : NSObject
@ -25,17 +26,12 @@
@property (nullable, strong, nonatomic) MVMCoreActionHandler *actionHandler;
@property (nullable, strong, nonatomic) MVMCoreSessionTimeHandler *sessionHandler;
// reference to main navigation controller
@property (nullable, weak, nonatomic) UINavigationController *navigationController;
// Reference to the top alert view
@property (nullable, weak, nonatomic) MVMCoreTopAlertView *topAlertView;
// The delegates
@property (nullable, weak, nonatomic) NSObject <MVMCoreMainSplitViewProtocol> *splitViewDelegate;
@property (nullable, weak, nonatomic) id <MVMCoreGlobalLoadProtocol> globalLoadDelegate;
@property (nullable, weak, nonatomic) id <MVMCoreLoadingOverlayDelegateProtocol> loadingProtocol;
@property (nullable, weak, nonatomic) id <MVMCoreLoggingDelegateProtocol> loggingDelegate;
@property (nullable, weak, nonatomic) id <MVMCoreGlobalTopAlertDelegateProtocol> globalTopAlertDelegate;
// A singleton.
+ (nullable instancetype)sharedInstance;

View File

@ -11,14 +11,11 @@
@implementation MVMCoreObject
+ (nullable instancetype)sharedInstance {
static dispatch_once_t once;
static id sharedInstance;
dispatch_once(&once, ^
{
sharedInstance = [[self alloc] init];
});
dispatch_once(&once, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}

View File

@ -23,19 +23,4 @@
// Can call to display a view controller based on the load object in the same way the architecture does it. Will check the presentation style of the page, action, and request. Will check if needs a view manager.
+ (void)displayViewController:(nonnull UIViewController <MVMCoreViewControllerProtocol> *)viewController forLoadObject:(nullable MVMCoreLoadObject *)loadObject presentationDelegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock;
#pragma mark - keyboard
/** Handles setting the content inset for a passed in scroll view.
* @param notification pass in the notification from the UIKeyboardWillShowNotification.
* @param scrollView the scroll view to set the content inset.
* @param viewController Pass in the main view that the scroll view is in for calculations.
* @param rectToScrollTo Pass in a block that returns the rectangle. **/
+ (void)setScrollViewInsetForKeyboardShow:(nonnull NSNotification *)notification scrollView:(nonnull UIScrollView *)scrollView viewController:(nonnull UIViewController *)viewController rectToScrollTo:(nonnull CGRect (^)(void))rectToScrollTo;
/** Handles setting the content inset for a passed in scroll view.
* @param notification pass in the notification from the UIKeyboardWillShowNotification.
* @param scrollView the scroll view to set the content inset.
* @param contentInset The pre-keyboard inset to set after hiding. **/
+ (void)setScrollViewInsetForKeyboardHide:(nonnull NSNotification *)notification scrollView:(nonnull UIScrollView *)scrollView viewController:(nonnull UIViewController *)viewController contentInset:(UIEdgeInsets)contentInset;
@end

View File

@ -137,47 +137,4 @@
[[MVMCoreNavigationHandler sharedNavigationHandler] navigateWithLoadObject:loadObject viewController:(viewControllerToLoad ?: viewController) delegate:delegate completionHandler:completionBlock];
}
#pragma mark - keyboard
+ (void)setScrollViewInsetForKeyboardShow:(nonnull NSNotification *)notification scrollView:(nonnull UIScrollView *)scrollView viewController:(nonnull UIViewController *)viewController rectToScrollTo:(nonnull CGRect (^)(void))rectToScrollTo {
NSDictionary *info = [notification userInfo];
CGRect keyboardRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
// Gets the scrollview end point in the window coordinate space to see if the keyboard will cover the scroll view at all. (This conversion allows the scrollview to be anyhwere in the hierarchy).
CGPoint scrollEndPointInWindowSpace = [[UIApplication sharedApplication].keyWindow convertPoint:CGPointMake(CGRectGetMinX(scrollView.frame), CGRectGetMaxY(scrollView.frame)) fromView:[scrollView superview]];
// Also takes into account the current content inset. (Even if the keyboard covers the frame, it might not matter if the bottom content inset is set to above the keyboard anyway).
if (scrollEndPointInWindowSpace.y - scrollView.contentInset.bottom > CGRectGetMinY(keyboardRect)) {
// Sets the scrollview insets to account for the portion covered by the keyboard (as apposed to changing the frame size).
UIEdgeInsets contentInsets = UIEdgeInsetsMake(scrollView.contentInset.top, scrollView.contentInset.left, scrollEndPointInWindowSpace.y - CGRectGetMinY(keyboardRect), scrollView.contentInset.right);
scrollView.contentInset = contentInsets;
scrollView.scrollIndicatorInsets = contentInsets;
}
// Looks smoother if animated
[UIView animateWithDuration:[[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue] delay:0 options:[[notification.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue] animations:^{
// Gets the field view rect in the scroll view coordinate space and scrolls to it. (This conversion allows the field to be anyhwere in the scrollviews subview hierarchy).
CGRect fieldRectInScrollViewSpace = rectToScrollTo();
[scrollView scrollRectToVisible:fieldRectInScrollViewSpace animated:YES];
[viewController updateViewConstraints];
[viewController.view layoutIfNeeded];
} completion:NULL];
}
+ (void)setScrollViewInsetForKeyboardHide:(nonnull NSNotification *)notification scrollView:(nonnull UIScrollView *)scrollView viewController:(nonnull UIViewController *)viewController contentInset:(UIEdgeInsets)contentInset {
[UIView animateWithDuration:[[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue] delay:0 options:[[notification.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue] animations:^{
// Go back to how it was before the user touched a text field.
scrollView.contentInset = contentInset;
scrollView.scrollIndicatorInsets = contentInset;
[viewController updateViewConstraints];
[viewController.view layoutIfNeeded];
} completion:NULL];
}
@end