meginf develop

This commit is contained in:
Kevin G Christiano 2021-01-04 09:34:21 -05:00
commit 3578eb9194
5 changed files with 57 additions and 24 deletions

View File

@ -12,7 +12,8 @@ import Foundation
public static var identifier: String = "topAlert"
public var actionType: String = ActionTopAlertModel.identifier
public var pageType: String
public var pageType: String?
public var topNotification: TopNotificationModel?
public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary?
@ -21,4 +22,10 @@ import Foundation
self.extraParameters = extraParameters
self.analyticsData = analyticsData
}
public init(topNotification: TopNotificationModel, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
self.topNotification = topNotification
self.extraParameters = extraParameters
self.analyticsData = analyticsData
}
}

View File

@ -9,12 +9,12 @@
import Foundation
@objcMembers public class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol {
@objcMembers open class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String {
open override class var identifier: String {
return "carouselItem"
}
@ -44,7 +44,7 @@ import Foundation
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
open override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(peakingUI, forKey: .peakingUI)

View File

@ -9,7 +9,7 @@
import Foundation
/// A model for a collection item that is a container for any molecule.
@objcMembers public class MoleculeCollectionItemModel: MoleculeContainerModel, CollectionItemModelProtocol {
@objcMembers open class MoleculeCollectionItemModel: MoleculeContainerModel, CollectionItemModelProtocol {
open override class var identifier: String {
return "collectionItem"
}

View File

@ -81,18 +81,28 @@
- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
// Perform a top alert.
NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType];
[[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo];
if (responseInfo) {
MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject];
if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) {
[((id <MVMCoreUIActionDelegateProtocol>)delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation];
NSString *pageTypeForTopAlert = [actionInformation string:KeyPageType];
if (pageTypeForTopAlert) {
[[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo];
if (responseInfo) {
MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject];
if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) {
[((id <MVMCoreUIActionDelegateProtocol>)delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation];
}
[alertObject showAlert];
}
[alertObject showAlert];
}];
} else {
NSDictionary *topNotification = [actionInformation dict:@"topNotification"];
if (topNotification) {
[[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification];
} else {
MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeTopAlert]];
[self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject];
}
}];
}
}
- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
@ -152,17 +162,27 @@
- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
// Perform a top alert.
NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType];
[[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo];
if (responseInfo) {
MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate];
if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) {
alertObject = [((id <MVMCoreUIActionDelegateProtocol>)delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary];
if (pageTypeForTopAlert) {
[[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo];
if (responseInfo) {
MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate];
if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) {
alertObject = [((id <MVMCoreUIActionDelegateProtocol>)delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary];
}
[alertObject showAlert];
}
[alertObject showAlert];
}];
} else {
NSDictionary *topNotification = [actionInformation dict:@"topNotification"];
if (topNotification) {
[[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification];
} else {
MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeTopAlert]];
[self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate];
}
}];
}
}
- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {

View File

@ -61,6 +61,12 @@ public extension MVMCoreUITopAlertView {
MVMCoreAlertHandler.shared()?.add(operation)
}
/// Shows the top alert with the json.
@objc func showTopAlert(with json: [AnyHashable: Any]) {
guard let model = decodeTopNotification(with: json, delegateObject: getDelegateObject()) else { return }
showTopAlert(with: model)
}
/// Checks for existing top alert object of same type and updates it. Only happens for molecular top alerts. Returns true if we updated.
private func checkAndUpdateExisting(with topAlertObject: MVMCoreTopAlertObject) -> Bool {
guard let queue = MVMCoreAlertHandler.shared()?.topAlertQueue.operations else { return false }