Modernization migrations and json passing

This commit is contained in:
Scott Pfeil 2022-07-21 12:39:44 -04:00
parent 768aa578d2
commit 9ea9894e80
7 changed files with 19 additions and 18 deletions

View File

@ -17,7 +17,6 @@
@import MVMCore.NSDictionary_MFConvenience;
@import MVMCore.MVMCoreHardcodedStringsConstants;
@import MVMCore.MVMCoreJSONConstants;
@import MVMCore.MVMCoreActionHandler;
@import MVMCore.Swift;
#import <MVMCoreUI/MVMCoreUI-Swift.h>
@ -162,7 +161,7 @@
NSMutableArray <UIAlertAction *> *actionsForAlert = [NSMutableArray array];
for (NSDictionary *actionMap in actions) {
[actionsForAlert addObject:[UIAlertAction actionWithTitle:[actionMap stringForKey:KeyTitle] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject];
[[MVMCoreUIActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject];
}]];
}
alert.actions = actionsForAlert;

View File

@ -15,12 +15,13 @@ open class ActionAlertHandler: MVMCoreActionHandlerProtocol {
open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
guard let model = model as? ActionAlertModel else { return }
let json = try MVMCoreActionHandler.convertActionToJSON(model)
var error: MVMCoreErrorObject? = nil
guard let alertObject = MVMCoreAlertObject.alertObjectWith(action: json, additionalData: additionalData, delegateObject: delegateObject, error: &error) else {
throw MVMCoreError.errorObject(error!)
try await MVMCoreActionHandler.getOriginalJSON(with: model, additionalData: additionalData) { json, additionalData in
var error: MVMCoreErrorObject? = nil
guard let alertObject = MVMCoreAlertObject.alertObjectWith(action: json, additionalData: additionalData, delegateObject: delegateObject, error: &error) else {
throw MVMCoreError.errorObject(error!)
}
(delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json)
MVMCoreAlertHandler.shared()?.showAlert(with: alertObject)
}
(delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json)
MVMCoreAlertHandler.shared()?.showAlert(with: alertObject)
}
}

View File

@ -15,11 +15,15 @@ open class ActionOpenPanelHandler: MVMCoreActionHandlerProtocol {
open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
guard let model = model as? ActionOpenPanelModel else { return }
switch model.panel {
case .left, .menu:
await MVMCoreUISplitViewController.main()?.showLeftPanel(animated: true)
case .right, .support:
await MVMCoreUISplitViewController.main()?.showRightPanel(animated: true)
try await MVMCoreActionHandler.getOriginalJSON(with: model, additionalData: additionalData) { json, additionalData in
switch model.panel {
case .left, .menu:
await MVMCoreUISplitViewController.main()?.leftPanel?.willOpen?(withActionInformation: json, additionalData: additionalData)
await MVMCoreUISplitViewController.main()?.showLeftPanel(animated: true)
case .right, .support:
await MVMCoreUISplitViewController.main()?.rightPanel?.willOpen?(withActionInformation: json, additionalData: additionalData)
await MVMCoreUISplitViewController.main()?.showRightPanel(animated: true)
}
}
}
}

View File

@ -22,7 +22,7 @@ open class ActionTopAlertHandler: MVMCoreActionHandlerProtocol {
return
}
let alertObject = MVMCoreAlertObject(forPageType: model.pageType, responseInfo: responseInfo, additionalData: additionalData, delegateObject: delegateObject)!
(delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json!)
(delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowTopAlert(with: alertObject, alertJson: json!)
MVMCoreAlertHandler.shared()?.showAlert(with: alertObject)
continuation.resume()
})

View File

@ -21,7 +21,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
#import <MVMCoreUI/MVMCoreUIViewControllerMappingObject.h>
#import <MVMCoreUI/MVMCoreUIViewConstrainingProtocol.h>
#import <MVMCoreUI/MVMCoreUIActionDelegateProtocol.h>
#import <MVMCoreUI/MVMCoreUIActionHandler.h>
// Alert Handling
#import <MVMCoreUI/MVMCoreAlertObject.h>

View File

@ -7,7 +7,6 @@
//
#import "MVMCoreUITopAlertBaseView.h"
@import MVMCore.MVMCoreActionHandler;
#import "MVMCoreUISplitViewController.h"
@import MVMCore.MVMCoreLoadObject;
@import MVMCore.MVMCoreRequestParameters;
@ -33,7 +32,7 @@
}
if (performAction) {
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:[MVMCoreUISession sharedGlobal].topAlertView]];
[[MVMCoreUIActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:[MVMCoreUISession sharedGlobal].topAlertView]];
}
}];
}

View File

@ -22,7 +22,6 @@
@import MVMCore.MVMCoreNavigationHandler;
@import MVMCore.MVMCoreBlockOperation;
#import <MVMCoreUI/MVMCoreAlertObject.h>
@import MVMCore.MVMCoreActionHandler;
#import <MVMCoreUI/MVMCoreAlertHandler.h>
@import MVMCore.NSDictionary_MFConvenience;
@import MVMCore.MVMCoreRequestParameters;