Merge branch 'develop' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/viewInRoomArAtomicTemplate
This commit is contained in:
commit
ce77f7dacc
@ -160,7 +160,7 @@ import Foundation
|
||||
|
||||
/// Collapse if focus is no longer on this top alert.
|
||||
@objc func accessibilityFocusChanged(notification: Notification) {
|
||||
if !MVMCoreUIUtility.viewContainsAccessiblityFocus(self) {
|
||||
if (notification.userInfo?[UIAccessibility.focusedElementUserInfoKey] != nil) && !MVMCoreUIUtility.viewContainsAccessiblityFocus(self) {
|
||||
NotificationCenter.default.removeObserver(self, name: UIAccessibility.elementFocusedNotification, object: nil)
|
||||
collapse()
|
||||
}
|
||||
|
||||
@ -8,6 +8,21 @@
|
||||
|
||||
|
||||
open class NotificationModel: MoleculeModelProtocol {
|
||||
|
||||
/**
|
||||
The style of the notification:
|
||||
- success, green background, white content
|
||||
- error, orange background, black content
|
||||
- \warning, yellow background, black content
|
||||
- information, blue background, white content
|
||||
*/
|
||||
public enum Style: String, Codable {
|
||||
case success
|
||||
case error
|
||||
case warning
|
||||
case information
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
@ -19,6 +34,7 @@ open class NotificationModel: MoleculeModelProtocol {
|
||||
public var body: LabelModel?
|
||||
public var button: ButtonModel?
|
||||
public var closeButton: NotificationXButtonModel?
|
||||
public var style: NotificationModel.Style = .success
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
@ -34,20 +50,63 @@ open class NotificationModel: MoleculeModelProtocol {
|
||||
|
||||
open func setDefault() {
|
||||
if backgroundColor == nil {
|
||||
backgroundColor = Color(uiColor: .mvmGreen)
|
||||
switch style {
|
||||
case .error:
|
||||
backgroundColor = Color(uiColor: .mvmOrange)
|
||||
case .warning:
|
||||
backgroundColor = Color(uiColor: .mvmYellow)
|
||||
case .information:
|
||||
backgroundColor = Color(uiColor: .mvmBlue)
|
||||
default:
|
||||
backgroundColor = Color(uiColor: .mvmGreen)
|
||||
}
|
||||
}
|
||||
if headline.textColor == nil {
|
||||
headline.textColor = Color(uiColor: .mvmWhite)
|
||||
switch style {
|
||||
case .error, .warning:
|
||||
headline.textColor = Color(uiColor: .mvmBlack)
|
||||
default:
|
||||
headline.textColor = Color(uiColor: .mvmWhite)
|
||||
}
|
||||
}
|
||||
if body?.textColor == nil {
|
||||
body?.textColor = Color(uiColor: .mvmWhite)
|
||||
switch style {
|
||||
case .error, .warning:
|
||||
body?.textColor = Color(uiColor: .mvmBlack)
|
||||
default:
|
||||
body?.textColor = Color(uiColor: .mvmWhite)
|
||||
}
|
||||
}
|
||||
|
||||
button?.size = .tiny
|
||||
if button?.enabledTextColor == nil {
|
||||
switch style {
|
||||
case .error, .warning:
|
||||
button?.enabledTextColor = Color(uiColor: .mvmBlack)
|
||||
default:
|
||||
button?.enabledTextColor = Color(uiColor: .mvmWhite)
|
||||
}
|
||||
}
|
||||
if button?.enabledBorderColor == nil {
|
||||
switch style {
|
||||
case .error, .warning:
|
||||
button?.enabledBorderColor = Color(uiColor: .mvmBlack)
|
||||
default:
|
||||
button?.enabledBorderColor = Color(uiColor: .mvmWhite)
|
||||
}
|
||||
}
|
||||
if button?.style == nil {
|
||||
button?.style = .secondary
|
||||
}
|
||||
button?.size = .tiny
|
||||
button?.enabledTextColor = Color(uiColor: .mvmWhite)
|
||||
button?.enabledBorderColor = Color(uiColor: .mvmWhite)
|
||||
|
||||
if closeButton?.color == nil {
|
||||
switch style {
|
||||
case .error, .warning:
|
||||
closeButton?.color = Color(uiColor: .mvmBlack)
|
||||
default:
|
||||
closeButton?.color = Color(uiColor: .mvmWhite)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -62,6 +121,7 @@ open class NotificationModel: MoleculeModelProtocol {
|
||||
case body
|
||||
case button
|
||||
case closeButton
|
||||
case style
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -76,6 +136,9 @@ open class NotificationModel: MoleculeModelProtocol {
|
||||
body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
|
||||
button = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .button)
|
||||
closeButton = try typeContainer.decodeIfPresent(NotificationXButtonModel.self, forKey: .closeButton)
|
||||
if let style = try typeContainer.decodeIfPresent(NotificationModel.Style.self, forKey: .style) {
|
||||
self.style = style
|
||||
}
|
||||
setDefault()
|
||||
}
|
||||
|
||||
@ -88,5 +151,6 @@ open class NotificationModel: MoleculeModelProtocol {
|
||||
try container.encodeIfPresent(body, forKey: .body)
|
||||
try container.encodeIfPresent(button, forKey: .button)
|
||||
try container.encodeIfPresent(closeButton, forKey: .closeButton)
|
||||
try container.encode(style, forKey: .style)
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ import Foundation
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
guard let model = model as? NotificationXButtonModel else { return }
|
||||
tintColor = model.color.uiColor
|
||||
tintColor = model.color?.uiColor ?? .white
|
||||
|
||||
// TODO: Temporary, consider action for dismissing top alert
|
||||
if model.action.actionType == ActionNoopModel.identifier {
|
||||
|
||||
@ -11,7 +11,7 @@ import Foundation
|
||||
public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
||||
public static var identifier: String = "notificationXButton"
|
||||
public var backgroundColor: Color?
|
||||
public var color = Color(uiColor: .white)
|
||||
public var color: Color?
|
||||
public var action: ActionModelProtocol = ActionNoopModel()
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
@ -24,7 +24,7 @@ public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtoco
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) ?? Color(uiColor: .white)
|
||||
color = try typeContainer.decodeIfPresent(Color.self, forKey: .color)
|
||||
if let action: ActionModelProtocol = try typeContainer.decodeModelIfPresent(codingKey: .action) {
|
||||
self.action = action
|
||||
}
|
||||
@ -33,7 +33,7 @@ public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtoco
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encode(color, forKey: .color)
|
||||
try container.encodeIfPresent(color, forKey: .color)
|
||||
try container.encodeModel(action, forKey: .action)
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol, ParentMolecule
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
||||
headline = try typeContainer.decodeMoleculeIfPresent(codingKey: .headline)
|
||||
body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
|
||||
body = try typeContainer.decodeMoleculeIfPresent(codingKey: .body)
|
||||
link = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .link)
|
||||
setDefaults()
|
||||
// TODO: This class initializers should ensure that atleast one item is set.
|
||||
|
||||
@ -423,7 +423,7 @@
|
||||
}
|
||||
|
||||
- (void)accessibilityFocusChanged:(NSNotification *)notification {
|
||||
if (![MVMCoreUIUtility viewContainsAccessiblityFocus:self]) {
|
||||
if (notification.userInfo[UIAccessibilityFocusedElementKey] && ![MVMCoreUIUtility viewContainsAccessiblityFocus:self]) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityElementFocusedNotification object:nil];
|
||||
[self collapse];
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
|
||||
|
||||
/// If the voice over user leaves top alert focus, hide.
|
||||
- (void)accessibilityFocusChanged:(NSNotification *)notification {
|
||||
if (![MVMCoreUIUtility viewContainsAccessiblityFocus:self]) {
|
||||
if (notification.userInfo[UIAccessibilityFocusedElementKey] && ![MVMCoreUIUtility viewContainsAccessiblityFocus:self]) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityElementFocusedNotification object:nil];
|
||||
[self hideAlertView:YES completionHandler:self.hideCompletionHandler];
|
||||
self.hideCompletionHandler = nil;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user