From d94543f3122aa6439af3043a4da7e360ef68cc87 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 7 May 2020 12:11:10 -0400 Subject: [PATCH 1/2] fixes for notification button --- .../Atomic/Atoms/Buttons/PillButton.swift | 32 ++++++++++++++++--- .../TopAlert/MVMCoreUITopAlertMainView.m | 3 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 1 + 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 745a34f4..0f612f5a 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -26,6 +26,28 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { didSet { style() } } + open var buttonSize: Styler.Button.Size = .standard { + didSet { + buttonModel?.size = buttonSize + } + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + @objc public convenience init(asPrimaryButton tiny: Bool) { + self.init() + buttonSize = tiny ? .tiny : .standard + stylePrimary() + } + + @objc public convenience init(asSecondaryButton tiny: Bool) { + self.init() + buttonSize = tiny ? .tiny : .standard + styleSecondary() + } + //-------------------------------------------------- // MARK: - Computed Properties //-------------------------------------------------- @@ -116,7 +138,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } private func getHeight() -> CGFloat { - PillButton.getHeight(for: buttonModel?.size, size: size) + PillButton.getHeight(for: buttonSize, size: size) } public static func getHeight(for buttonSize: Styler.Button.Size?, size: CGFloat) -> CGFloat { @@ -138,7 +160,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { private func getMinimumWidth() -> CGFloat { - switch buttonModel?.size { + switch buttonSize { case .tiny: return MFSizeObject(standardSize: 49, standardiPadPortraitSize: 90, @@ -165,7 +187,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { guard let model = model as? ButtonModel else { return } setTitle(model.title, for: .normal) - + if let size = model.size { + buttonSize = size + } model.updateUI = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { self?.enableField(model.enabled) @@ -185,7 +209,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { invalidateIntrinsicContentSize() - switch buttonModel?.size { + switch buttonSize { case .tiny: titleLabel?.font = MFFonts.mfFont75Bd(11 * (intrinsicContentSize.height / Styler.Button.Size.tiny.getHeight())) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m index 2021cb15..4c62293e 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m @@ -188,14 +188,13 @@ self.labelRightConstraint.active = NO; // Sets up to use a button action. Always uses the top view controller - PillButton *button = [[PillButton alloc] init]; + PillButton *button = [[PillButton alloc] initAsSecondaryButton:true]; [button styleSecondary]; [button setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; [button setContentHuggingPriority:800 forAxis:UILayoutConstraintAxisHorizontal]; button.translatesAutoresizingMaskIntoConstraints = NO; [self addSubview:button]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|->=space-[button]->=space-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"space":@(PaddingFive)} views:NSDictionaryOfVariableBindings(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; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index b3dacb21..d8c21b45 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -160,6 +160,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; UIColor *statusBarColor = nil; UIStatusBarStyle statusBarStyle = UIStatusBarStyleDefault; MVMCoreUITopAlertBaseView *view = [self topAlertViewForTopAlertObject:topAlertObject animationDelegate:animationDelegate statusBarColor:&statusBarColor statusBarStyle:&statusBarStyle]; + [view updateView:CGRectGetWidth(self.bounds)]; if (!statusBarColor) { statusBarColor = [UIColor whiteColor]; } From 770731a63927aab8e7614b8d8b6748bda74d56b1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 7 May 2020 12:43:44 -0400 Subject: [PATCH 2/2] feedback --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 12 +++--------- MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 0f612f5a..f5a7ed44 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -36,16 +36,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { // MARK: - Initializers //-------------------------------------------------- - @objc public convenience init(asPrimaryButton tiny: Bool) { + @objc public convenience init(asPrimaryButton isPrimary: Bool, makeTiny istiny: Bool) { self.init() - buttonSize = tiny ? .tiny : .standard - stylePrimary() - } - - @objc public convenience init(asSecondaryButton tiny: Bool) { - self.init() - buttonSize = tiny ? .tiny : .standard - styleSecondary() + buttonSize = istiny ? .tiny : .standard + isPrimary ? stylePrimary() : styleSecondary() } //-------------------------------------------------- diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m index 4c62293e..eeff9cfe 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m @@ -188,7 +188,7 @@ self.labelRightConstraint.active = NO; // Sets up to use a button action. Always uses the top view controller - PillButton *button = [[PillButton alloc] initAsSecondaryButton:true]; + PillButton *button = [[PillButton alloc] initAsPrimaryButton:false makeTiny:true]; [button styleSecondary]; [button setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; [button setContentHuggingPriority:800 forAxis:UILayoutConstraintAxisHorizontal];