Margin and max header width
This commit is contained in:
parent
b962c1c002
commit
ef56ed6cb3
@ -23,6 +23,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: 596).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: 596).isActive = true
|
||||
}
|
||||
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
line.updateView(size)
|
||||
|
||||
@ -77,7 +77,9 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
|
||||
#pragma mark - Spacing Defaults
|
||||
+ (CGFloat)defaultHorizontalPaddingForApplicationWidth {
|
||||
return [[MFSizeObject sizeObjectWithScalingStandardSize:PaddingDefaultHorizontalSpacing] getValueBasedOnApplicationWidth];
|
||||
MFSizeObject *sizeObject = [MFSizeObject sizeObjectWithStandardSize:16];
|
||||
[sizeObject addLargerThanCustomSize:32 forThreshold:MFSizeMostlySweetSpotThreshold];
|
||||
return [sizeObject getValueBasedOnApplicationWidth];
|
||||
}
|
||||
|
||||
+ (CGFloat)defaultVerticalPaddingForApplicationWidth {
|
||||
@ -85,7 +87,9 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (CGFloat)defaultHorizontalPaddingForSize:(CGFloat)size {
|
||||
return [[MFSizeObject sizeObjectWithScalingStandardSize:PaddingDefaultHorizontalSpacing] getValueBasedOnSize:size];
|
||||
MFSizeObject *sizeObject = [MFSizeObject sizeObjectWithStandardSize:16];
|
||||
[sizeObject addLargerThanCustomSize:32 forThreshold:MFSizeMostlySweetSpotThreshold];
|
||||
return [sizeObject getValueBasedOnSize:size];
|
||||
}
|
||||
|
||||
+ (CGFloat)defaultVerticalPaddingForSize:(CGFloat)size {
|
||||
|
||||
@ -25,12 +25,14 @@ public struct Padding {
|
||||
|
||||
public struct Component {
|
||||
public static let Standard: CGFloat = 24
|
||||
public static let HorizontalMarginSpacing: CGFloat = 32
|
||||
public static let HorizontalMarginSpacing: CGFloat = 16
|
||||
public static let LargeVerticalMarginSpacing: CGFloat = 32
|
||||
public static let VerticalMarginSpacing: CGFloat = 24
|
||||
|
||||
public static var horizontalPaddingForApplicationWidth: CGFloat {
|
||||
return MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalMarginSpacing
|
||||
let sizeObject = MFSizeObject(standardSize: 16)!
|
||||
sizeObject.addLargerThanCustomSize(32, forThreshold: MFSizeMostlySweetSpotThreshold)
|
||||
return sizeObject.getValueBasedOnApplicationWidth()
|
||||
}
|
||||
|
||||
public static var verticalPaddingForApplicationWidth: CGFloat {
|
||||
@ -38,7 +40,9 @@ public struct Padding {
|
||||
}
|
||||
|
||||
public static func horizontalPaddingForSize(_ size: CGFloat) -> CGFloat {
|
||||
return MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBased(onSize: size) ?? HorizontalMarginSpacing
|
||||
let sizeObject = MFSizeObject(standardSize: 16)!
|
||||
sizeObject.addLargerThanCustomSize(32, forThreshold: MFSizeMostlySweetSpotThreshold)
|
||||
return sizeObject.getValueBased(onSize: size)
|
||||
}
|
||||
|
||||
public static func verticalPaddingForSize(_ size: CGFloat) -> CGFloat {
|
||||
|
||||
@ -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