Merge branch 'develop' into feature/viewInRoomArAtomicTemplate
This commit is contained in:
commit
ca0d35dd96
@ -290,6 +290,7 @@
|
||||
BBC0C4FF24811DCA0087C44F /* TagModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBC0C4FE24811DCA0087C44F /* TagModel.swift */; };
|
||||
C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; };
|
||||
C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; };
|
||||
C6687441259D92D400F32D13 /* ActionTopNotificationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */; };
|
||||
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; };
|
||||
C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; };
|
||||
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; };
|
||||
@ -833,6 +834,7 @@
|
||||
BBC0C4FE24811DCA0087C44F /* TagModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagModel.swift; sourceTree = "<group>"; };
|
||||
C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
|
||||
C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = "<group>"; };
|
||||
C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopNotificationModel.swift; sourceTree = "<group>"; };
|
||||
C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = "<group>"; };
|
||||
C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = "<group>"; };
|
||||
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = "<group>"; };
|
||||
@ -1308,6 +1310,7 @@
|
||||
D2ED27E9254B0CE600A1C293 /* ActionAlertModel.swift */,
|
||||
D2ED27EA254B0CE700A1C293 /* AlertModel.swift */,
|
||||
D2ED27E8254B0CE600A1C293 /* ActionPopupModel.swift */,
|
||||
C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */,
|
||||
);
|
||||
path = Actions;
|
||||
sourceTree = "<group>";
|
||||
@ -2432,6 +2435,7 @@
|
||||
32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */,
|
||||
D2CAC7CF2511052300C75681 /* CollapsableNotificationModel.swift in Sources */,
|
||||
DBC4391822442197001AB423 /* CaretView.swift in Sources */,
|
||||
C6687441259D92D400F32D13 /* ActionTopNotificationModel.swift in Sources */,
|
||||
C07065C42395677300FBF997 /* Link.swift in Sources */,
|
||||
0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */,
|
||||
D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */,
|
||||
|
||||
24
MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift
Normal file
24
MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// ActionTopNotificationModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 31/12/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers public class ActionTopNotificationModel: ActionModelProtocol {
|
||||
|
||||
public static var identifier: String = "topNotification"
|
||||
public var actionType: String = ActionTopNotificationModel.identifier
|
||||
public var topNotification: TopNotificationModel
|
||||
public var extraParameters: JSONValueDictionary?
|
||||
public var analyticsData: JSONValueDictionary?
|
||||
|
||||
public init(topNotification: TopNotificationModel, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
||||
self.topNotification = topNotification
|
||||
self.extraParameters = extraParameters
|
||||
self.analyticsData = analyticsData
|
||||
}
|
||||
}
|
||||
@ -79,8 +79,6 @@ import UIKit
|
||||
heightConstraint = heightAnchor.constraint(equalTo: widthAnchor, multiplier: 1)
|
||||
heightConstraint?.isActive = true
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = .button
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
@ -89,6 +87,8 @@ import UIKit
|
||||
self.additionalData = additionalData
|
||||
guard let model = model as? HeartModel else { return }
|
||||
isSelected = model.isActive
|
||||
isEnabled = model.enabled
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -96,11 +96,13 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
/// Adjust accessibility label based on selection of Heart.
|
||||
func updateAccessibilityLabel() {
|
||||
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_unfavorite_action_hint" : "heart_favorite_action_hint")
|
||||
accessibilityHint = isEnabled ? MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_unfavorite_action_hint" : "heart_favorite_action_hint") : nil
|
||||
accessibilityTraits = isEnabled ? .button : .none
|
||||
accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_selected_state" : "heart_not_selected_state")
|
||||
}
|
||||
|
||||
func tapAction() {
|
||||
guard isEnabled else { return }
|
||||
isSelected = !isSelected
|
||||
if let heartModel = heartModel {
|
||||
Button.performButtonAction(with: heartModel.action, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: heartModel)
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
open class HeartModel: MoleculeModelProtocol {
|
||||
open class HeartModel: MoleculeModelProtocol, EnableableModelProtocol {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
@ -19,6 +19,7 @@ open class HeartModel: MoleculeModelProtocol {
|
||||
public var activeColor: Color = Color(uiColor: .mvmRed)
|
||||
public var inActiveColor: Color = Color(uiColor: .clear)
|
||||
public var action: ActionModelProtocol = ActionNoopModel()
|
||||
public var enabled: Bool = true
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Keys
|
||||
@ -30,6 +31,7 @@ open class HeartModel: MoleculeModelProtocol {
|
||||
case activeColor
|
||||
case inActiveColor
|
||||
case action
|
||||
case enabled
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -51,6 +53,9 @@ open class HeartModel: MoleculeModelProtocol {
|
||||
if let action: ActionModelProtocol = try typeContainer.decodeModelIfPresent(codingKey: .action) {
|
||||
self.action = action
|
||||
}
|
||||
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||
self.enabled = enabled
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -61,5 +66,6 @@ open class HeartModel: MoleculeModelProtocol {
|
||||
try container.encode(activeColor, forKey: .activeColor)
|
||||
try container.encode(inActiveColor, forKey: .inActiveColor)
|
||||
try container.encodeModel(action, forKey: .action)
|
||||
try container.encode(enabled, forKey: .enabled)
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,9 +351,13 @@ public typealias ActionBlock = () -> ()
|
||||
} else {
|
||||
imageAttachment = Label.getTextAttachmentImage(name: imageName, dimension: fontSize)
|
||||
}
|
||||
let mutableString = NSMutableAttributedString()
|
||||
mutableString.append(NSAttributedString(attachment: imageAttachment))
|
||||
attributedString.insert(mutableString, at: imageAtt.location)
|
||||
|
||||
// Confirm that the intended image location is within range.
|
||||
if 0...labelText.count ~= imageAtt.location {
|
||||
let mutableString = NSMutableAttributedString()
|
||||
mutableString.append(NSAttributedString(attachment: imageAttachment))
|
||||
attributedString.insert(mutableString, at: imageAtt.location)
|
||||
}
|
||||
|
||||
case let fontAtt as LabelAttributeFontModel:
|
||||
if let fontStyle = fontAtt.style {
|
||||
|
||||
@ -20,6 +20,10 @@ public extension UIDatePicker {
|
||||
let locale = NSLocale.current as NSLocale
|
||||
datePicker.locale = locale as Locale
|
||||
datePicker.calendar = locale.object(forKey: .calendar) as? Calendar
|
||||
//To support old style wheel
|
||||
if #available(iOS 13.4, *) {
|
||||
datePicker.preferredDatePickerStyle = .wheels
|
||||
}
|
||||
textField.inputView = datePicker
|
||||
|
||||
return datePicker
|
||||
@ -30,6 +34,10 @@ public extension UIDatePicker {
|
||||
let datePicker = UIDatePicker()
|
||||
datePicker.backgroundColor = .mvmWhite
|
||||
datePicker.datePickerMode = .time
|
||||
//To support old style wheel
|
||||
if #available(iOS 13.4, *) {
|
||||
datePicker.preferredDatePickerStyle = .wheels
|
||||
}
|
||||
textField.inputView = datePicker
|
||||
|
||||
return datePicker
|
||||
|
||||
@ -259,6 +259,7 @@ import Foundation
|
||||
try? ModelRegistry.register(ActionTopAlertModel.self)
|
||||
try? ModelRegistry.register(ActionCollapseNotificationModel.self)
|
||||
try? ModelRegistry.register(ActionOpenPanelModel.self)
|
||||
try? ModelRegistry.register(ActionTopNotificationModel.self)
|
||||
|
||||
// MARK:- Behaviors
|
||||
try? ModelRegistry.register(ScreenBrightnessModifierBehavior.self)
|
||||
|
||||
@ -42,8 +42,6 @@
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
horizontalStack.restack()
|
||||
accessibilityHint = heart.accessibilityHint
|
||||
accessibilityTraits = heart.accessibilityTraits
|
||||
}
|
||||
|
||||
public override func updateView(_ size: CGFloat) {
|
||||
@ -123,20 +121,40 @@
|
||||
}
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
if let accessoryView = accessoryView {
|
||||
// Both caret and heart.
|
||||
let hasHeart = !(horizontalStack.stackModel?.molecules[1].gone ?? true)
|
||||
if let accessoryView = accessoryView,
|
||||
hasHeart {
|
||||
// Both accessory and heart actions.
|
||||
isAccessibilityElement = false
|
||||
accessoryView.accessibilityLabel = getAccessibilityMessage()
|
||||
accessibilityElements = [accessoryView, heart]
|
||||
} else {
|
||||
// Make whole cell focusable if no action.
|
||||
isAccessibilityElement = true
|
||||
if let message = getAccessibilityMessage(),
|
||||
let heartLabel = heart.accessibilityLabel {
|
||||
accessibilityLabel = message + ", " + heartLabel
|
||||
var message = getAccessibilityMessage()
|
||||
if hasHeart {
|
||||
accessibilityHint = heart.accessibilityHint
|
||||
if let heartLabel = heart.accessibilityLabel {
|
||||
message = (message ?? "") + ", " + heartLabel
|
||||
}
|
||||
} else {
|
||||
accessibilityLabel = getAccessibilityMessage()
|
||||
accessibilityHint = nil
|
||||
}
|
||||
accessibilityLabel = message
|
||||
}
|
||||
}
|
||||
|
||||
// Ensures voice over does not read "selected" after user triggers action on cell.
|
||||
override public var accessibilityTraits: UIAccessibilityTraits {
|
||||
get {
|
||||
if (accessoryView != nil) {
|
||||
return .button
|
||||
} else if (!(horizontalStack.stackModel?.molecules[1].gone ?? true)) {
|
||||
return heart.accessibilityTraits
|
||||
} else {
|
||||
return .none
|
||||
}
|
||||
}
|
||||
set {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol {
|
||||
//--------------------------------------------------
|
||||
|
||||
public static var identifier = "listStoreLocator"
|
||||
public var heart: HeartModel
|
||||
public var heart: HeartModel?
|
||||
public var leftHeadline: LabelModel
|
||||
public var leftBody: LabelModel
|
||||
public var leftSubBody: LabelModel
|
||||
@ -22,7 +22,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol {
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
public init(heart: HeartModel, leftHeadline: LabelModel, leftBody: LabelModel, leftSubBody: LabelModel, rightLabel: LabelModel) {
|
||||
public init(heart: HeartModel?, leftHeadline: LabelModel, leftBody: LabelModel, leftSubBody: LabelModel, rightLabel: LabelModel) {
|
||||
self.heart = heart
|
||||
self.leftHeadline = leftHeadline
|
||||
self.leftBody = leftBody
|
||||
@ -59,7 +59,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol {
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
heart = try typeContainer.decode(HeartModel.self, forKey:.heart)
|
||||
heart = try typeContainer.decodeIfPresent(HeartModel.self, forKey:.heart)
|
||||
leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline)
|
||||
leftBody = try typeContainer.decode(LabelModel.self, forKey: .leftBody)
|
||||
leftSubBody = try typeContainer.decode(LabelModel.self, forKey: .leftSubBody)
|
||||
@ -71,7 +71,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol {
|
||||
try super.encode(to: encoder)
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encode(heart, forKey: .heart)
|
||||
try container.encodeIfPresent(heart, forKey: .heart)
|
||||
try container.encode(leftHeadline, forKey: .leftHeadline)
|
||||
try container.encode(leftBody, forKey: .leftBody)
|
||||
try container.encode(leftSubBody, forKey: .leftSubBody)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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"
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule
|
||||
|
||||
public var image: String
|
||||
public var action: ActionModelProtocol
|
||||
public var accessibilityText: String?
|
||||
|
||||
public init(with image: String, action: ActionModelProtocol) {
|
||||
self.image = image
|
||||
@ -23,12 +24,14 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule
|
||||
case image
|
||||
case action
|
||||
case moleculeName
|
||||
case accessibilityText
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
image = try typeContainer.decode(String.self, forKey: .image)
|
||||
action = try typeContainer.decodeModel(codingKey: .action)
|
||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||
}
|
||||
|
||||
open func encode(to encoder: Encoder) throws {
|
||||
@ -36,11 +39,17 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule
|
||||
try container.encode(image, forKey: .image)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeModel(action, forKey: .action)
|
||||
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||
}
|
||||
|
||||
/// Convenience function that creates a BarButtonItem for the model.
|
||||
public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem {
|
||||
let uiImage = MVMCoreCache.shared()?.getImageFromRegisteredBundles(image)
|
||||
return ImageBarButtonItem.create(with: uiImage, actionModel: action, delegateObject: delegateObject, additionalData: additionalData)
|
||||
let navigationImageButton = ImageBarButtonItem.create(with: uiImage, actionModel: action, delegateObject: delegateObject, additionalData: additionalData)
|
||||
if let accessibilityString = accessibilityText {
|
||||
navigationImageButton.accessibilityLabel = accessibilityString
|
||||
navigationImageButton.isAccessibilityElement = true
|
||||
}
|
||||
return navigationImageButton
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,21 +12,24 @@ import Foundation
|
||||
public override class var identifier: String {
|
||||
return "numberedList"
|
||||
}
|
||||
public var numberColor: Color
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case backgroundColor
|
||||
case list
|
||||
case numberColor
|
||||
}
|
||||
|
||||
// Numbered list model comes in the from of list = [MoleculeModelProtocol]
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
|
||||
numberColor = try typeContainer.decodeIfPresent(Color.self, forKey: .numberColor) ?? Color(uiColor: .mvmBlack)
|
||||
let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list)
|
||||
var models: [MoleculeStackItemModel] = []
|
||||
for (index, molecule) in list.enumerated() {
|
||||
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule)))
|
||||
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, stringColor: numberColor)))
|
||||
}
|
||||
super.init(molecules: models, spacing: 0)
|
||||
}
|
||||
@ -41,6 +44,7 @@ import Foundation
|
||||
models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule)
|
||||
}
|
||||
try container.encodeModels(models, forKey: .list)
|
||||
try container.encode(numberColor, forKey: .numberColor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13,10 +13,12 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
||||
public var backgroundColor: Color?
|
||||
public var string: String
|
||||
public var molecule: MoleculeModelProtocol
|
||||
|
||||
public init(string: String, molecule: MoleculeModelProtocol) {
|
||||
public var stringColor: Color
|
||||
|
||||
public init(string: String, molecule: MoleculeModelProtocol, stringColor: Color = Color(uiColor: .mvmBlack)) {
|
||||
self.string = string
|
||||
self.molecule = molecule
|
||||
self.stringColor = stringColor
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
@ -24,6 +26,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
||||
case backgroundColor
|
||||
case string
|
||||
case molecule
|
||||
case stringColor
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
@ -31,6 +34,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
string = try typeContainer.decode(String.self, forKey: .string)
|
||||
molecule = try typeContainer.decodeModel(codingKey: .molecule)
|
||||
stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) ?? Color(uiColor: .mvmBlack)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -39,5 +43,6 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
||||
try container.encode(string, forKey: .string)
|
||||
try container.encodeModel(molecule, forKey: .molecule)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encode(stringColor, forKey: .stringColor)
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +84,7 @@ open class StringAndMoleculeView: View {
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
guard let model = model as? StringAndMoleculeModel else { return }
|
||||
label.text = model.string
|
||||
label.textColor = model.stringColor.uiColor
|
||||
molecule.set(with: model.molecule, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
|
||||
@ -13,12 +13,14 @@ import Foundation
|
||||
return "unOrderedList"
|
||||
}
|
||||
public var bulletChar = "•"
|
||||
|
||||
public var bulletColor: Color
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case backgroundColor
|
||||
case list
|
||||
case bulletChar
|
||||
case bulletColor
|
||||
}
|
||||
|
||||
// Numbered list model comes in the from of list = [MoleculeModelProtocol]
|
||||
@ -28,10 +30,11 @@ import Foundation
|
||||
self.bulletChar = bulletChar
|
||||
}
|
||||
|
||||
bulletColor = try typeContainer.decodeIfPresent(Color.self, forKey: .bulletColor) ?? Color(uiColor: .mvmBlack)
|
||||
let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list)
|
||||
var models: [MoleculeStackItemModel] = []
|
||||
for molecule in list {
|
||||
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule)))
|
||||
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, stringColor: bulletColor)))
|
||||
}
|
||||
super.init(molecules: models, spacing: 0)
|
||||
}
|
||||
@ -47,5 +50,6 @@ import Foundation
|
||||
models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule)
|
||||
}
|
||||
try container.encodeModels(models, forKey: .list)
|
||||
try container.encode(bulletColor, forKey: .bulletColor)
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ import Foundation
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeModelsIfPresent(molecules, forKey: .molecules)
|
||||
try container.encode(line, forKey: .line)
|
||||
try container.encode(scrollToRowIndex, forKey: .scrollToRowIndex)
|
||||
try container.encodeIfPresent(scrollToRowIndex, forKey: .scrollToRowIndex)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class UICollectionViewLeftAlignedLayout: UICollectionViewFlowLayout {
|
||||
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
|
||||
public class UICollectionViewLeftAlignedLayout: UICollectionViewFlowLayout {
|
||||
public override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
|
||||
guard let attributes = super.layoutAttributesForElements(in: rect) else { return nil }
|
||||
var newAttributesForElementsInRect = [UICollectionViewLayoutAttributes]()
|
||||
for attribute in attributes {
|
||||
|
||||
@ -15,9 +15,9 @@ open class Container: View, ContainerProtocol {
|
||||
//--------------------------------------------------
|
||||
|
||||
public var view: UIView?
|
||||
let containerHelper = ContainerHelper()
|
||||
public let containerHelper = ContainerHelper()
|
||||
|
||||
var containerModel: ContainerModelProtocol? {
|
||||
public var containerModel: ContainerModelProtocol? {
|
||||
get { return model as? ContainerModelProtocol }
|
||||
}
|
||||
|
||||
|
||||
@ -15,23 +15,23 @@ open class ContainerHelper: NSObject {
|
||||
// MARK: - Constraints
|
||||
//--------------------------------------------------
|
||||
|
||||
var leftConstraint: NSLayoutConstraint?
|
||||
var topConstraint: NSLayoutConstraint?
|
||||
var bottomConstraint: NSLayoutConstraint?
|
||||
var rightConstraint: NSLayoutConstraint?
|
||||
open var leftConstraint: NSLayoutConstraint?
|
||||
open var topConstraint: NSLayoutConstraint?
|
||||
open var bottomConstraint: NSLayoutConstraint?
|
||||
open var rightConstraint: NSLayoutConstraint?
|
||||
|
||||
var alignCenterHorizontalConstraint: NSLayoutConstraint?
|
||||
var alignCenterLeftConstraint: NSLayoutConstraint?
|
||||
var alignCenterRightConstraint: NSLayoutConstraint?
|
||||
open var alignCenterHorizontalConstraint: NSLayoutConstraint?
|
||||
open var alignCenterLeftConstraint: NSLayoutConstraint?
|
||||
open var alignCenterRightConstraint: NSLayoutConstraint?
|
||||
|
||||
var alignCenterVerticalConstraint: NSLayoutConstraint?
|
||||
var alignCenterTopConstraint: NSLayoutConstraint?
|
||||
var alignCenterBottomConstraint: NSLayoutConstraint?
|
||||
open var alignCenterVerticalConstraint: NSLayoutConstraint?
|
||||
open var alignCenterTopConstraint: NSLayoutConstraint?
|
||||
open var alignCenterBottomConstraint: NSLayoutConstraint?
|
||||
|
||||
var leftLowConstraint: NSLayoutConstraint?
|
||||
var topLowConstraint: NSLayoutConstraint?
|
||||
var bottomLowConstraint: NSLayoutConstraint?
|
||||
var rightLowConstraint: NSLayoutConstraint?
|
||||
open var leftLowConstraint: NSLayoutConstraint?
|
||||
open var topLowConstraint: NSLayoutConstraint?
|
||||
open var bottomLowConstraint: NSLayoutConstraint?
|
||||
open var rightLowConstraint: NSLayoutConstraint?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Methods
|
||||
|
||||
@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Collapses the current top notification
|
||||
- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject;
|
||||
|
||||
// Shows a topnotification new molecular
|
||||
- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject;
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
// Shows a popup
|
||||
@ -32,6 +35,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Shows a top alert
|
||||
- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate __deprecated;
|
||||
|
||||
// Shows a molecular top alert
|
||||
- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate __deprecated;
|
||||
|
||||
// Collapses the current top notification
|
||||
- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate __deprecated;
|
||||
|
||||
|
||||
@ -31,6 +31,9 @@
|
||||
} else if ([actionType isEqualToString:KeyActionTypeAlert]) {
|
||||
[self showAlert:actionInformation additionalData:additionalData delegateObject:delegateObject];
|
||||
return YES;
|
||||
} else if ([actionType isEqualToString:KeyActionTypeTopNotification]) {
|
||||
[self topNotificationAction:actionInformation additionalData:additionalData delegateObject:delegateObject];
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@ -102,6 +105,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
|
||||
//Handle molecular topnotification
|
||||
[[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dict:@"topNotification"] ?: @{}];
|
||||
}
|
||||
|
||||
- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData {
|
||||
[super defaultHandleActionError:error additionalData:additionalData];
|
||||
if (!error.silentError) {
|
||||
@ -119,12 +127,16 @@
|
||||
- (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||
if ([actionType isEqualToString:KeyActionTypePopup]) {
|
||||
[self popupAction:actionInformation additionalData:additionalData delegate:delegate];
|
||||
return YES;
|
||||
} else if ([actionType isEqualToString:KeyActionTypeTopAlert]) {
|
||||
[self topAlertAction:actionInformation additionalData:additionalData delegate:delegate];
|
||||
return YES;
|
||||
} else if ([actionType isEqualToString:KeyActionTypeCollapseNotification]) {
|
||||
[self collapseNotificationAction:actionInformation additionalData:additionalData delegate:delegate];
|
||||
return YES;
|
||||
} else if ([actionType isEqualToString:KeyActionTypeTopNotification]) {
|
||||
[self topNotificationAction:actionInformation additionalData:additionalData delegate:delegate];
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@ -171,4 +183,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||
//Handle molecular topnotification
|
||||
[[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dict:@"topNotification"] ?: @{}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -1104,7 +1104,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string {
|
||||
return [MFStyler styleGetRegularBodySmallAttributedString:string genericScaling:YES];
|
||||
return [MFStyler styleGetRegularMicroAttributedString:string genericScaling:YES];
|
||||
}
|
||||
|
||||
+ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
|
||||
|
||||
@ -28,13 +28,13 @@ open class Styler {
|
||||
|
||||
// Legacy Fonts
|
||||
case H1
|
||||
case H2
|
||||
case H3
|
||||
case H32
|
||||
case H2
|
||||
case B20
|
||||
case H3
|
||||
case B1
|
||||
case B2
|
||||
case B3
|
||||
case B20
|
||||
|
||||
/// Returns the font size of the current enum case.
|
||||
public func pointSize() -> CGFloat {
|
||||
@ -45,8 +45,7 @@ open class Styler {
|
||||
case .Title2XLarge:
|
||||
return 36
|
||||
|
||||
case .TitleXLarge,
|
||||
.H32:
|
||||
case .TitleXLarge, .H32:
|
||||
return 32
|
||||
|
||||
case .H2:
|
||||
@ -57,8 +56,7 @@ open class Styler {
|
||||
return 24
|
||||
|
||||
case .BoldTitleMedium,
|
||||
.RegularTitleMedium,
|
||||
.B20:
|
||||
.RegularTitleMedium, .B20:
|
||||
return 20
|
||||
|
||||
case .H3:
|
||||
@ -68,15 +66,12 @@ open class Styler {
|
||||
.RegularBodyLarge:
|
||||
return 16
|
||||
|
||||
case .BoldBodySmall,
|
||||
.RegularBodySmall,
|
||||
.B1,
|
||||
.B2:
|
||||
case .BoldBodySmall, .B1,
|
||||
.RegularBodySmall, .B2:
|
||||
return 13
|
||||
|
||||
case .BoldMicro,
|
||||
.RegularMicro,
|
||||
.B3:
|
||||
.RegularMicro, .B3:
|
||||
return 11
|
||||
}
|
||||
}
|
||||
@ -96,27 +91,22 @@ open class Styler {
|
||||
|
||||
switch self {
|
||||
case .RegularTitleLarge,
|
||||
.RegularTitleMedium,
|
||||
.RegularTitleMedium, .B20,
|
||||
.RegularBodyLarge,
|
||||
.RegularBodySmall,
|
||||
.RegularMicro,
|
||||
.B2,
|
||||
.B3,
|
||||
.B20:
|
||||
.RegularBodySmall, .B2,
|
||||
.RegularMicro, .B3:
|
||||
return false
|
||||
|
||||
case .Title2XLarge,
|
||||
.TitleXLarge,
|
||||
case .H1,
|
||||
.Title2XLarge,
|
||||
.TitleXLarge, .H32,
|
||||
.H2,
|
||||
.BoldTitleLarge,
|
||||
.BoldTitleMedium,
|
||||
.BoldBodyLarge,
|
||||
.BoldBodySmall,
|
||||
.BoldMicro,
|
||||
.H1,
|
||||
.H2,
|
||||
.H3,
|
||||
.H32,
|
||||
.B1:
|
||||
.BoldBodyLarge,
|
||||
.BoldBodySmall, .B1,
|
||||
.BoldMicro:
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -140,9 +130,9 @@ open class Styler {
|
||||
return false
|
||||
|
||||
case .H1,
|
||||
.H32,
|
||||
.H2,
|
||||
.H3,
|
||||
.H32,
|
||||
.B1,
|
||||
.B2,
|
||||
.B3,
|
||||
|
||||
@ -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 }
|
||||
|
||||
@ -118,6 +118,10 @@ static const CGFloat VertialShadowOffset = 6;
|
||||
NSLocale *locale = [NSLocale currentLocale];
|
||||
datePicker.locale = locale;
|
||||
datePicker.calendar = [locale objectForKey:NSLocaleCalendar];
|
||||
//To handle new style in ios 13.4 and above
|
||||
if (@available(iOS 13.4, *)) {
|
||||
[datePicker setPreferredDatePickerStyle:UIDatePickerStyleWheels];
|
||||
}
|
||||
datePicker = datePicker;
|
||||
textField.inputView = datePicker;
|
||||
return datePicker;
|
||||
@ -128,6 +132,10 @@ static const CGFloat VertialShadowOffset = 6;
|
||||
datePicker.backgroundColor = [UIColor whiteColor];
|
||||
datePicker.datePickerMode = UIDatePickerModeTime;
|
||||
datePicker = datePicker;
|
||||
//To handle new style in ios 13.4 and above
|
||||
if (@available(iOS 13.4, *)) {
|
||||
[datePicker setPreferredDatePickerStyle:UIDatePickerStyleWheels];
|
||||
}
|
||||
textField.inputView = datePicker;
|
||||
|
||||
return datePicker;
|
||||
|
||||
@ -48,6 +48,7 @@ extern NSString * const KeyActionTypePopup;
|
||||
extern NSString * const KeyActionTypeAlert;
|
||||
extern NSString * const KeyActionTypeTopAlert;
|
||||
extern NSString * const KeyActionTypeCollapseNotification;
|
||||
extern NSString * const KeyActionTypeTopNotification;
|
||||
|
||||
/// Key for molecular top notification architecture.
|
||||
extern NSString * const KeyTopAlert;
|
||||
|
||||
@ -47,6 +47,7 @@ NSString * const KeyActionTypeAlert = @"alert";
|
||||
NSString * const KeyActionTypeTopAlert = @"topAlert";
|
||||
NSString * const KeyActionTypeCollapseNotification = @"collapseNotification";
|
||||
|
||||
NSString * const KeyActionTypeTopNotification = @"topNotification";
|
||||
NSString * const KeyTopAlert = @"TopNotification";
|
||||
|
||||
#pragma mark - Values
|
||||
|
||||
Loading…
Reference in New Issue
Block a user