Merge branch 'feature/model_wip_kamlesh' of gitlab.verizon.com:BPHV_MIPS/mvm_core_ui into feature/model_wip_kamlesh
This commit is contained in:
commit
dba412c7d9
@ -103,26 +103,9 @@ open class CaretView: View {
|
|||||||
defaultState()
|
defaultState()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: CaretViewModel.self) else { return }
|
||||||
// Configure class properties with JSON values
|
setWithModel(model, delegateObject, additionalData as? [String : AnyHashable])
|
||||||
guard let dictionary = json else { return }
|
|
||||||
|
|
||||||
if let strokeColorHex = dictionary["strokeColor"] as? String {
|
|
||||||
strokeColor = UIColor.mfGet(forHex: strokeColorHex)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isHiddenValue = dictionary[KeyIsHidden] as? Bool {
|
|
||||||
isHidden = isHiddenValue
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isOpaqueValue = dictionary[KeyIsOpaque] as? Bool {
|
|
||||||
isOpaque = isOpaqueValue
|
|
||||||
}
|
|
||||||
|
|
||||||
if let lineWidthValue = dictionary["lineWidth"] as? CGFloat {
|
|
||||||
lineWidth = lineWidthValue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - MVMCoreMoleculeViewProtocol
|
//MARK: - MVMCoreMoleculeViewProtocol
|
||||||
@ -131,17 +114,9 @@ open class CaretView: View {
|
|||||||
guard let caretModel = model as? CaretViewModel else {
|
guard let caretModel = model as? CaretViewModel else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if let strokeColorHex = caretModel.strokeColor {
|
strokeColor = caretModel.strokeColor.uiColor
|
||||||
strokeColor = UIColor.mfGet(forHex: strokeColorHex)
|
isHidden = caretModel.isHidden ?? false
|
||||||
}
|
isOpaque = caretModel.isOpaque ?? false
|
||||||
|
|
||||||
if let isHiddenValue = caretModel.isHidden {
|
|
||||||
isHidden = isHiddenValue
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isOpaqueValue = caretModel.isOpaque {
|
|
||||||
isOpaque = isOpaqueValue
|
|
||||||
}
|
|
||||||
|
|
||||||
if let lineWidthValue = caretModel.lineWidth {
|
if let lineWidthValue = caretModel.lineWidth {
|
||||||
lineWidth = lineWidthValue
|
lineWidth = lineWidthValue
|
||||||
|
|||||||
@ -12,8 +12,36 @@ import Foundation
|
|||||||
|
|
||||||
public static var identifier: String = "caretView"
|
public static var identifier: String = "caretView"
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var strokeColor: String?
|
public var strokeColor: Color = Color(uiColor: .black)
|
||||||
public var isHidden: Bool?
|
public var isHidden: Bool?
|
||||||
public var isOpaque: Bool?
|
public var isOpaque: Bool?
|
||||||
public var lineWidth: CGFloat?
|
public var lineWidth: CGFloat?
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case backgroundColor
|
||||||
|
case strokeColor
|
||||||
|
case isHidden
|
||||||
|
case isOpaque
|
||||||
|
case lineWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
if let strokeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .strokeColor) {
|
||||||
|
self.strokeColor = strokeColor
|
||||||
|
}
|
||||||
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
isHidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .isHidden)
|
||||||
|
isOpaque = try typeContainer.decodeIfPresent(Bool.self, forKey: .isOpaque)
|
||||||
|
lineWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .lineWidth)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(strokeColor, forKey: .strokeColor)
|
||||||
|
try container.encodeIfPresent(isHidden, forKey: .isHidden)
|
||||||
|
try container.encodeIfPresent(isOpaque, forKey: .isOpaque)
|
||||||
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
try container.encodeIfPresent(lineWidth, forKey: .lineWidth)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,8 +15,11 @@ open class DashLine: View {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
@objc public var dashColor: UIColor?
|
var dashModel: DashLineModel? {
|
||||||
@objc public var dashLayer: CAShapeLayer?
|
get { return model as? DashLineModel }
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private var dashLayer: CAShapeLayer?
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
@ -53,7 +56,7 @@ open class DashLine: View {
|
|||||||
dashLayer.lineCap = .round
|
dashLayer.lineCap = .round
|
||||||
dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)]
|
dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)]
|
||||||
dashLayer.path = path.cgPath
|
dashLayer.path = path.cgPath
|
||||||
dashLayer.strokeColor = dashColor?.cgColor ?? UIColor.mfLighterGray().cgColor
|
dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? UIColor.mfLighterGray().cgColor
|
||||||
dashLayer.fillColor = UIColor.clear.cgColor
|
dashLayer.fillColor = UIColor.clear.cgColor
|
||||||
dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor
|
dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor
|
||||||
self.dashLayer = dashLayer
|
self.dashLayer = dashLayer
|
||||||
@ -70,27 +73,16 @@ open class DashLine: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: DashLineModel.self) else { return }
|
||||||
|
setWithModel(model, delegateObject, additionalData as? [String : AnyHashable])
|
||||||
// Configure class properties with JSON values
|
|
||||||
guard let jsonDictionary = json else { return }
|
|
||||||
|
|
||||||
if let isHiddenValue = jsonDictionary[KeyIsHidden] as? Bool {
|
|
||||||
isHidden = isHiddenValue
|
|
||||||
}
|
|
||||||
|
|
||||||
if let dashColorHex = jsonDictionary["dashColor"] as? String {
|
|
||||||
dashColor = UIColor.mfGet(forHex: dashColorHex)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - MVMCoreMoleculeViewProtocol
|
//MARK: - MVMCoreMoleculeViewProtocol
|
||||||
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||||
super.setWithModel(model, delegateObject, additionalData)
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
guard let dashLineModel = model as? DashLineModel else {
|
guard let dashLineModel = dashModel else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dashColor = dashLineModel.dashColor.uiColor
|
|
||||||
if let isHiddenValue = dashLineModel.isHidden {
|
if let isHiddenValue = dashLineModel.isHidden {
|
||||||
isHidden = isHiddenValue
|
isHidden = isHiddenValue
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,10 +12,32 @@ import Foundation
|
|||||||
public static var identifier: String = "dashLine"
|
public static var identifier: String = "dashLine"
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var dashColor: Color
|
public var dashColor: Color = Color(uiColor: .mfLighterGray())
|
||||||
public var isHidden: Bool?
|
public var isHidden: Bool?
|
||||||
|
|
||||||
public init(dashColor: Color) {
|
public init(dashColor: Color) {
|
||||||
self.dashColor = dashColor
|
self.dashColor = dashColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case backgroundColor
|
||||||
|
case dashColor
|
||||||
|
case isHidden
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
if let dashColor = try typeContainer.decodeIfPresent(Color.self, forKey: .dashColor) {
|
||||||
|
self.dashColor = dashColor
|
||||||
|
}
|
||||||
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
isHidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .isHidden)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(dashColor, forKey: .dashColor)
|
||||||
|
try container.encodeIfPresent(isHidden, forKey: .isHidden)
|
||||||
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import Foundation
|
|||||||
|
|
||||||
@objcMembers public class ImageViewModel: MoleculeProtocol {
|
@objcMembers public class ImageViewModel: MoleculeProtocol {
|
||||||
public static var identifier: String = "image"
|
public static var identifier: String = "image"
|
||||||
public var moleculeName: String
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var image: String
|
public var image: String
|
||||||
|
|||||||
@ -13,5 +13,4 @@ import UIKit
|
|||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var leftText: LabelModel
|
public var leftText: LabelModel
|
||||||
public var rightText: LabelModel
|
public var rightText: LabelModel
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,19 +9,13 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers open class Line: View {
|
@objcMembers open class Line: View {
|
||||||
|
var lineModel: LineModel? {
|
||||||
|
get { return model as? LineModel }
|
||||||
|
}
|
||||||
|
|
||||||
public var heightConstraint: NSLayoutConstraint?
|
public var heightConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
public enum Style: String, Codable {
|
open func setStyle(_ style: LineModel.Style) {
|
||||||
case standard
|
|
||||||
case thin
|
|
||||||
case medium
|
|
||||||
case heavy
|
|
||||||
case none
|
|
||||||
}
|
|
||||||
|
|
||||||
public var style = Style.standard {
|
|
||||||
didSet {
|
|
||||||
switch style {
|
switch style {
|
||||||
case .standard:
|
case .standard:
|
||||||
heightConstraint?.constant = 1
|
heightConstraint?.constant = 1
|
||||||
@ -39,12 +33,11 @@ import UIKit
|
|||||||
heightConstraint?.constant = 0
|
heightConstraint?.constant = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Helpers
|
// MARK: - Helpers
|
||||||
open func shouldBeVisible() -> Bool {
|
open func shouldBeVisible() -> Bool {
|
||||||
guard let type = json?.optionalStringForKey(KeyType) else { return false }
|
guard let type = lineModel?.type else { return false }
|
||||||
return type != "none"
|
return type != .none
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) {
|
public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) {
|
||||||
@ -56,26 +49,33 @@ import UIKit
|
|||||||
// MARK: - MVMCoreViewProtocol
|
// MARK: - MVMCoreViewProtocol
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
backgroundColor = .black
|
|
||||||
heightConstraint = heightAnchor.constraint(equalToConstant: 1)
|
heightConstraint = heightAnchor.constraint(equalToConstant: 1)
|
||||||
heightConstraint?.isActive = true
|
heightConstraint?.isActive = true
|
||||||
|
setStyle(.standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
|
|
||||||
// If no type, default to standard.
|
// If no type, default to standard.
|
||||||
if let typeString = json?.optionalStringForKey(KeyType), let type = Style.init(rawValue: typeString) {
|
if let typeString = json?.optionalStringForKey(KeyType), let type = LineModel.Style.init(rawValue: typeString) {
|
||||||
style = type
|
setStyle(type)
|
||||||
} else {
|
} else {
|
||||||
style = .standard
|
setStyle(.standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||||
|
if let lineModel = model as? LineModel {
|
||||||
|
setStyle(lineModel.type ?? .standard)
|
||||||
|
}
|
||||||
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
style = .standard
|
setStyle(.standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
open func copyBackgroundColor() -> Bool {
|
open func copyBackgroundColor() -> Bool {
|
||||||
@ -83,7 +83,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||||
guard let type = json?.optionalStringForKey(KeyType), let style = Style(rawValue: type) else { return 1 }
|
guard let type = json?.optionalStringForKey(KeyType), let style = LineModel.Style(rawValue: type) else { return 1 }
|
||||||
switch style {
|
switch style {
|
||||||
case .none:
|
case .none:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@ -9,6 +9,9 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers open class MultiProgress: View {
|
@objcMembers open class MultiProgress: View {
|
||||||
|
var multiProgressModel: MultiProgressBarModel? {
|
||||||
|
get { return model as? MultiProgressBarModel }
|
||||||
|
}
|
||||||
|
|
||||||
///passing value to progressList creates corresponding progress bars
|
///passing value to progressList creates corresponding progress bars
|
||||||
var progressList: Array<SingleProgressBarModel>? {
|
var progressList: Array<SingleProgressBarModel>? {
|
||||||
@ -63,7 +66,7 @@ import UIKit
|
|||||||
//MARK: - MVMCoreMoleculeViewProtocol
|
//MARK: - MVMCoreMoleculeViewProtocol
|
||||||
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||||
super.setWithModel(model, delegateObject, additionalData)
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
guard let multiProgressModel = model as? MultiProgressBarModel else {
|
guard let multiProgressModel = multiProgressModel else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
roundedRect = multiProgressModel.roundedRect ?? false
|
roundedRect = multiProgressModel.roundedRect ?? false
|
||||||
@ -78,9 +81,8 @@ import UIKit
|
|||||||
progressList = nil
|
progressList = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: MultiProgressBarModel.self) else { return }
|
||||||
thicknessConstraint?.constant = json?.optionalCGFloatForKey("thickness") ?? defaultHeight
|
setWithModel(model, delegateObject, additionalData as? [String : AnyHashable])
|
||||||
roundedRect = json?.optionalBoolForKey("roundedRect") ?? false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,10 @@ import Foundation
|
|||||||
case backgroundColor
|
case backgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public init(_ progressList: [SingleProgressBarModel]) {
|
||||||
|
self.progressList = progressList
|
||||||
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList)
|
progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList)
|
||||||
|
|||||||
@ -9,11 +9,12 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers open class ProgressBar: UIProgressView, MVMCoreViewProtocol, ModelMoleculeViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
@objcMembers open class ProgressBar: UIProgressView, MVMCoreViewProtocol, ModelMoleculeViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||||
var isRounded = false
|
var progressBarModel: ProgressBarModel?
|
||||||
|
|
||||||
var thickness: CGFloat = 8.0 {
|
var thickness: CGFloat = 8.0 {
|
||||||
willSet(newValue) {
|
willSet(newValue) {
|
||||||
heightAnchor.constraint(equalToConstant: newValue).isActive = true
|
heightAnchor.constraint(equalToConstant: newValue).isActive = true
|
||||||
if isRounded {
|
if progressBarModel?.isRounded ?? false {
|
||||||
layer.cornerRadius = newValue/2.0
|
layer.cornerRadius = newValue/2.0
|
||||||
} else {
|
} else {
|
||||||
progressViewStyle = .bar
|
progressViewStyle = .bar
|
||||||
@ -40,7 +41,6 @@ import Foundation
|
|||||||
public func setupView() {
|
public func setupView() {
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
isRounded = false
|
|
||||||
thickness = 8
|
thickness = 8
|
||||||
progress = 0
|
progress = 0
|
||||||
progressTintColor = UIColor.mfCerulean()
|
progressTintColor = UIColor.mfCerulean()
|
||||||
@ -55,7 +55,6 @@ import Foundation
|
|||||||
guard let progressBarModel = model as? ProgressBarModel else {
|
guard let progressBarModel = model as? ProgressBarModel else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isRounded = progressBarModel.isRounded ?? false
|
|
||||||
thickness = progressBarModel.thickness ?? 8
|
thickness = progressBarModel.thickness ?? 8
|
||||||
progress = Float((progressBarModel.percent)/100.0)
|
progress = Float((progressBarModel.percent)/100.0)
|
||||||
progressTintColor = progressBarModel.progressColor.uiColor
|
progressTintColor = progressBarModel.progressColor.uiColor
|
||||||
@ -66,26 +65,11 @@ import Foundation
|
|||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
if let isRounded = json?.optionalBoolForKey("roundedRect") {
|
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: ProgressBarModel.self) else { return }
|
||||||
self.isRounded = isRounded
|
setWithModel(model, delegateObject, additionalData as? [String : AnyHashable])
|
||||||
}
|
|
||||||
if let thickness = json?.optionalCGFloatForKey("thickness") {
|
|
||||||
self.thickness = thickness
|
|
||||||
}
|
|
||||||
// as? Float returns nil, apple defect.
|
|
||||||
if let percentage = json?["percent"] as? CGFloat {
|
|
||||||
progress = Float(percentage/100.0)
|
|
||||||
}
|
|
||||||
if let progressColor = json?.optionalStringForKey("progressColor") {
|
|
||||||
progressTintColor = UIColor.mfGet(forHex: progressColor)
|
|
||||||
}
|
|
||||||
if let backgroundColor = json?.optionalStringForKey("backgroundColor") {
|
|
||||||
trackTintColor = UIColor.mfGet(forHex: backgroundColor)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reset() {
|
public func reset() {
|
||||||
isRounded = false
|
|
||||||
thickness = 8
|
thickness = 8
|
||||||
progress = 0
|
progress = 0
|
||||||
progressTintColor = UIColor.mfCerulean()
|
progressTintColor = UIColor.mfCerulean()
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import Foundation
|
|||||||
case backgroundColor
|
case backgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
init(_ percent: CGFloat) {
|
public init(_ percent: CGFloat) {
|
||||||
self.percent = percent
|
self.percent = percent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import UIKit
|
|||||||
let navigationController = self.init()
|
let navigationController = self.init()
|
||||||
style(navigationController.navigationBar)
|
style(navigationController.navigationBar)
|
||||||
navigationController.separatorView = Line(pinTo: navigationController.navigationBar, edge: .bottom, useMargin: false)
|
navigationController.separatorView = Line(pinTo: navigationController.navigationBar, edge: .bottom, useMargin: false)
|
||||||
navigationController.separatorView?.style = .standard
|
navigationController.separatorView?.setStyle(.standard)
|
||||||
MVMCoreUISession.sharedGlobal()?.navigationController = navigationController
|
MVMCoreUISession.sharedGlobal()?.navigationController = navigationController
|
||||||
MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController
|
MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController
|
||||||
MVMCoreNavigationHandler.shared()?.navigationController = navigationController
|
MVMCoreNavigationHandler.shared()?.navigationController = navigationController
|
||||||
|
|||||||
@ -9,7 +9,43 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers public class LineModel: MoleculeProtocol {
|
@objcMembers public class LineModel: MoleculeProtocol {
|
||||||
public static var identifier: String = "line"
|
|
||||||
public var backgroundColor: Color?
|
/*
|
||||||
public var type: String?
|
The frequency of the line in a moleculeList.
|
||||||
|
all (between all cells, above top, below bottom)
|
||||||
|
allExceptTop (between all cells, below bottom)
|
||||||
|
allExceptBottom (between all cells, above top)
|
||||||
|
between (between all cells)
|
||||||
|
*/
|
||||||
|
public enum Frequency: String, Codable {
|
||||||
|
case all
|
||||||
|
case allExceptTop
|
||||||
|
case allExceptBottom
|
||||||
|
case between
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The style of the line.
|
||||||
|
standard (1 height, silver)
|
||||||
|
thin (1 height, black)
|
||||||
|
medium (2 height, black)
|
||||||
|
heavy (4 height, black)
|
||||||
|
none (hidden)
|
||||||
|
*/
|
||||||
|
public enum Style: String, Codable {
|
||||||
|
case standard
|
||||||
|
case thin
|
||||||
|
case medium
|
||||||
|
case heavy
|
||||||
|
case none
|
||||||
|
}
|
||||||
|
|
||||||
|
public static var identifier: String = "line"
|
||||||
|
public var type: Style? = .standard
|
||||||
|
public var frequency: Frequency? = .allExceptTop
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
|
public init(type: Style) {
|
||||||
|
self.type = type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||||
bottomSeparatorView?.style = .none
|
bottomSeparatorView?.setStyle(.none)
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
super.setWithModel(model, delegateObject, additionalData)
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
|
|
||||||
@ -65,6 +65,6 @@ import UIKit
|
|||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
bottomMarginPadding = 0
|
bottomMarginPadding = 0
|
||||||
bottomSeparatorView?.style = .none
|
bottomSeparatorView?.setStyle(.none)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,29 +62,29 @@ import UIKit
|
|||||||
open func styleStandard() {
|
open func styleStandard() {
|
||||||
topMarginPadding = 24
|
topMarginPadding = 24
|
||||||
bottomMarginPadding = 24
|
bottomMarginPadding = 24
|
||||||
topSeparatorView?.style = .none
|
topSeparatorView?.setStyle(.none)
|
||||||
bottomSeparatorView?.style = .standard
|
bottomSeparatorView?.setStyle(.standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
open func styleHeader() {
|
open func styleHeader() {
|
||||||
topMarginPadding = 48
|
topMarginPadding = 48
|
||||||
bottomMarginPadding = 16
|
bottomMarginPadding = 16
|
||||||
topSeparatorView?.style = .none
|
topSeparatorView?.setStyle(.none)
|
||||||
bottomSeparatorView?.style = .thin
|
bottomSeparatorView?.setStyle(.thin)
|
||||||
}
|
}
|
||||||
|
|
||||||
open func styleFooter() {
|
open func styleFooter() {
|
||||||
topMarginPadding = 24
|
topMarginPadding = 24
|
||||||
bottomMarginPadding = 0
|
bottomMarginPadding = 0
|
||||||
topSeparatorView?.style = .none
|
topSeparatorView?.setStyle(.none)
|
||||||
bottomSeparatorView?.style = .none
|
bottomSeparatorView?.setStyle(.none)
|
||||||
}
|
}
|
||||||
|
|
||||||
open func styleNone() {
|
open func styleNone() {
|
||||||
topMarginPadding = 0
|
topMarginPadding = 0
|
||||||
bottomMarginPadding = 0
|
bottomMarginPadding = 0
|
||||||
topSeparatorView?.style = .none
|
topSeparatorView?.setStyle(.none)
|
||||||
bottomSeparatorView?.style = .none
|
bottomSeparatorView?.setStyle(.none)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds the molecule to the view.
|
/// Adds the molecule to the view.
|
||||||
@ -264,8 +264,8 @@ import UIKit
|
|||||||
setSeparatorFrequency(separatorFrequency, indexPath: indexPath)
|
setSeparatorFrequency(separatorFrequency, indexPath: indexPath)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
topSeparatorView?.style = .standard
|
topSeparatorView?.setStyle(.standard)
|
||||||
bottomSeparatorView?.style = .standard
|
bottomSeparatorView?.setStyle(.standard)
|
||||||
setSeparatorFrequency(TableViewCell.SeparatorFrequency.allExceptTop, indexPath: indexPath)
|
setSeparatorFrequency(TableViewCell.SeparatorFrequency.allExceptTop, indexPath: indexPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ import UIKit
|
|||||||
open func addSeparatorsIfNeeded() {
|
open func addSeparatorsIfNeeded() {
|
||||||
if topSeparatorView == nil {
|
if topSeparatorView == nil {
|
||||||
let line = Line()
|
let line = Line()
|
||||||
line.style = .none
|
line.setStyle(.none)
|
||||||
addSubview(line)
|
addSubview(line)
|
||||||
NSLayoutConstraint.pinViewTop(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
NSLayoutConstraint.pinViewTop(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
||||||
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||||
@ -294,7 +294,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
if bottomSeparatorView == nil {
|
if bottomSeparatorView == nil {
|
||||||
let line = Line()
|
let line = Line()
|
||||||
line.style = .none
|
line.setStyle(.none)
|
||||||
addSubview(line)
|
addSubview(line)
|
||||||
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
||||||
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||||
|
|||||||
@ -25,4 +25,11 @@ extension ModelMoleculeViewProtocol {
|
|||||||
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary
|
||||||
|
public static func decodeJSONToModel<T>(json: [AnyHashable: Any], type: T.Type) throws -> T where T : Decodable {
|
||||||
|
let data = try JSONSerialization.data(withJSONObject: json)
|
||||||
|
let decoder = JSONDecoder()
|
||||||
|
return try decoder.decode(type, from: data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public class StandardHeaderView: MoleculeContainer {
|
|||||||
|
|
||||||
guard line == nil else { return }
|
guard line == nil else { return }
|
||||||
let line = Line()
|
let line = Line()
|
||||||
line.style = .heavy
|
line.setStyle(.heavy)
|
||||||
addSubview(line)
|
addSubview(line)
|
||||||
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
||||||
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||||
@ -56,7 +56,7 @@ public class StandardHeaderView: MoleculeContainer {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
line?.style = .heavy
|
line?.setStyle(.heavy)
|
||||||
}
|
}
|
||||||
|
|
||||||
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||||
|
|||||||
@ -143,7 +143,6 @@ open class MoleculeStackView: Container {
|
|||||||
} else {
|
} else {
|
||||||
setWithModel(model, delegateObject, additionalData as? [String : AnyHashable])
|
setWithModel(model, delegateObject, additionalData as? [String : AnyHashable])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||||
|
|||||||
@ -33,5 +33,6 @@ import Foundation
|
|||||||
//
|
//
|
||||||
//ModelRegistry.register(ModuleMoleculeModel.self)
|
//ModelRegistry.register(ModuleMoleculeModel.self)
|
||||||
ModelRegistry.register(LeftRightLabelModel.self)
|
ModelRegistry.register(LeftRightLabelModel.self)
|
||||||
|
ModelRegistry.register(CaretViewModel.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user