alignment fix issues.
This commit is contained in:
parent
814d470775
commit
4050b784ed
@ -12,7 +12,7 @@
|
|||||||
@class Label;
|
@class Label;
|
||||||
@class MFSizeObject;
|
@class MFSizeObject;
|
||||||
|
|
||||||
@interface MVMCoreUICheckBox : UIControl <MVMCoreViewProtocol>
|
@interface MVMCoreUICheckBox : UIControl <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol>
|
||||||
|
|
||||||
@property (nullable, weak, nonatomic) MVMCoreUICheckMarkView *checkMark;
|
@property (nullable, weak, nonatomic) MVMCoreUICheckMarkView *checkMark;
|
||||||
@property (readonly, nonatomic) BOOL isSelected;
|
@property (readonly, nonatomic) BOOL isSelected;
|
||||||
|
|||||||
@ -9,10 +9,11 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||||
|
#import <MVMCoreUI/MVMCoreUIViewConstrainingProtocol.h>
|
||||||
@import MVMCore.MVMCoreViewProtocol;
|
@import MVMCore.MVMCoreViewProtocol;
|
||||||
typedef void(^ValueChangeBlock)(void);
|
typedef void(^ValueChangeBlock)(void);
|
||||||
|
|
||||||
@interface MVMCoreUISwitch : UIControl <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
@interface MVMCoreUISwitch : UIControl <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol>
|
||||||
|
|
||||||
@property (assign, nonatomic, getter=isOn) BOOL on;
|
@property (assign, nonatomic, getter=isOn) BOOL on;
|
||||||
@property (nullable, strong, nonatomic) UIColor *onTintColor;
|
@property (nullable, strong, nonatomic) UIColor *onTintColor;
|
||||||
|
|||||||
@ -20,27 +20,30 @@ import UIKit
|
|||||||
guard subviews.count == 0 else {
|
guard subviews.count == 0 else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0)
|
|
||||||
headlineBody.headlineLabel.styleB1(true)
|
headlineBody.headlineLabel.styleB1(true)
|
||||||
headlineBody.spaceBetweenLabelsConstant = 0
|
headlineBody.spaceBetweenLabelsConstant = 0
|
||||||
addSubview(headlineBody)
|
|
||||||
addSubview(imageView)
|
|
||||||
|
|
||||||
NSLayoutConstraint.pinViewTop(toSuperview: headlineBody, useMargins: true, constant: 0).isActive = true
|
let view = MVMCoreUICommonViewsUtility.commonView()
|
||||||
NSLayoutConstraint.pinViewRight(toSuperview: headlineBody, useMargins: true, constant: 0).isActive = true
|
addSubview(view)
|
||||||
layoutMarginsGuide.bottomAnchor.constraint(greaterThanOrEqualTo: headlineBody.bottomAnchor).isActive = true
|
pinView(toSuperView: view)
|
||||||
var constraint = NSLayoutConstraint.pinViewBottom(toSuperview: headlineBody, useMargins: true, constant: 0)
|
view.addSubview(headlineBody)
|
||||||
|
view.addSubview(imageView)
|
||||||
|
|
||||||
|
headlineBody.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
|
||||||
|
view.rightAnchor.constraint(equalTo: headlineBody.rightAnchor).isActive = true
|
||||||
|
view.bottomAnchor.constraint(greaterThanOrEqualTo: headlineBody.bottomAnchor).isActive = true
|
||||||
|
var constraint = view.bottomAnchor.constraint(equalTo: headlineBody.bottomAnchor)
|
||||||
constraint.priority = .defaultLow
|
constraint.priority = .defaultLow
|
||||||
constraint.isActive = true
|
constraint.isActive = true
|
||||||
|
|
||||||
imageView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
imageView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
|
||||||
NSLayoutConstraint.pinViewLeft(toSuperview: imageView, useMargins: true, constant: 0).isActive = true
|
imageView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
|
||||||
imageView.topAnchor.constraint(greaterThanOrEqualTo: layoutMarginsGuide.topAnchor).isActive = true
|
imageView.topAnchor.constraint(greaterThanOrEqualTo: view.topAnchor).isActive = true
|
||||||
layoutMarginsGuide.bottomAnchor.constraint(greaterThanOrEqualTo: imageView.bottomAnchor).isActive = true
|
view.bottomAnchor.constraint(greaterThanOrEqualTo: imageView.bottomAnchor).isActive = true
|
||||||
constraint = NSLayoutConstraint.pinViewBottom(toSuperview: imageView, useMargins: true, constant: 0)
|
constraint = view.bottomAnchor.constraint(equalTo: imageView.bottomAnchor)
|
||||||
constraint.priority = UILayoutPriority(rawValue: 200)
|
constraint.priority = UILayoutPriority(rawValue: 200)
|
||||||
constraint.isActive = true
|
constraint.isActive = true
|
||||||
constraint = NSLayoutConstraint.pinViewTop(toSuperview: imageView, useMargins: true, constant: 0)
|
constraint = imageView.topAnchor.constraint(equalTo: view.topAnchor)
|
||||||
constraint.priority = UILayoutPriority(rawValue: 200)
|
constraint.priority = UILayoutPriority(rawValue: 200)
|
||||||
constraint.isActive = true
|
constraint.isActive = true
|
||||||
|
|
||||||
|
|||||||
@ -25,8 +25,12 @@ import UIKit
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
headlineBody.styleListItem()
|
headlineBody.styleListItem()
|
||||||
addSubview(headlineBody)
|
let view = MVMCoreUICommonViewsUtility.commonView()
|
||||||
addSubview(mvmSwitch)
|
addSubview(view)
|
||||||
|
pinView(toSuperView: view)
|
||||||
|
|
||||||
|
view.addSubview(headlineBody)
|
||||||
|
view.addSubview(mvmSwitch)
|
||||||
NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: mvmSwitch)
|
NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: mvmSwitch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,9 +24,13 @@ import UIKit
|
|||||||
guard mvmSwitch.superview == nil else {
|
guard mvmSwitch.superview == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let view = MVMCoreUICommonViewsUtility.commonView()
|
||||||
|
addSubview(view)
|
||||||
|
pinView(toSuperView: view)
|
||||||
|
|
||||||
headlineBodyTextButton.headlineBody.styleListItem()
|
headlineBodyTextButton.headlineBody.styleListItem()
|
||||||
addSubview(headlineBodyTextButton)
|
view.addSubview(headlineBodyTextButton)
|
||||||
addSubview(mvmSwitch)
|
view.addSubview(mvmSwitch)
|
||||||
NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBodyTextButton, rightView: mvmSwitch)
|
NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBodyTextButton, rightView: mvmSwitch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,8 +24,12 @@ import UIKit
|
|||||||
guard mvmSwitch.superview == nil else {
|
guard mvmSwitch.superview == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
addSubview(label)
|
let view = MVMCoreUICommonViewsUtility.commonView()
|
||||||
addSubview(mvmSwitch)
|
addSubview(view)
|
||||||
|
pinView(toSuperView: view)
|
||||||
|
|
||||||
|
view.addSubview(label)
|
||||||
|
view.addSubview(mvmSwitch)
|
||||||
label.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
label.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
||||||
NSLayoutConstraint.pinSubviewsCenter(leftView: label, rightView: mvmSwitch)
|
NSLayoutConstraint.pinSubviewsCenter(leftView: label, rightView: mvmSwitch)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,33 +70,37 @@ open class HeadlineBody: ViewConstrainingView {
|
|||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
|
|
||||||
addSubview(headlineLabel)
|
let view = MVMCoreUICommonViewsUtility.commonView()
|
||||||
addSubview(messageLabel)
|
addSubview(view)
|
||||||
|
pinView(toSuperView: view)
|
||||||
|
|
||||||
|
view.addSubview(headlineLabel)
|
||||||
|
view.addSubview(messageLabel)
|
||||||
|
|
||||||
headlineLabel.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
headlineLabel.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
||||||
messageLabel.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
messageLabel.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
||||||
setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
||||||
|
|
||||||
topPin = headlineLabel.topAnchor.constraint(equalTo: topAnchor, constant: 0)
|
topPin = headlineLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 0)
|
||||||
topPin?.isActive = true
|
topPin?.isActive = true
|
||||||
|
|
||||||
spaceBetweenLabels = messageLabel.topAnchor.constraint(equalTo: headlineLabel.bottomAnchor, constant: spaceBetweenLabelsConstant)
|
spaceBetweenLabels = messageLabel.topAnchor.constraint(equalTo: headlineLabel.bottomAnchor, constant: spaceBetweenLabelsConstant)
|
||||||
spaceBetweenLabels?.isActive = true
|
spaceBetweenLabels?.isActive = true
|
||||||
|
|
||||||
leftConstraintTitle = headlineLabel.leftAnchor.constraint(equalTo: leftAnchor)
|
leftConstraintTitle = headlineLabel.leftAnchor.constraint(equalTo: view.leftAnchor)
|
||||||
leftConstraintTitle?.isActive = true
|
leftConstraintTitle?.isActive = true
|
||||||
|
|
||||||
rightConstraintTitle = rightAnchor.constraint(equalTo: headlineLabel.rightAnchor)
|
rightConstraintTitle = view.rightAnchor.constraint(equalTo: headlineLabel.rightAnchor)
|
||||||
rightConstraintTitle?.isActive = true
|
rightConstraintTitle?.isActive = true
|
||||||
|
|
||||||
leftConstraintMessage = messageLabel.leftAnchor.constraint(equalTo: leftAnchor)
|
leftConstraintMessage = messageLabel.leftAnchor.constraint(equalTo: view.leftAnchor)
|
||||||
leftConstraintMessage?.isActive = true
|
leftConstraintMessage?.isActive = true
|
||||||
|
|
||||||
rightConstraintMessage = rightAnchor.constraint(equalTo: messageLabel.rightAnchor)
|
rightConstraintMessage = view.rightAnchor.constraint(equalTo: messageLabel.rightAnchor)
|
||||||
rightConstraintMessage?.isActive = true
|
rightConstraintMessage?.isActive = true
|
||||||
|
|
||||||
bottomPin = bottomAnchor.constraint(equalTo: messageLabel.bottomAnchor, constant: 0)
|
bottomPin = view.bottomAnchor.constraint(equalTo: messageLabel.bottomAnchor, constant: 0)
|
||||||
bottomPin?.isActive = true
|
bottomPin?.isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,16 +113,6 @@ open class HeadlineBody: ViewConstrainingView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setLeftPinConstant(_ constant: CGFloat) {
|
|
||||||
leftConstraintTitle?.constant = constant
|
|
||||||
leftConstraintMessage?.constant = constant
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func setRightPinConstant(_ constant: CGFloat) {
|
|
||||||
rightConstraintTitle?.constant = constant
|
|
||||||
rightConstraintMessage?.constant = constant
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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]?) {
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
|||||||
@ -28,23 +28,27 @@ import UIKit
|
|||||||
guard subviews.count == 0 else {
|
guard subviews.count == 0 else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
addSubview(headlineBody)
|
let view = MVMCoreUICommonViewsUtility.commonView()
|
||||||
addSubview(textButton)
|
addSubview(view)
|
||||||
|
pinView(toSuperView: view)
|
||||||
|
|
||||||
|
view.addSubview(headlineBody)
|
||||||
|
view.addSubview(textButton)
|
||||||
headlineBody.styleListItem()
|
headlineBody.styleListItem()
|
||||||
|
|
||||||
headlineBody.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor, constant: 0).isActive = true
|
headlineBody.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
|
||||||
headlineBody.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
|
headlineBody.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
|
||||||
var constraint = layoutMarginsGuide.rightAnchor.constraint(equalTo: headlineBody.rightAnchor)
|
var constraint = view.rightAnchor.constraint(equalTo: headlineBody.rightAnchor)
|
||||||
constraint.priority = .defaultHigh
|
constraint.priority = .defaultHigh
|
||||||
constraint.isActive = true
|
constraint.isActive = true
|
||||||
|
|
||||||
spaceBetween = textButton.topAnchor.constraint(equalTo: headlineBody.bottomAnchor, constant: spaceBetweenConstant)
|
spaceBetween = textButton.topAnchor.constraint(equalTo: headlineBody.bottomAnchor, constant: spaceBetweenConstant)
|
||||||
spaceBetween?.isActive = true
|
spaceBetween?.isActive = true
|
||||||
|
|
||||||
textButton.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
|
textButton.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
|
||||||
layoutMarginsGuide.bottomAnchor.constraint(equalTo: textButton.bottomAnchor).isActive = true
|
view.bottomAnchor.constraint(equalTo: textButton.bottomAnchor).isActive = true
|
||||||
layoutMarginsGuide.rightAnchor.constraint(greaterThanOrEqualTo: textButton.rightAnchor).isActive = true
|
view.rightAnchor.constraint(greaterThanOrEqualTo: textButton.rightAnchor).isActive = true
|
||||||
constraint = layoutMarginsGuide.rightAnchor.constraint(equalTo: textButton.rightAnchor)
|
constraint = view.rightAnchor.constraint(equalTo: textButton.rightAnchor)
|
||||||
constraint.priority = .defaultHigh
|
constraint.priority = .defaultHigh
|
||||||
constraint.isActive = true
|
constraint.isActive = true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,11 +27,15 @@ public class StackItem {
|
|||||||
func update(with json: [AnyHashable: Any]) {
|
func update(with json: [AnyHashable: Any]) {
|
||||||
spacing = json.optionalCGFloatForKey("spacing")
|
spacing = json.optionalCGFloatForKey("spacing")
|
||||||
percentage = json["percent"] as? Int
|
percentage = json["percent"] as? Int
|
||||||
if let alignment = json.optionalStringForKey("verticalAlignment") {
|
if let alignment = json.stringOptionalWithChainOfKeysOrIndexes([KeyMolecule,"verticalAlignment"]) {
|
||||||
verticalAlignment = ViewConstrainingView.getAlignmentFor(alignment, defaultAlignment: .fill)
|
verticalAlignment = ViewConstrainingView.getAlignmentFor(alignment, defaultAlignment: .fill)
|
||||||
|
} else {
|
||||||
|
verticalAlignment = nil
|
||||||
}
|
}
|
||||||
if let alignment = json.optionalStringForKey("horizontalAlignment") {
|
if let alignment = json.stringOptionalWithChainOfKeysOrIndexes([KeyMolecule,"horizontalAlignment"]) {
|
||||||
horizontalAlignment = ViewConstrainingView.getAlignmentFor(alignment, defaultAlignment: .fill)
|
horizontalAlignment = ViewConstrainingView.getAlignmentFor(alignment, defaultAlignment: .fill)
|
||||||
|
} else {
|
||||||
|
horizontalAlignment = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user