Line to swift
This commit is contained in:
parent
82f94cde25
commit
c96f5050a8
@ -33,6 +33,7 @@
|
||||
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; };
|
||||
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
|
||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
||||
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; };
|
||||
D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelSwitch.swift */; };
|
||||
D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */; };
|
||||
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */; };
|
||||
@ -229,6 +230,7 @@
|
||||
9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = "<group>"; };
|
||||
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
||||
D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; };
|
||||
D22479892314445E003FCCF9 /* LabelSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelSwitch.swift; sourceTree = "<group>"; };
|
||||
D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodySwitch.swift; sourceTree = "<group>"; };
|
||||
D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutConstraintExtension.swift; sourceTree = "<group>"; };
|
||||
@ -443,6 +445,12 @@
|
||||
D213347523842FF5008E41B3 /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D29DF17E21E69E2E003B2FB9 /* MFView.h */,
|
||||
D29DF17F21E69E2E003B2FB9 /* MFView.m */,
|
||||
D29DF31E21ED0CBA003B2FB9 /* LabelView.h */,
|
||||
D29DF31F21ED0CBA003B2FB9 /* LabelView.m */,
|
||||
D29DF15921E697DA003B2FB9 /* SeparatorView.h */,
|
||||
D29DF15A21E697DA003B2FB9 /* SeparatorView.m */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@ -737,19 +745,14 @@
|
||||
DBC4391622442196001AB423 /* CaretView.swift */,
|
||||
DBC4391722442197001AB423 /* DashLine.swift */,
|
||||
DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */,
|
||||
D29DF17E21E69E2E003B2FB9 /* MFView.h */,
|
||||
D29DF17F21E69E2E003B2FB9 /* MFView.m */,
|
||||
D29DF31E21ED0CBA003B2FB9 /* LabelView.h */,
|
||||
D29DF31F21ED0CBA003B2FB9 /* LabelView.m */,
|
||||
D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */,
|
||||
D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */,
|
||||
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */,
|
||||
D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */,
|
||||
D213347623843825008E41B3 /* Line.swift */,
|
||||
D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */,
|
||||
D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */,
|
||||
D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */,
|
||||
D29DF15921E697DA003B2FB9 /* SeparatorView.h */,
|
||||
D29DF15A21E697DA003B2FB9 /* SeparatorView.m */,
|
||||
D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */,
|
||||
D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */,
|
||||
D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */,
|
||||
@ -1092,6 +1095,7 @@
|
||||
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */,
|
||||
D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */,
|
||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
||||
D213347723843825008E41B3 /* Line.swift in Sources */,
|
||||
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
||||
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
||||
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
//
|
||||
|
||||
|
||||
open class CaretView: MFView {
|
||||
open class CaretView: View {
|
||||
//------------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//------------------------------------------------------
|
||||
@ -26,7 +26,7 @@ open class CaretView: MFView {
|
||||
// MARK: - Initialization
|
||||
//------------------------------------------------------
|
||||
|
||||
@objc public init() {
|
||||
@objc public override init() {
|
||||
super.init(frame: .zero)
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ open class CaretView: MFView {
|
||||
//------------------------------------------------------
|
||||
|
||||
// Default values for view.
|
||||
@objc open override func setAsMolecule() {
|
||||
@objc open func setAsMolecule() {
|
||||
defaultState()
|
||||
}
|
||||
|
||||
@ -124,12 +124,14 @@ open class CaretView: MFView {
|
||||
lineWidth = lineWidthValue
|
||||
}
|
||||
}
|
||||
|
||||
open override func needsToBeConstrained() -> Bool {
|
||||
}
|
||||
|
||||
extension CaretView: MVMCoreUIViewConstrainingProtocol {
|
||||
open func needsToBeConstrained() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
open override func alignment() -> UIStackView.Alignment {
|
||||
open func alignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
import MVMCore
|
||||
|
||||
|
||||
open class DashLine: MFView {
|
||||
open class DashLine: View {
|
||||
//------------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//------------------------------------------------------
|
||||
@ -62,8 +62,7 @@ open class DashLine: MFView {
|
||||
//------------------------------------------------------
|
||||
|
||||
// Default values for view.
|
||||
@objc open override func setAsMolecule() {
|
||||
|
||||
@objc open func setAsMolecule() {
|
||||
backgroundColor = .clear
|
||||
isHidden = false
|
||||
}
|
||||
|
||||
113
MVMCoreUI/Atoms/Views/Line.swift
Normal file
113
MVMCoreUI/Atoms/Views/Line.swift
Normal file
@ -0,0 +1,113 @@
|
||||
//
|
||||
// Line.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 11/19/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers open class Line: View {
|
||||
|
||||
public var heightConstraint: NSLayoutConstraint?
|
||||
|
||||
public enum Style: String, Codable {
|
||||
case standard
|
||||
case thin
|
||||
case medium
|
||||
case heavy
|
||||
case none
|
||||
}
|
||||
|
||||
public var style = Style.standard {
|
||||
didSet {
|
||||
switch style {
|
||||
case .standard:
|
||||
heightConstraint?.constant = 1
|
||||
backgroundColor = .mfSilver()
|
||||
setNeedsLayout()
|
||||
layoutIfNeeded()
|
||||
case .thin:
|
||||
heightConstraint?.constant = 1
|
||||
backgroundColor = .black
|
||||
setNeedsLayout()
|
||||
layoutIfNeeded()
|
||||
case .medium:
|
||||
heightConstraint?.constant = 2
|
||||
backgroundColor = .black
|
||||
setNeedsLayout()
|
||||
layoutIfNeeded()
|
||||
case .heavy:
|
||||
heightConstraint?.constant = 4
|
||||
backgroundColor = .black
|
||||
setNeedsLayout()
|
||||
layoutIfNeeded()
|
||||
case .none:
|
||||
heightConstraint?.constant = 0
|
||||
setNeedsLayout()
|
||||
layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
open func shouldBeVisible() -> Bool {
|
||||
guard let type = json?.optionalStringForKey(KeyType) else { return false }
|
||||
return type != "none"
|
||||
}
|
||||
|
||||
public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) {
|
||||
self.init(frame: .zero)
|
||||
view.addSubview(self)
|
||||
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: self, useMargins: useMargin, pinTop: edge != .bottom, pinBottom: edge != .top, pinLeft: edge != .right, pinRight: edge != .left).values))
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
backgroundColor = .black
|
||||
heightConstraint = heightAnchor.constraint(equalToConstant: 1)
|
||||
heightConstraint?.isActive = true
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
|
||||
if let typeString = json?.optionalStringForKey(KeyType), let type = Style.init(rawValue: typeString) {
|
||||
style = type
|
||||
} else {
|
||||
style = .standard
|
||||
}
|
||||
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
style = .standard
|
||||
}
|
||||
|
||||
open func copyBackgroundColor() -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||
guard let type = json?.optionalStringForKey(KeyType) else { return 0 }
|
||||
switch type {
|
||||
case "thin", "standard":
|
||||
return 1
|
||||
case "medium":
|
||||
return 2
|
||||
case "heavy":
|
||||
return 4
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Line: MVMCoreUIViewConstrainingProtocol {
|
||||
open func needsToBeConstrained() -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -34,7 +34,7 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
@objcMembers open class MultiProgress: MFView {
|
||||
@objcMembers open class MultiProgress: View {
|
||||
///passing value to progressList creates corresponding progress bars
|
||||
var progressList: Array<ProgressBarObject>? {
|
||||
didSet {
|
||||
@ -49,7 +49,7 @@ import UIKit
|
||||
guard progressObject.progress > 0.0 else {
|
||||
continue
|
||||
}
|
||||
let view = MFView(frame: .zero)
|
||||
let view = UIView(frame: .zero)
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(view)
|
||||
view.backgroundColor = progressObject.color
|
||||
|
||||
@ -62,6 +62,8 @@ extern NSString * _Nonnull const ConstraintWidth;
|
||||
#pragma mark - With Margins
|
||||
|
||||
+ (nonnull NSDictionary <NSString *, NSLayoutConstraint *>*)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins;
|
||||
+ (nonnull NSDictionary <NSString *, NSLayoutConstraint *>*)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins pinTop:(BOOL)pinTop pinBottom:(BOOL)pinBottom pinLeft:(BOOL)pinLeft pinRight:(BOOL)pinRight;
|
||||
+ (nonnull NSDictionary <NSString *, NSLayoutConstraint *>*)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins pinTop:(BOOL)pinTop topConstant:(CGFloat)topConstant pinBottom:(BOOL)pinBottom bottomConstant:(CGFloat)bottomConstant pinLeft:(BOOL)pinLeft leftConstant:(CGFloat)leftConstant pinRight:(BOOL)pinRight rightConstant:(CGFloat)rightConstant;
|
||||
+ (nonnull NSLayoutConstraint *)pinViewTopToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant;
|
||||
+ (nonnull NSLayoutConstraint *)pinViewLeftToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant;
|
||||
+ (nonnull NSLayoutConstraint *)pinViewRightToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant;
|
||||
|
||||
@ -161,11 +161,28 @@ NSString *const ConstraintWidth = @"width";
|
||||
#pragma mark - With Margins
|
||||
|
||||
+ (nonnull NSDictionary *)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins {
|
||||
return @{ConstraintTop:[self pinViewTopToSuperview:subview useMargins:useMargins constant:0],
|
||||
ConstraintLeading:[self pinViewLeftToSuperview:subview useMargins:useMargins constant:0],
|
||||
ConstraintTrailing:[self pinViewRightToSuperview:subview useMargins:useMargins constant:0],
|
||||
ConstraintBot:[self pinViewBottomToSuperview:subview useMargins:useMargins constant:0],
|
||||
};
|
||||
return [NSLayoutConstraint pinViewToSuperview:subview useMargins:useMargins pinTop:YES topConstant:0 pinBottom:YES bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0];
|
||||
}
|
||||
|
||||
+ (nonnull NSDictionary *)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins pinTop:(BOOL)pinTop pinBottom:(BOOL)pinBottom pinLeft:(BOOL)pinLeft pinRight:(BOOL)pinRight {
|
||||
return [NSLayoutConstraint pinViewToSuperview:subview useMargins:useMargins pinTop:pinTop topConstant:0 pinBottom:pinBottom bottomConstant:0 pinLeft:pinLeft leftConstant:0 pinRight:pinRight rightConstant:0];
|
||||
}
|
||||
|
||||
+ (NSDictionary *)pinViewToSuperview:(UIView *)subview useMargins:(BOOL)useMargins pinTop:(BOOL)pinTop topConstant:(CGFloat)topConstant pinBottom:(BOOL)pinBottom bottomConstant:(CGFloat)bottomConstant pinLeft:(BOOL)pinLeft leftConstant:(CGFloat)leftConstant pinRight:(BOOL)pinRight rightConstant:(CGFloat)rightConstant {
|
||||
NSMutableDictionary *constraints = [[NSMutableDictionary alloc] init];
|
||||
if (pinTop) {
|
||||
[constraints setObject:[self pinViewTopToSuperview:subview useMargins:useMargins constant:topConstant] forKey:ConstraintTop];
|
||||
}
|
||||
if (pinLeft) {
|
||||
[constraints setObject:[self pinViewLeftToSuperview:subview useMargins:useMargins constant:topConstant] forKey:ConstraintLeading];
|
||||
}
|
||||
if (pinRight) {
|
||||
[constraints setObject:[self pinViewRightToSuperview:subview useMargins:useMargins constant:topConstant] forKey:ConstraintTrailing];
|
||||
}
|
||||
if (pinBottom) {
|
||||
[constraints setObject:[self pinViewBottomToSuperview:subview useMargins:useMargins constant:topConstant] forKey:ConstraintBot];
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
|
||||
+ (NSLayoutConstraint *)pinViewTopToSuperview:(UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant {
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
import UIKit
|
||||
|
||||
@objcMembers open class NavigationController: UINavigationController {
|
||||
public var separatorView: SeparatorView?
|
||||
public var separatorView: Line?
|
||||
|
||||
public static func navigationController() -> Self? {
|
||||
return MVMCoreActionUtility.initializerClassCheck(MVMCoreUISession.sharedGlobal()?.navigationController, classToVerify: self) as? Self
|
||||
@ -28,8 +28,8 @@ import UIKit
|
||||
public static func setupNavigationController() -> Self? {
|
||||
let navigationController = self.init()
|
||||
style(navigationController.navigationBar)
|
||||
navigationController.separatorView = SeparatorView.separatorAdd(to: navigationController.navigationBar, position: SeparatorPositionBot, withHorizontalPadding: 0)
|
||||
navigationController.separatorView?.setAsLight()
|
||||
navigationController.separatorView = Line(pinTo: navigationController.navigationBar, edge: .bottom, useMargin: false)
|
||||
navigationController.separatorView?.style = .standard
|
||||
MVMCoreUISession.sharedGlobal()?.navigationController = navigationController
|
||||
MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController
|
||||
MVMCoreNavigationHandler.shared()?.navigationController = navigationController
|
||||
|
||||
@ -21,8 +21,8 @@ import UIKit
|
||||
private var caretViewHeightSizeObject: MFSizeObject?
|
||||
|
||||
// For separation between cells.
|
||||
public var topSeparatorView: SeparatorView?
|
||||
public var bottomSeparatorView: SeparatorView?
|
||||
public var topSeparatorView: Line?
|
||||
public var bottomSeparatorView: Line?
|
||||
public enum SeparatorFrequency: String {
|
||||
case all
|
||||
case allExceptTop
|
||||
@ -57,21 +57,22 @@ import UIKit
|
||||
open func styleStandard() {
|
||||
topMarginPadding = 24
|
||||
bottomMarginPadding = 24
|
||||
bottomSeparatorView?.show()
|
||||
bottomSeparatorView?.setAsLight()
|
||||
topSeparatorView?.style = .none
|
||||
bottomSeparatorView?.style = .standard
|
||||
}
|
||||
|
||||
open func styleHeader() {
|
||||
topMarginPadding = 48
|
||||
bottomMarginPadding = 16
|
||||
bottomSeparatorView?.show()
|
||||
bottomSeparatorView?.setAsRegular()
|
||||
topSeparatorView?.style = .none
|
||||
bottomSeparatorView?.style = .thin
|
||||
}
|
||||
|
||||
open func styleNone() {
|
||||
topMarginPadding = 0
|
||||
bottomMarginPadding = 0
|
||||
bottomSeparatorView?.hide()
|
||||
topSeparatorView?.style = .none
|
||||
bottomSeparatorView?.style = .none
|
||||
}
|
||||
|
||||
/// Adds the molecule to the view.
|
||||
@ -111,23 +112,25 @@ import UIKit
|
||||
// MARK: - MFViewProtocol
|
||||
public func updateView(_ size: CGFloat) {
|
||||
MFStyler.setMarginsFor(self, size: size, defaultHorizontal: updateViewHorizontalDefaults, top: topMarginPadding, bottom: bottomMarginPadding)
|
||||
|
||||
if accessoryView != nil {
|
||||
// Smaller left margin if accessory view.
|
||||
var margin = directionalLayoutMargins
|
||||
margin.trailing = 16
|
||||
contentView.directionalLayoutMargins = margin
|
||||
|
||||
// Update caret automatically.
|
||||
if let caretView = caretView, let widthObject = caretViewWidthSizeObject, let heightObject = caretViewHeightSizeObject {
|
||||
caretView.frame = CGRect(x: 0, y: 0, width: widthObject.getValueBased(onSize: size), height: heightObject.getValueBased(onSize: size))
|
||||
}
|
||||
} else {
|
||||
contentView.directionalLayoutMargins = directionalLayoutMargins
|
||||
}
|
||||
topSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading)
|
||||
bottomSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading)
|
||||
|
||||
molecule?.updateView(size)
|
||||
if let _ = accessoryView, let caretView = caretView, let widthObject = caretViewWidthSizeObject, let heightObject = caretViewHeightSizeObject {
|
||||
caretView.frame = CGRect(x: 0, y: 0, width: widthObject.getValueBased(onSize: size), height: heightObject.getValueBased(onSize: size))
|
||||
}
|
||||
|
||||
topSeparatorView?.updateView(size)
|
||||
bottomSeparatorView?.updateView(size)
|
||||
|
||||
molecule?.updateView(size)
|
||||
}
|
||||
|
||||
public func setupView() {
|
||||
@ -256,8 +259,8 @@ import UIKit
|
||||
setSeparatorFrequency(separatorFrequency, indexPath: indexPath)
|
||||
}
|
||||
} else {
|
||||
topSeparatorView?.hide()
|
||||
bottomSeparatorView?.setAsLight()
|
||||
topSeparatorView?.style = .standard
|
||||
bottomSeparatorView?.style = .standard
|
||||
setSeparatorFrequency(TableViewCell.SeparatorFrequency.allExceptTop, indexPath: indexPath)
|
||||
}
|
||||
}
|
||||
@ -275,12 +278,22 @@ import UIKit
|
||||
// MARK: - Separator
|
||||
open func addSeparatorsIfNeeded() {
|
||||
if topSeparatorView == nil {
|
||||
topSeparatorView = SeparatorView.separatorAdd(to: self, position: SeparatorPositionTop)
|
||||
topSeparatorView?.hide()
|
||||
let line = Line()
|
||||
line.style = .none
|
||||
addSubview(line)
|
||||
NSLayoutConstraint.pinViewTop(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
||||
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||
NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||
topSeparatorView = line
|
||||
}
|
||||
if bottomSeparatorView == nil {
|
||||
bottomSeparatorView = SeparatorView.separatorAdd(to: self, position: SeparatorPositionBot)
|
||||
bottomSeparatorView?.hide()
|
||||
let line = Line()
|
||||
line.style = .none
|
||||
addSubview(line)
|
||||
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
||||
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||
NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||
bottomSeparatorView = line
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,26 +302,26 @@ import UIKit
|
||||
switch separatorFrequency {
|
||||
case .all:
|
||||
if indexPath.row == 0 {
|
||||
topSeparatorView?.show()
|
||||
topSeparatorView?.isHidden = false
|
||||
} else {
|
||||
topSeparatorView?.hide()
|
||||
topSeparatorView?.isHidden = true
|
||||
}
|
||||
bottomSeparatorView?.show()
|
||||
bottomSeparatorView?.isHidden = false
|
||||
case .allExceptBottom:
|
||||
topSeparatorView?.show()
|
||||
bottomSeparatorView?.hide()
|
||||
topSeparatorView?.isHidden = false
|
||||
bottomSeparatorView?.isHidden = true
|
||||
case .between:
|
||||
if indexPath.row == 0 {
|
||||
topSeparatorView?.hide()
|
||||
topSeparatorView?.isHidden = true
|
||||
} else {
|
||||
topSeparatorView?.show()
|
||||
topSeparatorView?.isHidden = false
|
||||
}
|
||||
bottomSeparatorView?.hide()
|
||||
bottomSeparatorView?.isHidden = true
|
||||
case .allExceptTop:
|
||||
fallthrough
|
||||
default:
|
||||
topSeparatorView?.hide()
|
||||
bottomSeparatorView?.show()
|
||||
topSeparatorView?.isHidden = true
|
||||
bottomSeparatorView?.isHidden = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
import UIKit
|
||||
|
||||
public class StandardHeaderView: ViewConstrainingView {
|
||||
var separatorView: SeparatorView?
|
||||
var line: Line?
|
||||
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
separatorView?.updateView(size)
|
||||
line?.updateView(size)
|
||||
}
|
||||
|
||||
public override func setupView() {
|
||||
@ -24,21 +24,12 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
updateViewHorizontalDefaults = true
|
||||
topMarginPadding = PaddingDefaultVerticalSpacing
|
||||
bottomMarginPadding = PaddingDefaultVerticalSpacing
|
||||
if separatorView == nil, let separatorView = SeparatorView.separatorAdd(to: self, position: SeparatorPositionBot, withHorizontalPadding: 0) {
|
||||
separatorView.setAsHeavy()
|
||||
addSubview(separatorView)
|
||||
self.separatorView = separatorView
|
||||
}
|
||||
}
|
||||
|
||||
public override func setLeftPinConstant(_ constant: CGFloat) {
|
||||
super.setLeftPinConstant(constant)
|
||||
separatorView?.leftPin?.constant = constant
|
||||
}
|
||||
|
||||
public override func setRightPinConstant(_ constant: CGFloat) {
|
||||
super.setRightPinConstant(constant)
|
||||
separatorView?.rightPin?.constant = constant
|
||||
|
||||
guard line == nil else { return }
|
||||
let line = Line(pinTo: self, edge: .bottom, useMargin: true)
|
||||
line.style = .heavy
|
||||
addSubview(line)
|
||||
self.line = line
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
@ -50,7 +41,7 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
(molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false)
|
||||
|
||||
if let separatorJSON = json?.optionalDictionaryForKey("separator") {
|
||||
separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,8 +49,7 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
super.reset()
|
||||
topMarginPadding = PaddingDefaultVerticalSpacing
|
||||
bottomMarginPadding = PaddingDefaultVerticalSpacing
|
||||
separatorView?.setAsHeavy()
|
||||
separatorView?.show()
|
||||
line?.style = .heavy
|
||||
}
|
||||
|
||||
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
dispatch_once(&onceToken, ^{
|
||||
mapping = [@{
|
||||
@"label": Label.class,
|
||||
@"line": SeparatorView.class,
|
||||
@"line": Line.class,
|
||||
@"button": ButtonView.class,
|
||||
@"textButton": MFTextButton.class,
|
||||
@"header": StandardHeaderView.class,
|
||||
@ -43,7 +43,6 @@
|
||||
@"progressbar": ProgressBar.class,
|
||||
@"circleProgress": GraphView.class,
|
||||
@"multiProgressBar": MultiProgress.class,
|
||||
@"checkbox": MVMCoreUICheckBox.class,
|
||||
@"radioButton": RadioButton.class,
|
||||
@"radioButtonLabel": RadioButtonLabel.class,
|
||||
@"listItem": MoleculeTableViewCell.class,
|
||||
|
||||
@ -76,14 +76,13 @@ open class MoleculeListTemplate: ThreeLayerTableViewController {
|
||||
return UITableViewCell()
|
||||
}
|
||||
let delegate = delegateObject() as? MVMCoreUIDelegateObject
|
||||
let moleculeCell = cell as? MVMCoreUIMoleculeViewProtocol
|
||||
moleculeCell?.reset?()
|
||||
if let protocolCell = cell as? MoleculeListCellProtocol {
|
||||
protocolCell.setSeparatorWithJSON?(loadObject?.pageJSON?.optionalDictionaryForKey("separator"), delegateObject: delegate, additionalData: nil, indexPath: indexPath)
|
||||
}
|
||||
if let protocolCell = cell as? MVMCoreUIMoleculeViewProtocol {
|
||||
protocolCell.reset?()
|
||||
protocolCell.setWithJSON(moleculeInfo.molecule, delegateObject: delegate, additionalData: nil)
|
||||
protocolCell.updateView(tableView.bounds.width)
|
||||
}
|
||||
moleculeCell?.setWithJSON(moleculeInfo.molecule, delegateObject: delegate, additionalData: nil)
|
||||
moleculeCell?.updateView(tableView.bounds.width)
|
||||
return cell
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user