Merge pull request #39 in BPHVB/mvm_core from bugfix/popup_track to release/6_8

* commit 'b8374bee5ff7dcde3f29a09f63bd6d156d4ffdf1':
  fix delegate nil
  instance method in core logging delegate protocol
  remove unused page type
  changes to the way popup delegacy works
  proper marking of delegate
  add tracking to alert protocol
  pass controller instead
  remove space
  revert
  revert and change slightly
  remove pageType in document
  remove alertPageType property
  fixes
  alert handler takes alert object
  fix warning
  adobe track alert
This commit is contained in:
Yang, Tianhang (Chris) 2018-10-30 18:30:43 -04:00
commit 7b44fcaf5a
10 changed files with 28 additions and 3 deletions

View File

@ -219,7 +219,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo];
if (responseInfo) { if (responseInfo) {
MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate];
if ([delegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) {
alertObject = [delegate willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; alertObject = [delegate willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary];
} }
[alertObject showAlert]; [alertObject showAlert];

View File

@ -8,9 +8,11 @@
// Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler. // Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler.
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class MVMCoreAlertObject;
@interface MVMCoreAlertController : UIAlertController @interface MVMCoreAlertController : UIAlertController
@property (nonatomic, readonly, getter=isVisible) BOOL visible; @property (nonatomic, readonly, getter=isVisible) BOOL visible;
@property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject;
@end @end

View File

@ -7,6 +7,7 @@
// //
#import "MVMCoreAlertController.h" #import "MVMCoreAlertController.h"
#import "MVMCoreLoggingHandler.h"
@interface MVMCoreAlertController () @interface MVMCoreAlertController ()
@ -22,6 +23,7 @@
[self willChangeValueForKey:@"isVisible"]; [self willChangeValueForKey:@"isVisible"];
self.visible = YES; self.visible = YES;
[self didChangeValueForKey:@"isVisible"]; [self didChangeValueForKey:@"isVisible"];
[MVMCoreLoggingHandler logAlertForAlertController:self];
} }
- (void)viewDidDisappear:(BOOL)animated { - (void)viewDidDisappear:(BOOL)animated {

View File

@ -8,11 +8,15 @@
// Called for popup style alerts. // Called for popup style alerts.
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@class MVMCoreAlertObject;
@protocol MVMCoreAlertDelegateProtocol @protocol MVMCoreAlertDelegateProtocol
@optional @optional
// helps tracking alert state
- (nullable NSDictionary *)additionalAlertDataToTrackForAlertWithObject:(nullable MVMCoreAlertObject *)alertObject;
// All are performed on the main thread. // All are performed on the main thread.
- (void)alertShown:(nonnull UIAlertController *)alertController; - (void)alertShown:(nonnull UIAlertController *)alertController;
- (void)alertCancelled:(nonnull UIAlertController *)alertController; - (void)alertCancelled:(nonnull UIAlertController *)alertController;

View File

@ -102,7 +102,9 @@
} }
- (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject { - (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject {
return [self showAlertWithTitle:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; MVMCoreAlertController *controller = (MVMCoreAlertController *)[self showAlertWithTitle:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate];
controller.alertObject = alertObject;
return controller;
} }
- (void)removeAllAlertViews { - (void)removeAllAlertViews {

View File

@ -28,6 +28,7 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors);
@interface MVMCoreAlertObject : NSObject @interface MVMCoreAlertObject : NSObject
@property (nullable, strong, nonatomic) NSString *title; @property (nullable, strong, nonatomic) NSString *title;
@property (nullable, copy, nonatomic) NSDictionary *pageJson;
@property (nullable, strong, nonatomic) NSString *message; @property (nullable, strong, nonatomic) NSString *message;
@property (nonnull, strong, nonatomic) NSArray *actions; @property (nonnull, strong, nonatomic) NSArray *actions;
@property (nonatomic) BOOL isGreedy; @property (nonatomic) BOOL isGreedy;

View File

@ -71,7 +71,7 @@
// Perform a popup. // Perform a popup.
alert.type = MFAlertTypePopup; alert.type = MFAlertTypePopup;
alert.alertStyle = UIAlertControllerStyleAlert; 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). // 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"]; NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"];
[[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
@ -99,6 +99,7 @@
alert.alertStyle = UIAlertControllerStyleAlert; alert.alertStyle = UIAlertControllerStyleAlert;
} }
} }
alert.alertDelegate = actionDelegate;
return alert; return alert;
} }
@ -145,6 +146,7 @@
MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init];
alert.title = [page stringForKey:KeyTitle]; alert.title = [page stringForKey:KeyTitle];
alert.pageJson = page;
alert.message = [page stringForKey:KeyMessage]; alert.message = [page stringForKey:KeyMessage];
alert.isGreedy = isGreedy; alert.isGreedy = isGreedy;
alert.type = MFAlertTypePopup; alert.type = MFAlertTypePopup;

View File

@ -7,6 +7,7 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class MVMCoreAlertController;
@protocol MVMCoreLoggingDelegateProtocol <NSObject> @protocol MVMCoreLoggingDelegateProtocol <NSObject>
@ -24,4 +25,7 @@
// Log that the load has finished. // Log that the load has finished.
- (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController error:(nullable MVMCoreErrorObject *)error; - (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController error:(nullable MVMCoreErrorObject *)error;
// Log alert
- (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController;
@end @end

View File

@ -10,6 +10,7 @@
#import <MVMCore/MVMCoreErrorObject.h> #import <MVMCore/MVMCoreErrorObject.h>
#import <MVMCore/MVMCoreViewControllerProtocol.h> #import <MVMCore/MVMCoreViewControllerProtocol.h>
#import <MVMCore/MVMCoreLoadObject.h> #import <MVMCore/MVMCoreLoadObject.h>
@class MVMCoreAlertController;
#define MVMCoreLog(fmt, ...) \ #define MVMCoreLog(fmt, ...) \
[MVMCoreLoggingHandler logDebugMessageWithDelegate:[NSString stringWithFormat:(@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__]]; [MVMCoreLoggingHandler logDebugMessageWithDelegate:[NSString stringWithFormat:(@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__]];
@ -20,5 +21,6 @@
+ (void)logDebugMessageWithDelegate:(nullable NSString *)message; + (void)logDebugMessageWithDelegate:(nullable NSString *)message;
+ (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra; + (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra;
+ (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController error:(nullable MVMCoreErrorObject *)error; + (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController error:(nullable MVMCoreErrorObject *)error;
+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController;
@end @end

View File

@ -35,5 +35,11 @@
} }
} }
+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController {
if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertController:)]) {
[[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertController:alertController];
}
}
@end @end