Merge branch 'feature/unified_grid' into 'develop'
Feature/unified grid See merge request BPHV_MIPS/mvm_core_ui!696
This commit is contained in:
commit
a641a3775b
@ -347,6 +347,7 @@
|
||||
D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */; };
|
||||
D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */; };
|
||||
D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; };
|
||||
D23A8FD9260CE004007E14CE /* MFStyler+PaddingExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FD5260CDF01007E14CE /* MFStyler+PaddingExtension.swift */; };
|
||||
D23A8FEB26122F69007E14CE /* VisibleBehaviorForVideoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FEA26122F69007E14CE /* VisibleBehaviorForVideoModel.swift */; };
|
||||
D23A8FEE26122F7D007E14CE /* VisibleBehaviorForVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FED26122F7D007E14CE /* VisibleBehaviorForVideo.swift */; };
|
||||
D23A8FF82612308D007E14CE /* PageBehaviorProtocolRequirer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FF72612308D007E14CE /* PageBehaviorProtocolRequirer.swift */; };
|
||||
@ -910,6 +911,7 @@
|
||||
D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescription.swift; sourceTree = "<group>"; };
|
||||
D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescriptionModel.swift; sourceTree = "<group>"; };
|
||||
D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = "<group>"; };
|
||||
D23A8FD5260CDF01007E14CE /* MFStyler+PaddingExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFStyler+PaddingExtension.swift"; sourceTree = "<group>"; };
|
||||
D23A8FEA26122F69007E14CE /* VisibleBehaviorForVideoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisibleBehaviorForVideoModel.swift; sourceTree = "<group>"; };
|
||||
D23A8FED26122F7D007E14CE /* VisibleBehaviorForVideo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisibleBehaviorForVideo.swift; sourceTree = "<group>"; };
|
||||
D23A8FF72612308D007E14CE /* PageBehaviorProtocolRequirer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageBehaviorProtocolRequirer.swift; sourceTree = "<group>"; };
|
||||
@ -2038,6 +2040,7 @@
|
||||
D29DF13921E68637003B2FB9 /* MFStyler.m */,
|
||||
0A6682A92435125F00AD3CA1 /* Styler.swift */,
|
||||
0A6682AB243531C300AD3CA1 /* Padding.swift */,
|
||||
D23A8FD5260CDF01007E14CE /* MFStyler+PaddingExtension.swift */,
|
||||
);
|
||||
path = Styles;
|
||||
sourceTree = "<group>";
|
||||
@ -2884,6 +2887,7 @@
|
||||
D253BB9C245874F8002DE544 /* BGImageMolecule.swift in Sources */,
|
||||
D2C78CD224228BBD00B69FDE /* ActionOpenPanelModel.swift in Sources */,
|
||||
AA617AB02453010A00910B8F /* ListDeviceComplexLinkSmall.swift in Sources */,
|
||||
D23A8FD9260CE004007E14CE /* MFStyler+PaddingExtension.swift in Sources */,
|
||||
C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */,
|
||||
01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */,
|
||||
D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */,
|
||||
|
||||
@ -168,10 +168,14 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
}
|
||||
|
||||
open override var intrinsicContentSize: CGSize {
|
||||
|
||||
let size = super.intrinsicContentSize
|
||||
let width = size.width + (2 * getInnerPadding())
|
||||
return CGSize(width: max(width, getMinimumWidth()), height: getHeight())
|
||||
if buttonSize == .tiny {
|
||||
let size = super.intrinsicContentSize
|
||||
let width = size.width + (2 * getInnerPadding())
|
||||
return CGSize(width: max(width, getMinimumWidth()), height: getHeight())
|
||||
} else {
|
||||
let width = Padding.Component.gutterForApplicationWidth + (2.0 * Padding.Component.columnFor(size: MVMCoreUISplitViewController.getApplicationViewWidth()))
|
||||
return CGSize(width: min(292, width), height: getHeight())
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -14,7 +14,7 @@ open class RadioBoxes: View {
|
||||
public var collectionViewHeight: NSLayoutConstraint!
|
||||
private let boxWidth: CGFloat = 151.0
|
||||
private let boxHeight: CGFloat = 64.0
|
||||
private let itemSpacing: CGFloat = 8.0
|
||||
private var itemSpacing: CGFloat = 12.0
|
||||
private var numberOfColumns: CGFloat = 2.0
|
||||
private var radioBoxesModel: RadioBoxesModel? {
|
||||
return model as? RadioBoxesModel
|
||||
@ -71,6 +71,7 @@ open class RadioBoxes: View {
|
||||
@objc override open func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
self.size = size
|
||||
itemSpacing = Padding.Component.gutterFor(size: size)
|
||||
collectionView.updateView(size)
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
//------------------------------------------------------
|
||||
|
||||
let containingStack: Stack<StackModel>
|
||||
let stackSpacing: CGFloat = 5.0
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -31,7 +30,7 @@
|
||||
(view: rightHeadlineBodyLink, model: StackItemModel(percent: 50, verticalAlignment: .leading))],
|
||||
axis: .horizontal)
|
||||
|
||||
containingStack = Stack<StackModel>.createStack(with: [stackHeadline1], spacing: 0)
|
||||
containingStack = Stack<StackModel>.createStack(with: [stackHeadline1], spacing: Padding.Component.gutterForApplicationWidth)
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
stack = Stack<StackModel>.createStack(with: [(view: leftDropDown, model: StackItemModel(percent: 50, horizontalAlignment: .fill)),
|
||||
(view: rightDropDown, model: StackItemModel(percent: 50, horizontalAlignment: .fill))],
|
||||
axis: .horizontal, spacing: 9)
|
||||
axis: .horizontal, spacing: Padding.Component.gutterForApplicationWidth)
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,12 @@ open class HeaderView: Container {
|
||||
addSubview(molecule)
|
||||
containerHelper.constrainView(molecule)
|
||||
self.molecule = molecule
|
||||
guard let margins = molecule.superview?.layoutMarginsGuide else { return }
|
||||
containerHelper.rightConstraint?.isActive = false
|
||||
containerHelper.rightConstraint = margins.rightAnchor.constraint(equalTo: molecule.rightAnchor)
|
||||
containerHelper.rightConstraint?.priority = .defaultHigh
|
||||
containerHelper.rightConstraint?.isActive = true
|
||||
molecule.widthAnchor.constraint(equalToConstant: HeaderMaxWidth).isActive = true
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
|
||||
@ -24,6 +24,16 @@ public class MoleculeHeaderView: MoleculeContainer {
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
public override func addMolecule(_ molecule: UIView) {
|
||||
super.addMolecule(molecule)
|
||||
guard let margins = molecule.superview?.layoutMarginsGuide else { return }
|
||||
containerHelper.rightConstraint?.isActive = false
|
||||
containerHelper.rightConstraint = margins.rightAnchor.constraint(equalTo: molecule.rightAnchor)
|
||||
containerHelper.rightConstraint?.priority = .defaultHigh
|
||||
containerHelper.rightConstraint?.isActive = true
|
||||
molecule.widthAnchor.constraint(lessThanOrEqualToConstant: HeaderMaxWidth).isActive = true
|
||||
}
|
||||
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
line.updateView(size)
|
||||
|
||||
@ -32,7 +32,7 @@ import UIKit
|
||||
|
||||
if let rightView = createRightView() {
|
||||
addSubview(rightView)
|
||||
rightView.leftAnchor.constraint(equalTo: radioButton.rightAnchor, constant: PaddingHorizontalBetweenRelatedItems).isActive = true
|
||||
rightView.leftAnchor.constraint(equalTo: radioButton.rightAnchor, constant: Padding.Component.gutterForApplicationWidth).isActive = true
|
||||
rightView.rightAnchor.constraint(equalTo: layoutMarginsGuide.rightAnchor, constant: 0).isActive = true
|
||||
|
||||
var constraint = rightView.topAnchor.constraint(greaterThanOrEqualTo: layoutMarginsGuide.topAnchor, constant: PaddingOne)
|
||||
|
||||
@ -198,11 +198,13 @@ extension Tabs: UICollectionViewDelegateFlowLayout {
|
||||
}
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
|
||||
if !paddingBeforeFirstTab && section == 0 {
|
||||
return .zero
|
||||
} else {
|
||||
guard section == 0 else {
|
||||
return UIEdgeInsets(top: 0, left: sectionPadding, bottom: 0, right: 0)
|
||||
}
|
||||
guard paddingBeforeFirstTab else {
|
||||
return .zero
|
||||
}
|
||||
return UIEdgeInsets(top: 0, left: Padding.Component.horizontalPaddingForApplicationWidth, bottom: 0, right: 0)
|
||||
}
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
||||
|
||||
@ -51,7 +51,7 @@ import UIKit
|
||||
stack.addArrangedSubview(primaryButton)
|
||||
NSLayoutConstraint.constraintPinSubview(toSuperview: stack)
|
||||
stack.axis = .horizontal
|
||||
stack.spacing = 10
|
||||
stack.spacing = Padding.Component.gutterForApplicationWidth
|
||||
equalWidthConstraint = secondaryButton.widthAnchor.constraint(equalTo: primaryButton.widthAnchor, multiplier: 1)
|
||||
equalWidthConstraint?.isActive = true
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@ open class CollapsableNotificationModel: NotificationModel {
|
||||
super.init(with: headline)
|
||||
}
|
||||
|
||||
open override func setDefault() {
|
||||
super.setDefault()
|
||||
open override func setDefaults() {
|
||||
super.setDefaults()
|
||||
if topLabel.textColor == nil {
|
||||
topLabel.textColor = Color(uiColor: .white)
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers open class NotificationView: View {
|
||||
@objcMembers open class NotificationView: Container {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Outlets
|
||||
//--------------------------------------------------
|
||||
@ -43,19 +43,13 @@ import Foundation
|
||||
|
||||
labelStack = Stack<StackModel>.createStack(with: [headline, body], spacing: 0)
|
||||
horizontalStack = Stack<StackModel>.createStack(with: [(view: labelStack, model: StackItemModel()),(view: button, model: StackItemModel(horizontalAlignment: .fill)),(view: closeButton, model: StackItemModel(horizontalAlignment: .fill))], axis: .horizontal)
|
||||
addSubview(horizontalStack)
|
||||
NSLayoutConstraint.constraintPinSubview(horizontalStack, pinTop: true, topConstant: PaddingTwo, pinBottom: true, bottomConstant: PaddingTwo, pinLeft: true, leftConstant: PaddingThree, pinRight: true, rightConstant: PaddingThree)
|
||||
addAndContain(horizontalStack)
|
||||
labelStack.restack()
|
||||
horizontalStack.restack()
|
||||
|
||||
heightAnchor.constraint(equalToConstant: Self.viewHeight).isActive = true
|
||||
}
|
||||
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
horizontalStack.updateView(size)
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
backgroundColor = .mvmGreen()
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
//
|
||||
|
||||
|
||||
open class NotificationModel: MoleculeModelProtocol {
|
||||
|
||||
open class NotificationModel: ContainerModel, MoleculeModelProtocol {
|
||||
|
||||
/**
|
||||
The style of the notification:
|
||||
- success, green background, white content
|
||||
@ -42,13 +42,19 @@ open class NotificationModel: MoleculeModelProtocol {
|
||||
|
||||
public init(with headline: LabelModel) {
|
||||
self.headline = headline
|
||||
super.init()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Default
|
||||
//--------------------------------------------------
|
||||
|
||||
open func setDefault() {
|
||||
open override func setDefaults() {
|
||||
useHorizontalMargins = true
|
||||
useVerticalMargins = true
|
||||
topPadding = PaddingTwo
|
||||
bottomPadding = PaddingTwo
|
||||
|
||||
if backgroundColor == nil {
|
||||
switch style {
|
||||
case .error:
|
||||
@ -139,10 +145,10 @@ open class NotificationModel: MoleculeModelProtocol {
|
||||
if let style = try typeContainer.decodeIfPresent(NotificationModel.Style.self, forKey: .style) {
|
||||
self.style = style
|
||||
}
|
||||
setDefault()
|
||||
super.init()
|
||||
}
|
||||
|
||||
open func encode(to encoder: Encoder) throws {
|
||||
|
||||
open override func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
|
||||
@ -13,14 +13,12 @@
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
static let defaultSpacing: CGFloat = 16.0
|
||||
|
||||
public class var identifier: String { "stack" }
|
||||
|
||||
public var backgroundColor: Color?
|
||||
public var molecules: [StackItemModelProtocol & MoleculeModelProtocol]
|
||||
public var axis: NSLayoutConstraint.Axis = .vertical
|
||||
public var spacing: CGFloat = StackModel.defaultSpacing
|
||||
public var spacing: CGFloat = Padding.Four
|
||||
public var useStackSpacingBeforeFirstItem = false
|
||||
|
||||
public var children: [MoleculeModelProtocol] {
|
||||
@ -38,6 +36,8 @@
|
||||
}
|
||||
if let spacing = spacing {
|
||||
self.spacing = spacing
|
||||
} else if axis == .horizontal {
|
||||
self.spacing = Padding.Component.gutterForApplicationWidth
|
||||
}
|
||||
super.init()
|
||||
}
|
||||
@ -66,6 +66,8 @@
|
||||
}
|
||||
if let spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) {
|
||||
self.spacing = spacing
|
||||
} else if axis == .horizontal {
|
||||
self.spacing = Padding.Component.gutterForApplicationWidth
|
||||
}
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
try super.init(from: decoder)
|
||||
|
||||
@ -34,8 +34,7 @@
|
||||
[view addSubview:activityIndicatorView];
|
||||
self.activityIndicator = activityIndicatorView;
|
||||
self.activityIndicator.accessibilityIdentifier = @"Loader";
|
||||
|
||||
[NSLayoutConstraint constraintPinView:activityIndicatorView heightConstraint:YES heightConstant:PaddingSix widthConstraint:YES widthConstant:PaddingSix];
|
||||
[activityIndicatorView pinWidthAndHeight];
|
||||
|
||||
// Sets the constraints for the activityIndicatorView
|
||||
[NSLayoutConstraint constraintPinSubview:activityIndicatorView pinCenterX:YES pinCenterY:YES];
|
||||
|
||||
@ -55,6 +55,6 @@ public extension NSLayoutConstraint {
|
||||
}
|
||||
leftView.leadingAnchor.constraint(equalTo: superView.layoutMarginsGuide.leadingAnchor).isActive = true
|
||||
superView.layoutMarginsGuide.trailingAnchor.constraint(equalTo: rightView.trailingAnchor).isActive = true
|
||||
rightView.leftAnchor.constraint(greaterThanOrEqualTo: leftView.rightAnchor, constant: PaddingHorizontalBetweenRelatedItems).isActive = true
|
||||
rightView.leftAnchor.constraint(greaterThanOrEqualTo: leftView.rightAnchor, constant: Padding.Component.gutterForApplicationWidth).isActive = true
|
||||
}
|
||||
}
|
||||
|
||||
44
MVMCoreUI/Styles/MFStyler+PaddingExtension.swift
Normal file
44
MVMCoreUI/Styles/MFStyler+PaddingExtension.swift
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// MFStyler+PaddingExtension.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 3/25/21.
|
||||
// Copyright © 2021 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public extension MFStyler {
|
||||
|
||||
@objc static func bridgeGetGutterSizeForApplicationWidth() -> CGFloat {
|
||||
Padding.Component.gutterForApplicationWidth
|
||||
}
|
||||
|
||||
@objc static func bridgeGetGutterSize(for size: CGFloat) -> CGFloat {
|
||||
Padding.Component.gutterFor(size: size)
|
||||
}
|
||||
|
||||
@objc static func bridgeGetColumnSizeForApplicationWidth() -> CGFloat {
|
||||
Padding.Component.columnFor(size: MVMCoreUISplitViewController.getApplicationViewWidth())
|
||||
}
|
||||
|
||||
@objc static func bridgeGetColumnSize(for size: CGFloat) -> CGFloat {
|
||||
Padding.Component.columnFor(size: size)
|
||||
}
|
||||
|
||||
@objc static func bridgeHorizontalPadding(for size: CGFloat) -> CGFloat {
|
||||
Padding.Component.horizontalPaddingForSize(size)
|
||||
}
|
||||
|
||||
@objc static func bridgeVerticalPadding(for size: CGFloat) -> CGFloat {
|
||||
Padding.Component.verticalPaddingForSize(size)
|
||||
}
|
||||
|
||||
@objc static func bridgeSetDefaultMargins(for view: UIView, size: CGFloat, horizontal: Bool = true, vertical: Bool = false) {
|
||||
Styler.setDefaultMarginsFor(view, size: size, horizontal: horizontal, vertical: vertical)
|
||||
}
|
||||
|
||||
@objc static func bridgeSetMargins(for view: UIView, size: CGFloat, horizontal: Bool, top: CGFloat, bottom: CGFloat) {
|
||||
Styler.setMarginsFor(view, size: size, horizontal: horizontal ? nil : 0, top: top, bottom: bottom)
|
||||
}
|
||||
}
|
||||
@ -57,6 +57,8 @@ extern CGFloat const HeightTableSeperatorHeight;
|
||||
extern CGFloat const MFHeightForSwitch;
|
||||
extern CGFloat const MFMFWidthForSwitch;
|
||||
|
||||
extern CGFloat const HeaderMaxWidth;
|
||||
|
||||
// Color constants
|
||||
extern CGFloat const DisableOppacity;
|
||||
extern CGFloat const PaymentMethodViewHeightWidthMultiplier;
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#import "MVMCoreUISplitViewController.h"
|
||||
@import MVMCore.MVMCoreDispatchUtility;
|
||||
#import <MVMCoreUI/MVMCoreUIUtility.h>
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
|
||||
CGFloat const PaddingDefault = 24;
|
||||
CGFloat const PaddingDefaultHorizontalSpacing = 32;
|
||||
@ -26,7 +27,7 @@ CGFloat const PaddingVerticalWhiteGrayView = 72;
|
||||
CGFloat const PaddingVerticalHeadlineAlternate = 48;
|
||||
CGFloat const PaddingPrimaryButtonTop = 36;
|
||||
|
||||
CGFloat const PaddingHorizontalBetweenRelatedItems = 16;
|
||||
CGFloat const PaddingHorizontalBetweenRelatedItems = 12;
|
||||
CGFloat const PaddingOne = 6;
|
||||
CGFloat const PaddingTwo = 12;
|
||||
CGFloat const PaddingThree = 18;
|
||||
@ -45,6 +46,9 @@ CGFloat const HeightTableSeperatorHeight = 1;
|
||||
|
||||
CGFloat const MFHeightForSwitch = 22;
|
||||
CGFloat const MFWidthForSwitch = 42;
|
||||
|
||||
CGFloat const HeaderMaxWidth = 596;
|
||||
|
||||
CGFloat const DisableOppacity = 0.5;
|
||||
CGFloat const PaymentMethodViewHeightWidthMultiplier = 0.55;
|
||||
CGFloat const MinCellHeight = 96;
|
||||
@ -77,19 +81,19 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
|
||||
#pragma mark - Spacing Defaults
|
||||
+ (CGFloat)defaultHorizontalPaddingForApplicationWidth {
|
||||
return [[MFSizeObject sizeObjectWithScalingStandardSize:PaddingDefaultHorizontalSpacing] getValueBasedOnApplicationWidth];
|
||||
return [self bridgeHorizontalPaddingFor:[MVMCoreUISplitViewController getApplicationViewWidth]];
|
||||
}
|
||||
|
||||
+ (CGFloat)defaultVerticalPaddingForApplicationWidth {
|
||||
return [[MFSizeObject sizeObjectWithScalingStandardSize:PaddingDefaultVerticalSpacing] getValueBasedOnApplicationWidth];
|
||||
return [self bridgeVerticalPaddingFor:[MVMCoreUISplitViewController getApplicationViewWidth]];
|
||||
}
|
||||
|
||||
+ (CGFloat)defaultHorizontalPaddingForSize:(CGFloat)size {
|
||||
return [[MFSizeObject sizeObjectWithScalingStandardSize:PaddingDefaultHorizontalSpacing] getValueBasedOnSize:size];
|
||||
return [self bridgeHorizontalPaddingFor:size];
|
||||
}
|
||||
|
||||
+ (CGFloat)defaultVerticalPaddingForSize:(CGFloat)size {
|
||||
return [[MFSizeObject sizeObjectWithScalingStandardSize:PaddingDefaultVerticalSpacing] getValueBasedOnSize:size];
|
||||
return [self bridgeVerticalPaddingFor:size];
|
||||
}
|
||||
|
||||
+ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size {
|
||||
@ -97,18 +101,13 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size horizontal:(BOOL)horizontal vertical:(BOOL)vertical {
|
||||
CGFloat horizontalPadding = horizontal ? [MFStyler defaultHorizontalPaddingForSize:size] : 0;
|
||||
CGFloat verticalPadding = vertical ? PaddingDefaultVerticalSpacing3 : 0;
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
[MVMCoreUIUtility setMarginsForView:view leading:horizontalPadding top:verticalPadding trailing:horizontalPadding bottom:verticalPadding];
|
||||
}];
|
||||
if (!view) { return; }
|
||||
[self bridgeSetDefaultMarginsFor:view size:size horizontal:horizontal vertical:vertical];
|
||||
}
|
||||
|
||||
+ (void)setMarginsForView:(nullable UIView *)view size:(CGFloat)size defaultHorizontal:(BOOL)horizontal top:(CGFloat)top bottom:(CGFloat)bottom {
|
||||
CGFloat horizontalPadding = horizontal ? [MFStyler defaultHorizontalPaddingForSize:size] : 0;
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
[MVMCoreUIUtility setMarginsForView:view leading:horizontalPadding top:top trailing:horizontalPadding bottom:bottom];
|
||||
}];
|
||||
if (!view) { return; }
|
||||
[self bridgeSetMarginsFor:view size:size horizontal:horizontal top:top bottom:bottom];
|
||||
}
|
||||
|
||||
#pragma mark - 3.0 fonts
|
||||
|
||||
@ -23,24 +23,41 @@ public struct Padding {
|
||||
|
||||
public struct Component {
|
||||
public static let Standard: CGFloat = 24
|
||||
public static let HorizontalMarginSpacing: CGFloat = 32
|
||||
public static let LargeVerticalMarginSpacing: CGFloat = 32
|
||||
public static let HorizontalMarginSpacing: CGFloat = 16
|
||||
public static let LargeHorizontalMarginSpacing: CGFloat = 32
|
||||
public static let VerticalMarginSpacing: CGFloat = 24
|
||||
|
||||
public static let LargeVerticalMarginSpacing: CGFloat = 32
|
||||
public static let HorizontalGutterSpacing: CGFloat = 12
|
||||
public static let LargeHorizontalGutterSpacing: CGFloat = 24
|
||||
|
||||
public static var horizontalPaddingForApplicationWidth: CGFloat {
|
||||
MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalMarginSpacing
|
||||
horizontalPaddingForSize(MVMCoreUISplitViewController.getApplicationViewWidth())
|
||||
}
|
||||
|
||||
public static var verticalPaddingForApplicationWidth: CGFloat {
|
||||
MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? VerticalMarginSpacing
|
||||
verticalPaddingForSize(MVMCoreUISplitViewController.getApplicationViewWidth())
|
||||
}
|
||||
|
||||
public static var gutterForApplicationWidth: CGFloat {
|
||||
gutterFor(size: MVMCoreUISplitViewController.getApplicationViewWidth())
|
||||
}
|
||||
|
||||
public static func horizontalPaddingForSize(_ size: CGFloat) -> CGFloat {
|
||||
MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBased(onSize: size) ?? HorizontalMarginSpacing
|
||||
let sizeObject = MFSizeObject(standardSize: HorizontalMarginSpacing)!
|
||||
return sizeObject.getValueBased(onSize: size)
|
||||
}
|
||||
|
||||
public static func verticalPaddingForSize(_ size: CGFloat) -> CGFloat {
|
||||
MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBased(onSize: size) ?? VerticalMarginSpacing
|
||||
}
|
||||
|
||||
public static func gutterFor(size: CGFloat) -> CGFloat {
|
||||
let sizeObject = MFSizeObject(standardSize: HorizontalGutterSpacing)!
|
||||
return sizeObject.getValueBased(onSize: size)
|
||||
}
|
||||
|
||||
public static func columnFor(size: CGFloat) -> CGFloat {
|
||||
return (size - (3.0 * gutterFor(size: size)) - (2.0 * horizontalPaddingForSize(size))) / 4.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,18 +164,19 @@
|
||||
[self.iconView removeFromSuperview];
|
||||
}
|
||||
|
||||
CGFloat horizontalPadding = [MFStyler defaultHorizontalPaddingForApplicationWidth];
|
||||
if (imageURL) {
|
||||
LoadImageView *imageView = [[LoadImageView alloc] init];
|
||||
imageView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[imageView setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
|
||||
[self addSubview:imageView];
|
||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|->=space-[imageView]->=space-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"space":@(PaddingFive)} views:NSDictionaryOfVariableBindings(imageView)]];
|
||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-space-[imageView]-space-[centerView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"space":@(PaddingThree)} views:NSDictionaryOfVariableBindings(imageView,centerView)]];
|
||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-space-[imageView]-space-[centerView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"space":@(horizontalPadding)} views:NSDictionaryOfVariableBindings(imageView,centerView)]];
|
||||
[NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0].active = YES;
|
||||
self.iconView = imageView;
|
||||
[imageView loadImageWithName:imageURL width:@(32)];
|
||||
} else {
|
||||
[NSLayoutConstraint constraintWithItem:centerView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1 constant:PaddingThree].active = YES;
|
||||
[NSLayoutConstraint constraintWithItem:centerView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1 constant:horizontalPadding].active = YES;
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,6 +194,7 @@
|
||||
- (void)setupWithButton:(BOOL)showButton {
|
||||
|
||||
// Setup the button.
|
||||
CGFloat horizontalPadding = [MFStyler defaultHorizontalPaddingForApplicationWidth];
|
||||
if (showButton) {
|
||||
|
||||
if (!self.button) {
|
||||
@ -210,7 +212,7 @@
|
||||
[self addSubview:button];
|
||||
[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0].active = YES;
|
||||
[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.centerView attribute:NSLayoutAttributeRight multiplier:1 constant:PaddingThree].active = YES;
|
||||
[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:button attribute:NSLayoutAttributeRight multiplier:1 constant:(self.closeButton ? PaddingTen : PaddingFive)].active = YES;
|
||||
[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:button attribute:NSLayoutAttributeRight multiplier:1 constant:(self.closeButton ? PaddingTen : horizontalPadding)].active = YES;
|
||||
self.button = button;
|
||||
}
|
||||
} else {
|
||||
@ -222,7 +224,7 @@
|
||||
}
|
||||
|
||||
if (!self.labelRightConstraint) {
|
||||
self.labelRightConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.centerView attribute:NSLayoutAttributeRight multiplier:1 constant:(self.closeButton ? PaddingTen : PaddingFive)];
|
||||
self.labelRightConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.centerView attribute:NSLayoutAttributeRight multiplier:1 constant:(self.closeButton ? PaddingTen : horizontalPadding)];
|
||||
}
|
||||
self.labelRightConstraint.active = YES;
|
||||
}
|
||||
|
||||
@ -23,11 +23,11 @@ public extension MVMCoreUICommonViewsUtility {
|
||||
view.addSubview(button)
|
||||
var constraints: [NSLayoutConstraint] = []
|
||||
if centeredVertically {
|
||||
constraints.append(view.rightAnchor.constraint(equalTo: button.rightAnchor, constant: PaddingTwo))
|
||||
constraints.append(view.rightAnchor.constraint(equalTo: button.rightAnchor, constant: Padding.Component.horizontalPaddingForApplicationWidth))
|
||||
constraints.append(view.centerYAnchor.constraint(equalTo: button.centerYAnchor))
|
||||
} else {
|
||||
constraints.append(button.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: PaddingOne))
|
||||
constraints.append(view.safeAreaLayoutGuide.rightAnchor.constraint(equalTo: button.rightAnchor, constant: PaddingTwo))
|
||||
constraints.append(view.safeAreaLayoutGuide.rightAnchor.constraint(equalTo: button.rightAnchor, constant: Padding.Component.horizontalPaddingForApplicationWidth))
|
||||
}
|
||||
NSLayoutConstraint.activate(constraints)
|
||||
return button
|
||||
|
||||
@ -17,6 +17,7 @@ extern CGFloat const MFSizeLargeiPhoneThreshold;
|
||||
extern CGFloat const MFSizeStandardiPadPortraitThreshold;
|
||||
extern CGFloat const MFSizeStandardiPadLandscapeThreshold;
|
||||
extern CGFloat const MFSizeiPadProLandscapeThreshold;
|
||||
extern CGFloat const MFSizeMostlySweetSpotThreshold;
|
||||
|
||||
@interface MFSizeObject : NSObject
|
||||
|
||||
|
||||
@ -18,6 +18,8 @@ CGFloat const MFSizeLargeiPhoneThreshold = 400;
|
||||
CGFloat const MFSizeStandardiPadPortraitThreshold = 600;
|
||||
CGFloat const MFSizeStandardiPadLandscapeThreshold = 1000;
|
||||
CGFloat const MFSizeiPadProLandscapeThreshold = 1300;
|
||||
CGFloat const MFSizeMostlySweetSpotThreshold = 750;
|
||||
|
||||
|
||||
@interface MFSizeObject ()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user