top alert margins
This commit is contained in:
parent
b4cfca0cb2
commit
9eb28ff675
@ -24,8 +24,8 @@ open class CollapsableNotificationModel: NotificationModel {
|
|||||||
super.init(with: headline)
|
super.init(with: headline)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setDefault() {
|
open override func setDefaults() {
|
||||||
super.setDefault()
|
super.setDefaults()
|
||||||
if topLabel.textColor == nil {
|
if topLabel.textColor == nil {
|
||||||
topLabel.textColor = Color(uiColor: .white)
|
topLabel.textColor = Color(uiColor: .white)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers open class NotificationView: View {
|
@objcMembers open class NotificationView: Container {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -43,19 +43,13 @@ import Foundation
|
|||||||
|
|
||||||
labelStack = Stack<StackModel>.createStack(with: [headline, body], spacing: 0)
|
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)
|
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)
|
addAndContain(horizontalStack)
|
||||||
NSLayoutConstraint.constraintPinSubview(horizontalStack, pinTop: true, topConstant: PaddingTwo, pinBottom: true, bottomConstant: PaddingTwo, pinLeft: true, leftConstant: PaddingThree, pinRight: true, rightConstant: PaddingThree)
|
|
||||||
labelStack.restack()
|
labelStack.restack()
|
||||||
horizontalStack.restack()
|
horizontalStack.restack()
|
||||||
|
|
||||||
heightAnchor.constraint(equalToConstant: Self.viewHeight).isActive = true
|
heightAnchor.constraint(equalToConstant: Self.viewHeight).isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
|
||||||
super.updateView(size)
|
|
||||||
horizontalStack.updateView(size)
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
backgroundColor = .mvmGreen()
|
backgroundColor = .mvmGreen()
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
open class NotificationModel: MoleculeModelProtocol {
|
open class NotificationModel: ContainerModel, MoleculeModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -26,13 +26,19 @@ open class NotificationModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public init(with headline: LabelModel) {
|
public init(with headline: LabelModel) {
|
||||||
self.headline = headline
|
self.headline = headline
|
||||||
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Default
|
// MARK: - Default
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open func setDefault() {
|
open override func setDefaults() {
|
||||||
|
useHorizontalMargins = true
|
||||||
|
useVerticalMargins = true
|
||||||
|
topPadding = PaddingTwo
|
||||||
|
bottomPadding = PaddingTwo
|
||||||
|
|
||||||
if backgroundColor == nil {
|
if backgroundColor == nil {
|
||||||
backgroundColor = Color(uiColor: .mvmGreen)
|
backgroundColor = Color(uiColor: .mvmGreen)
|
||||||
}
|
}
|
||||||
@ -76,10 +82,10 @@ open class NotificationModel: MoleculeModelProtocol {
|
|||||||
body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
|
body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
|
||||||
button = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .button)
|
button = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .button)
|
||||||
closeButton = try typeContainer.decodeIfPresent(NotificationXButtonModel.self, forKey: .closeButton)
|
closeButton = try typeContainer.decodeIfPresent(NotificationXButtonModel.self, forKey: .closeButton)
|
||||||
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)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
|||||||
@ -164,18 +164,19 @@
|
|||||||
[self.iconView removeFromSuperview];
|
[self.iconView removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGFloat horizontalPadding = [MFStyler defaultHorizontalPaddingForApplicationWidth];
|
||||||
if (imageURL) {
|
if (imageURL) {
|
||||||
LoadImageView *imageView = [[LoadImageView alloc] init];
|
LoadImageView *imageView = [[LoadImageView alloc] init];
|
||||||
imageView.translatesAutoresizingMaskIntoConstraints = NO;
|
imageView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
[imageView setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
|
[imageView setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
|
||||||
[self addSubview:imageView];
|
[self addSubview:imageView];
|
||||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|->=space-[imageView]->=space-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"space":@(PaddingFive)} views:NSDictionaryOfVariableBindings(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;
|
[NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0].active = YES;
|
||||||
self.iconView = imageView;
|
self.iconView = imageView;
|
||||||
[imageView loadImageWithName:imageURL width:@(32)];
|
[imageView loadImageWithName:imageURL width:@(32)];
|
||||||
} else {
|
} 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 {
|
- (void)setupWithButton:(BOOL)showButton {
|
||||||
|
|
||||||
// Setup the button.
|
// Setup the button.
|
||||||
|
CGFloat horizontalPadding = [MFStyler defaultHorizontalPaddingForApplicationWidth];
|
||||||
if (showButton) {
|
if (showButton) {
|
||||||
|
|
||||||
if (!self.button) {
|
if (!self.button) {
|
||||||
@ -210,7 +212,7 @@
|
|||||||
[self addSubview:button];
|
[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: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: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;
|
self.button = button;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -222,7 +224,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!self.labelRightConstraint) {
|
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;
|
self.labelRightConstraint.active = YES;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,11 +23,11 @@ public extension MVMCoreUICommonViewsUtility {
|
|||||||
view.addSubview(button)
|
view.addSubview(button)
|
||||||
var constraints: [NSLayoutConstraint] = []
|
var constraints: [NSLayoutConstraint] = []
|
||||||
if centeredVertically {
|
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))
|
constraints.append(view.centerYAnchor.constraint(equalTo: button.centerYAnchor))
|
||||||
} else {
|
} else {
|
||||||
constraints.append(button.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: PaddingOne))
|
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)
|
NSLayoutConstraint.activate(constraints)
|
||||||
return button
|
return button
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user