Line and image update
This commit is contained in:
parent
d651fb5783
commit
3e8b69a0bc
@ -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,42 +9,35 @@
|
|||||||
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
|
switch style {
|
||||||
case thin
|
case .standard:
|
||||||
case medium
|
heightConstraint?.constant = 1
|
||||||
case heavy
|
backgroundColor = .mfSilver()
|
||||||
case none
|
case .thin:
|
||||||
}
|
heightConstraint?.constant = 1
|
||||||
|
backgroundColor = .black
|
||||||
public var style = Style.standard {
|
case .medium:
|
||||||
didSet {
|
heightConstraint?.constant = 2
|
||||||
switch style {
|
backgroundColor = .black
|
||||||
case .standard:
|
case .heavy:
|
||||||
heightConstraint?.constant = 1
|
heightConstraint?.constant = 4
|
||||||
backgroundColor = .mfSilver()
|
backgroundColor = .black
|
||||||
case .thin:
|
case .none:
|
||||||
heightConstraint?.constant = 1
|
heightConstraint?.constant = 0
|
||||||
backgroundColor = .black
|
|
||||||
case .medium:
|
|
||||||
heightConstraint?.constant = 2
|
|
||||||
backgroundColor = .black
|
|
||||||
case .heavy:
|
|
||||||
heightConstraint?.constant = 4
|
|
||||||
backgroundColor = .black
|
|
||||||
case .none:
|
|
||||||
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
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|
||||||
|
/*
|
||||||
|
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 static var identifier: String = "line"
|
||||||
|
public var type: Style? = .standard
|
||||||
|
public var frequency: Frequency? = .allExceptTop
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var type: String?
|
|
||||||
|
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
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user