From 0501c2daae7bdd554a4b641b74381fbec775cb7b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 7 May 2020 10:38:10 -0400 Subject: [PATCH 1/6] correcting layout issue --- .../Views/CarouselIndicator/BarsIndicatorView.swift | 12 ++++++++++++ .../CarouselIndicator/NumericIndicatorView.swift | 11 +++++++++++ MVMCoreUI/Atomic/Organisms/Carousel.swift | 13 +++++-------- .../Atomic/Protocols/MoleculeViewProtocol.swift | 4 ++-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 691dbfa0..039ece9d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -98,6 +98,18 @@ open class BarsIndicatorView: CarouselIndicator { ]) } + open override func layoutSubviews() { + super.layoutSubviews() + + if barReferences.isEmpty { + generateBars() + updateUI(previousIndex: previousIndex, + newIndex: currentIndex, + totalCount: numberOfPages, + isAnimated: false) + } + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift index 3585be05..b4991d1e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift @@ -66,6 +66,17 @@ open class NumericIndicatorView: CarouselIndicator { pageCount.updateView(size) } + open override func layoutSubviews() { + super.layoutSubviews() + + if pageCount.text?.isEmpty == nil { + updateUI(previousIndex: previousIndex, + newIndex: currentIndex, + totalCount: numberOfPages, + isAnimated: false) + } + } + //-------------------------------------------------- // MARK: - Setup //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 5fd0df36..4cf65f1b 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -26,10 +26,8 @@ open class Carousel: View { /// The index of the page, does not include dummy cells. public var pageIndex: Int { - get { - return loop ? currentIndex - 2 : currentIndex - } - set(newIndex) { + get { return loop ? currentIndex - 2 : currentIndex } + set (newIndex) { currentIndex = loop ? newIndex + 2 : newIndex } } @@ -90,6 +88,7 @@ open class Carousel: View { } } + //-------------------------------------------------- // MARK: - MVMCoreViewProtocol //-------------------------------------------------- @@ -194,7 +193,7 @@ open class Carousel: View { pagingView = MoleculeObjectMapping.shared()?.createMolecule(molecule, delegateObject: delegateObject) as? (UIView & CarouselPageControlProtocol) } - addPaging(view: pagingView , position: (CGFloat(molecule?.position ?? 20))) + addPaging(view: pagingView, position: (CGFloat(molecule?.position ?? 20))) } /// Registers the cells with the collection view @@ -213,9 +212,7 @@ open class Carousel: View { /// Returns the (identifier, class) of the molecule for the given map. func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? { - guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { - return nil - } + guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { return nil } return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) } diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift index db0de647..91f461dd 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift @@ -45,8 +45,8 @@ extension MoleculeViewProtocol { } // Do nothing, optionals. - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {} - public func reset() {} + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { } + public func reset() { } public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil From d94543f3122aa6439af3043a4da7e360ef68cc87 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 7 May 2020 12:11:10 -0400 Subject: [PATCH 2/6] 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 3/6] 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]; From ee107a25cfea2bb56847ec63321e75232fc68900 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 7 May 2020 14:51:23 -0400 Subject: [PATCH 4/6] addressing layout issue --- .../CarouselIndicator/BarsIndicatorView.swift | 20 +++++++---------- .../NumericIndicatorView.swift | 22 +++++++++---------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 039ece9d..90fb0af1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -98,18 +98,6 @@ open class BarsIndicatorView: CarouselIndicator { ]) } - open override func layoutSubviews() { - super.layoutSubviews() - - if barReferences.isEmpty { - generateBars() - updateUI(previousIndex: previousIndex, - newIndex: currentIndex, - totalCount: numberOfPages, - isAnimated: false) - } - } - //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- @@ -154,6 +142,14 @@ open class BarsIndicatorView: CarouselIndicator { guard let model = model as? BarsCarouselIndicatorModel else { return } currentIndicatorColor = model.currentIndicatorColor.uiColor + + if barReferences.isEmpty { + generateBars() + updateUI(previousIndex: previousIndex, + newIndex: currentIndex, + totalCount: numberOfPages, + isAnimated: false) + } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift index b4991d1e..e4ac2fe4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift @@ -66,17 +66,6 @@ open class NumericIndicatorView: CarouselIndicator { pageCount.updateView(size) } - open override func layoutSubviews() { - super.layoutSubviews() - - if pageCount.text?.isEmpty == nil { - updateUI(previousIndex: previousIndex, - newIndex: currentIndex, - totalCount: numberOfPages, - isAnimated: false) - } - } - //-------------------------------------------------- // MARK: - Setup //-------------------------------------------------- @@ -124,6 +113,17 @@ open class NumericIndicatorView: CarouselIndicator { leftArrow.setNeedsDisplay() } + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + + if pageCount.text?.isEmpty == nil { + updateUI(previousIndex: previousIndex, + newIndex: currentIndex, + totalCount: numberOfPages, + isAnimated: false) + } + } + //-------------------------------------------------- // MARK: - IndicatorViewProtocol //-------------------------------------------------- From b8eb6cf3f4bcebf457978f49efc5dc1172e9072f Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 7 May 2020 15:07:37 -0400 Subject: [PATCH 5/6] didSet does not work upon init --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 601a8fb2..b0e4d54d 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -24,13 +24,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW public var style: Styler.Button.Style? { didSet { guard let style = style else { return } - switch style { - case .primary: - setPrimaryFacade() - - case .secondary: - setSecondaryFacade() - } + setFacade(by: style) } } public var size: Styler.Button.Size? = .standard @@ -160,6 +154,17 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW disabledBorderColor_inverted = Color(uiColor: .mvmCoolGray6) } + public func setFacade(by style: Styler.Button.Style) { + + switch style { + case .primary: + setPrimaryFacade() + + case .secondary: + setSecondaryFacade() + } + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -195,6 +200,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style) { self.style = style + setFacade(by: style) } if let size = try typeContainer.decodeIfPresent(Styler.Button.Size.self, forKey: .size) { From fd3b08bc064a21efa215bfce6821ddc9b4ebc9a1 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 7 May 2020 15:36:50 -0400 Subject: [PATCH 6/6] moving action to point of interaction --- .../Views/CarouselIndicator/BarsIndicatorView.swift | 9 +-------- .../Views/CarouselIndicator/CarouselIndicator.swift | 13 ++++++------- .../CarouselIndicator/NumericIndicatorView.swift | 11 ----------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 90fb0af1..972ea7ca 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -134,6 +134,7 @@ open class BarsIndicatorView: CarouselIndicator { public override func assessTouchOf(_ touchPoint_X: CGFloat) { currentIndex = barReferences.firstIndex { $0.0.frame.maxX >= touchPoint_X && $0.0.frame.minX <= touchPoint_X } ?? 0 + performAction() } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { @@ -142,14 +143,6 @@ open class BarsIndicatorView: CarouselIndicator { guard let model = model as? BarsCarouselIndicatorModel else { return } currentIndicatorColor = model.currentIndicatorColor.uiColor - - if barReferences.isEmpty { - generateBars() - updateUI(previousIndex: previousIndex, - newIndex: currentIndex, - totalCount: numberOfPages, - isAnimated: false) - } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index d1f12d85..9380e8c0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -48,13 +48,10 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { previousIndex = currentIndex carouselIndicatorModel?.currentIndex = newIndex - if previousIndex != newIndex { - updateUI(previousIndex: previousIndex, - newIndex: newIndex, - totalCount: numberOfPages, - isAnimated: carouselIndicatorModel?.animated ?? true) - performAction() - } + updateUI(previousIndex: previousIndex, + newIndex: newIndex, + totalCount: numberOfPages, + isAnimated: carouselIndicatorModel?.animated ?? true) } } @@ -141,11 +138,13 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { func incrementCurrentIndex() { currentIndex = (currentIndex + 1) % numberOfPages + performAction() } func decrementCurrentIndex() { let newIndex = currentIndex - 1 currentIndex = newIndex < 0 ? numberOfPages - 1 : newIndex + performAction() } /// Increments the currentIndex value. diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift index e4ac2fe4..3585be05 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift @@ -113,17 +113,6 @@ open class NumericIndicatorView: CarouselIndicator { leftArrow.setNeedsDisplay() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - - if pageCount.text?.isEmpty == nil { - updateUI(previousIndex: previousIndex, - newIndex: currentIndex, - totalCount: numberOfPages, - isAnimated: false) - } - } - //-------------------------------------------------- // MARK: - IndicatorViewProtocol //--------------------------------------------------