Commit a8f69337 authored by Maarten Billemont's avatar Maarten Billemont

Improve margin usage inside detail items.

parent 80d1b261
Pipeline #44417073 failed with stage
in 7 minutes and 14 seconds
Subproject commit 3d04d775e01ab1a437bb42166e92662ffffeedd4
Subproject commit 8688ea1e5a75055c42cc2435a3fef52e088c88af
......@@ -63,7 +63,8 @@ class MPSiteDetailViewController: UIViewController, MPSiteObserver {
.constrainTo { $1.bottomAnchor.constraint( lessThanOrEqualTo: $0.bottomAnchor ) }
.activate()
ViewConfiguration( view: self.itemsView )
.constrainToSuperview()
.constrainToSuperview( withMargins: true, forAttributes: [ .alignAllTop, .alignAllBottom ] )
.constrainToSuperview( withMargins: false, forAttributes: [ .alignAllLeading, .alignAllTrailing ] )
.activate()
ViewConfiguration( view: self.closeButton )
.constrainTo { $1.centerXAnchor.constraint( equalTo: self.backgroundView.centerXAnchor ) }
......@@ -149,6 +150,7 @@ class MPSiteDetailViewController: UIViewController, MPSiteObserver {
// - View
self.contentView.axis = .vertical
self.contentView.spacing = 8
self.contentView.preservesSuperviewLayoutMargins = true
self.titleLabel.textColor = .white
self.titleLabel.textAlignment = .center
......@@ -160,7 +162,10 @@ class MPSiteDetailViewController: UIViewController, MPSiteObserver {
}
self.subitemsView.axis = .horizontal
self.subitemsView.distribution = .fillEqually
self.subitemsView.spacing = 20
self.subitemsView.preservesSuperviewLayoutMargins = true
self.subitemsView.isLayoutMarginsRelativeArrangement = true
self.contentView.addArrangedSubview( self.subitemsView )
// - Hierarchy
......
......@@ -67,6 +67,17 @@ extension UIFont {
}
}
extension UIView {
convenience init(constraining subview: UIView, withMargins margins: Bool = true) {
self.init()
self.addSubview( subview )
ViewConfiguration( view: subview )
.constrainToSuperview( withMargins: margins )
.activate()
}
}
extension Data {
func sha256() -> Data {
var hash = Data( count: Int( CC_SHA256_DIGEST_LENGTH ) )
......
......@@ -78,6 +78,7 @@ CF_IMPLICIT_BRIDGING_ENABLED
- (instancetype)constrainToView:(UIView *__nullable)view withMargins:(BOOL)margins forAttributes:(NSLayoutFormatOptions)attributes;
- (instancetype)constrainToSuperview;
- (instancetype)constrainToMarginsOfSuperview;
- (instancetype)constrainToSuperviewWithMargins:(BOOL)margins;
- (instancetype)constrainToSuperviewWithMargins:(BOOL)margins forAttributes:(NSLayoutFormatOptions)attributes;
- (instancetype)setFloat:(CGFloat)value forKey:(NSString *)key;
......
......@@ -407,7 +407,12 @@
- (instancetype)constrainToMarginsOfSuperview {
return [self constrainToSuperviewWithMargins:YES forAttributes:
return [self constrainToSuperviewWithMargins:YES];
}
- (instancetype)constrainToSuperviewWithMargins:(BOOL)margins {
return [self constrainToSuperviewWithMargins:margins forAttributes:
NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllLeading | NSLayoutFormatAlignAllTrailing | NSLayoutFormatAlignAllBottom];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment