Adding new atom.
This commit is contained in:
parent
ec1682a632
commit
0f9aa7dc01
109
MVMCoreUI/Atoms/Views/ItemDetailView.swift
Normal file
109
MVMCoreUI/Atoms/Views/ItemDetailView.swift
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
//
|
||||||
|
// ItemDetailView.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Christiano, Kevin on 5/20/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
@objcMembers open class ItemDetailView: ViewConstrainingView {
|
||||||
|
//------------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//------------------------------------------------------
|
||||||
|
|
||||||
|
var title: Label?
|
||||||
|
var message: Label?
|
||||||
|
var detail: Label?
|
||||||
|
|
||||||
|
//------------------------------------------------------
|
||||||
|
// MARK: - Initialization
|
||||||
|
//------------------------------------------------------
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
super.init(frame: .zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init?(coder aDecoder: NSCoder) {
|
||||||
|
super.init(coder: aDecoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(actionMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
self.init()
|
||||||
|
setWithJSON(actionMap: actionMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
}
|
||||||
|
|
||||||
|
override open func setupView() {
|
||||||
|
super.setupView()
|
||||||
|
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
defaultState()
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------
|
||||||
|
// MARK: - Setup
|
||||||
|
//------------------------------------------------------
|
||||||
|
|
||||||
|
override open func updateView(_ size: CGFloat) {
|
||||||
|
super.updateView(size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultState() {
|
||||||
|
|
||||||
|
if title == nil {
|
||||||
|
title = Label.commonLabelB1(false)
|
||||||
|
message = Label.commonLabelB2(false)
|
||||||
|
detail = Label.commonLabelB1(false)
|
||||||
|
|
||||||
|
if let title = title, let message = message, let detail = detail {
|
||||||
|
addSubview(title)
|
||||||
|
addSubview(message)
|
||||||
|
addSubview(detail)
|
||||||
|
|
||||||
|
title.textAlignment = .left
|
||||||
|
message.textAlignment = .left
|
||||||
|
detail.textAlignment = .right
|
||||||
|
|
||||||
|
NSLayoutConstraint.constraintPinSubview(title, pinTop: true, topConstant: PaddingTwo, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: 16, pinRight: false, rightConstant: 0)
|
||||||
|
NSLayoutConstraint.constraintPinSubview(message, pinTop: false, topConstant: 0, pinBottom: true, bottomConstant: PaddingTwo, pinLeft: true, leftConstant: 16, pinRight: true, rightConstant: 16)
|
||||||
|
NSLayoutConstraint.constraintPinSubview(detail, pinTop: true, topConstant: PaddingTwo, pinBottom: false, bottomConstant: 0, pinLeft: false, leftConstant: 0, pinRight: true, rightConstant: 16)
|
||||||
|
NSLayoutConstraint(pinFirstView: title, toSecondView: message, withConstant: 0, directionVertical: true)?.isActive = true
|
||||||
|
|
||||||
|
title.trailingAnchor.constraint(lessThanOrEqualTo: detail.leadingAnchor, constant: PaddingOne).isActive = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setWithJSON(actionMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
|
||||||
|
guard let dictionary = actionMap else { return }
|
||||||
|
|
||||||
|
title?.text = dictionary.stringForkey(KeyTitle)
|
||||||
|
message?.text = dictionary.stringForkey(KeyMessage)
|
||||||
|
detail?.text = dictionary.stringForkey("detail")
|
||||||
|
|
||||||
|
if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String {
|
||||||
|
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------
|
||||||
|
// MARK: - Atomization
|
||||||
|
//------------------------------------------------------
|
||||||
|
|
||||||
|
open override func setAsMolecule() {
|
||||||
|
super.setAsMolecule()
|
||||||
|
defaultState()
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
setWithJSON(actionMap: json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user