Merge branch 'feature/reviewPopupChanges_v2' into 'release/10_4_0'
Feature/review popup changes v2 ### Summary Implementing a pre-review popup for sentiment analysis before sending the user to either the app store review or Medallia. ### JIRA Ticket https://onejira.verizon.com/browse/ONEAPP-2824 Co-authored-by: Kyle Matthew Hedden <kyle.hedden@verizonwireless.com> See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/902
This commit is contained in:
commit
25b7e74ec0
@ -9,6 +9,41 @@
|
|||||||
|
|
||||||
public extension MVMCoreAlertObject {
|
public extension MVMCoreAlertObject {
|
||||||
|
|
||||||
|
static func alertObject(from alertModel: AlertModel, actions: [UIAlertAction]? = nil, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> MVMCoreAlertObject? {
|
||||||
|
|
||||||
|
let actionsForAlert = actions ?? generateActions(from: alertModel.alertActions, additionalData: additionalData, delegateObject: delegateObject)
|
||||||
|
|
||||||
|
let alertObject = MVMCoreAlertObject(popupAlertWithTitle: alertModel.title,
|
||||||
|
message: alertModel.message,
|
||||||
|
actions: actionsForAlert,
|
||||||
|
isGreedy: false)
|
||||||
|
|
||||||
|
alertObject?.alertStyle = alertModel.style
|
||||||
|
alertObject?.pageJson = alertModel.analyticsData
|
||||||
|
|
||||||
|
return alertObject
|
||||||
|
}
|
||||||
|
|
||||||
|
static func generateActions(from buttonModels: [AlertButtonModel], additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalHandling: ((AlertButtonModel, UIAlertAction)->())? = nil) -> [UIAlertAction] {
|
||||||
|
return buttonModels.map { alertButtonModel in
|
||||||
|
let alertAction = UIAlertAction(title: alertButtonModel.title, style: alertButtonModel.style) { action in
|
||||||
|
Task(priority: .userInitiated) {
|
||||||
|
do {
|
||||||
|
try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(
|
||||||
|
with: alertButtonModel.action,
|
||||||
|
additionalData: additionalData,
|
||||||
|
delegateObject: delegateObject
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
|
||||||
|
}
|
||||||
|
additionalHandling?(alertButtonModel, action)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return alertAction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@objc static func alertObjectWith(action actionJson: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> MVMCoreAlertObject? {
|
@objc static func alertObjectWith(action actionJson: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> MVMCoreAlertObject? {
|
||||||
|
|
||||||
guard let alertJson = actionJson?.optionalDictionaryForKey("alert"),
|
guard let alertJson = actionJson?.optionalDictionaryForKey("alert"),
|
||||||
|
|||||||
@ -25,7 +25,14 @@ open class ActionAlertHandler: MVMCoreJSONActionHandlerProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
|
open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
|
||||||
let json = try MVMCoreActionHandler.convertActionToJSON(model)
|
guard let model = model as? ActionAlertModel else { return }
|
||||||
try await performAction(with: json, model: model, delegateObject: delegateObject, additionalData: additionalData)
|
var error: MVMCoreErrorObject? = nil
|
||||||
|
guard let alertObject = MVMCoreAlertObject.alertObject(from: model.alert, additionalData: additionalData, delegateObject: delegateObject, error: &error) else {
|
||||||
|
throw MVMCoreError.errorObject(error!)
|
||||||
|
}
|
||||||
|
(delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: try MVMCoreActionHandler.convertActionToJSON(model))
|
||||||
|
_ = await MainActor.run {
|
||||||
|
MVMCoreAlertHandler.shared()?.showAlert(with: alertObject)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public class AlertButtonModel: Codable {
|
|||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(_ title: String,_ action: ActionModelProtocol,_ style: UIAlertAction.Style = .default) {
|
public init(_ title: String, _ action: ActionModelProtocol, style: UIAlertAction.Style = .default) {
|
||||||
self.title = title
|
self.title = title
|
||||||
self.action = action
|
self.action = action
|
||||||
self.style = style
|
self.style = style
|
||||||
@ -76,10 +76,11 @@ public class AlertModel: Codable {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(_ title: String,_ message: String,_ alertActions: [AlertButtonModel]) {
|
public init(title: String, message: String, alertActions: [AlertButtonModel], style: UIAlertController.Style = .alert) {
|
||||||
self.title = title
|
self.title = title
|
||||||
self.message = message
|
self.message = message
|
||||||
self.alertActions = alertActions
|
self.alertActions = alertActions
|
||||||
|
self.style = style
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user