From 01b52bc479484d24dbeb0dd1b8bec06df18ee3b4 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Mon, 3 Aug 2020 13:41:37 -0400 Subject: [PATCH 1/9] prevent expandable alert collapse when accessibilty focused. top alert notification callout fix. --- .../MVMCoreUITopAlertExpandableView.m | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index ed9f5271..3c75445b 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -74,6 +74,7 @@ self.translatesAutoresizingMaskIntoConstraints = NO; self.clipsToBounds = YES; self.expanded = NO; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessibilityFocusChanged:) name:UIAccessibilityElementFocusedNotification object:nil]; } return self; } @@ -162,6 +163,7 @@ - (void)setupTopAlertWithButton:(MVMCoreUITopAlertMainView *)topAlertWithButton { topAlertWithButton.label.alpha = 0; + topAlertWithButton.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", [MVMCoreUIUtility hardcodedStringWithKey:@"top_alert_notification"], topAlertWithButton.label.accessibilityLabel]; topAlertWithButton.button.alpha = 0; topAlertWithButton.backgroundColor = [UIColor clearColor]; [self insertSubview:topAlertWithButton belowSubview:self.shortView]; @@ -304,7 +306,6 @@ //accessibility - added to make only top alert label and close button accessible. Posted notification when top alert is displayed weakSelf.accessibilityElements = @[weakSelf.buttonView]; weakSelf.shortView.isAccessibilityElement = NO; - weakSelf.buttonView.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", [MVMCoreUIUtility hardcodedStringWithKey:@"top_alert_notification"],weakSelf.buttonView.label.accessibilityLabel]; void(^completion)(void) = ^(void) { UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, weakSelf.buttonView.label); @@ -346,7 +347,7 @@ } dispatch_time_t dispatchTime = dispatch_time(DISPATCH_TIME_NOW, dismissTime * NSEC_PER_SEC); dispatch_after(dispatchTime, dispatch_get_main_queue(), ^(void){ - if (weakSelf && weakSelf.expanded && weakSelf.collapseAutomaticallyAfterExpanded) { + if (weakSelf && weakSelf.expanded && weakSelf.collapseAutomaticallyAfterExpanded && ![self containsAccessiblityFocus]) { [weakSelf collapse]; } }); @@ -390,4 +391,28 @@ } } +- (BOOL)containsAccessiblityFocus { + if (!UIAccessibilityIsVoiceOverRunning()) { + return NO; + } + id focusedElement = UIAccessibilityFocusedElement(UIAccessibilityNotificationVoiceOverIdentifier); + if (![focusedElement isKindOfClass:[UIView class]]) { + return NO; + } + UIView *focusedView = focusedElement; + while (focusedView != nil) { + if (focusedView == self) { + return YES; + } + focusedView = [focusedView superview]; + } + return NO; +} + +- (void)accessibilityFocusChanged:(NSNotification *)notification { + if (![self containsAccessiblityFocus]) { + [self collapse]; + } +} + @end From b1d0aa55c4a9d388f24f06c10c5f987e1c09577b Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Mon, 3 Aug 2020 16:42:13 -0400 Subject: [PATCH 2/9] adjust other config endpoints. --- MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index 3c75445b..8994b340 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -61,6 +61,13 @@ } } +- (void)amendAccesibilityLabel { + NSString *amendment = [MVMCoreUIUtility hardcodedStringWithKey:@"top_alert_notification"]; + if (![self.buttonView.label.accessibilityLabel hasPrefix:amendment]) { + self.buttonView.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", amendment, self.buttonView.label.accessibilityLabel]; + } +} + #pragma mark - Setup View - (void)updateView:(CGFloat)size { @@ -163,12 +170,13 @@ - (void)setupTopAlertWithButton:(MVMCoreUITopAlertMainView *)topAlertWithButton { topAlertWithButton.label.alpha = 0; - topAlertWithButton.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", [MVMCoreUIUtility hardcodedStringWithKey:@"top_alert_notification"], topAlertWithButton.label.accessibilityLabel]; topAlertWithButton.button.alpha = 0; topAlertWithButton.backgroundColor = [UIColor clearColor]; [self insertSubview:topAlertWithButton belowSubview:self.shortView]; self.buttonView = topAlertWithButton; + [self amendAccesibilityLabel]; + self.topConstraint = [NSLayoutConstraint constraintWithItem:topAlertWithButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.shortView attribute:NSLayoutAttributeBottom multiplier:1 constant:0]; [NSLayoutConstraint constraintPinSubview:topAlertWithButton pinTop:NO topConstant:0 pinBottom:YES bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; } @@ -209,6 +217,7 @@ [MVMCoreDispatchUtility performBlockOnMainThread:^{ [self setTopMessage:topMessage]; [self.buttonView setupWithMessage:message subMessage:subMessage color:contentColor actionMap:actionMap additionalData:additionalData]; + [self amendAccesibilityLabel]; }]; } @@ -216,6 +225,7 @@ [MVMCoreDispatchUtility performBlockOnMainThread:^{ [self setTopMessage:topMessage]; [self.buttonView setupWithMessage:message subMessage:subMessage color:contentColor buttonTitle:buttonTitle userActionHandler:userActionHandler]; + [self amendAccesibilityLabel]; }]; } From daf6e7ea012df1e5c7ac1bd3aad6447ad01452b1 Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Tue, 4 Aug 2020 16:53:40 +0530 Subject: [PATCH 3/9] Updated Opacity as per design team comments --- MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index 4fa079ad..84ad5f5d 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -272,7 +272,7 @@ static const CGFloat VertialShadowOffset = 6; view.layer.shadowColor = [UIColor blackColor].CGColor; view.layer.shadowOffset = CGSizeMake(0.0f, VertialShadowOffset); - view.layer.shadowOpacity = 0.7f; + view.layer.shadowOpacity = 0.25f; view.layer.shadowPath = shadowPath.CGPath; } From 5d89ae873d91cafeead4e57f4558ff35353f3310 Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Wed, 5 Aug 2020 15:45:13 +0530 Subject: [PATCH 4/9] Corner radius added to Image and bgImageContainer --- MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift | 2 ++ MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift | 5 +++++ .../Molecules/OtherContainers/BGImageMolecule.swift | 12 ++++++++++-- .../OtherContainers/BGImageMoleculeModel.swift | 4 ++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift index 637b074d..57a82052 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift @@ -20,6 +20,7 @@ import Foundation public var height: CGFloat? public var contentMode: UIView.ContentMode? public var localBundle: Bundle? + public var cornerRadius: CGFloat? public init(image: String, imageFormat: String? = nil, width: CGFloat? = nil, height: CGFloat? = nil) { self.image = image @@ -38,5 +39,6 @@ import Foundation case width case height case contentMode + case cornerRadius } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift index baa63ee8..4357537c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift @@ -247,6 +247,11 @@ import UIKit if let contentMode = imageModel.contentMode { imageView.contentMode = contentMode } + + if let cornerRadius = imageModel.cornerRadius { + imageView.clipsToBounds = true + imageView.layer.cornerRadius = cornerRadius + } } // MARK: - load functions diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMolecule.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMolecule.swift index 1c39975e..e7d354ea 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMolecule.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMolecule.swift @@ -19,7 +19,15 @@ open class BGImageMolecule: MoleculeContainer { } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - image.setOptional(with: (model as? BGImageMoleculeModel)?.image, delegateObject, additionalData) - super.set(with: model, delegateObject, additionalData) + guard let castModel = model as? BGImageMoleculeModel else { + super.set(with: model, delegateObject, additionalData) + return + } + image.setOptional(with: castModel.image, delegateObject, additionalData) + super.set(with: castModel, delegateObject, additionalData) + if let cornerRadius = castModel.cornerRadius { + layer.cornerRadius = cornerRadius + clipsToBounds = true + } } } diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift index 83b5931d..f0200455 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift @@ -13,6 +13,7 @@ open class BGImageMoleculeModel: MoleculeContainerModel { return "bgImageContainer" } public var image: ImageViewModel + public var cornerRadius: CGFloat? open override func setDefaults() { if useHorizontalMargins == nil { @@ -31,6 +32,7 @@ open class BGImageMoleculeModel: MoleculeContainerModel { private enum CodingKeys: String, CodingKey { case image + case cornerRadius } public init(_ image: ImageViewModel, molecule: MoleculeModelProtocol) { @@ -41,6 +43,7 @@ open class BGImageMoleculeModel: MoleculeContainerModel { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) image = try typeContainer.decode(ImageViewModel.self, forKey:.image) + cornerRadius = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .cornerRadius) try super.init(from: decoder) } @@ -48,5 +51,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(image, forKey: .image) + try container.encodeIfPresent(cornerRadius, forKey: .cornerRadius) } } From d388f5be8448f3649b3f8633b481bc5fb01e7ba3 Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Thu, 6 Aug 2020 20:21:14 +0530 Subject: [PATCH 5/9] Added bgColor implementation in image --- MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift | 4 ++++ .../Molecules/OtherContainers/BGImageMolecule.swift | 12 ++---------- .../OtherContainers/BGImageMoleculeModel.swift | 4 ---- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift index 4357537c..2359f5b3 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift @@ -252,6 +252,10 @@ import UIKit imageView.clipsToBounds = true imageView.layer.cornerRadius = cornerRadius } + + if let backgroundColor = imageModel.backgroundColor?.uiColor { + imageView.backgroundColor = backgroundColor + } } // MARK: - load functions diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMolecule.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMolecule.swift index e7d354ea..1c39975e 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMolecule.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMolecule.swift @@ -19,15 +19,7 @@ open class BGImageMolecule: MoleculeContainer { } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let castModel = model as? BGImageMoleculeModel else { - super.set(with: model, delegateObject, additionalData) - return - } - image.setOptional(with: castModel.image, delegateObject, additionalData) - super.set(with: castModel, delegateObject, additionalData) - if let cornerRadius = castModel.cornerRadius { - layer.cornerRadius = cornerRadius - clipsToBounds = true - } + image.setOptional(with: (model as? BGImageMoleculeModel)?.image, delegateObject, additionalData) + super.set(with: model, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift index f0200455..83b5931d 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift @@ -13,7 +13,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel { return "bgImageContainer" } public var image: ImageViewModel - public var cornerRadius: CGFloat? open override func setDefaults() { if useHorizontalMargins == nil { @@ -32,7 +31,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel { private enum CodingKeys: String, CodingKey { case image - case cornerRadius } public init(_ image: ImageViewModel, molecule: MoleculeModelProtocol) { @@ -43,7 +41,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) image = try typeContainer.decode(ImageViewModel.self, forKey:.image) - cornerRadius = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .cornerRadius) try super.init(from: decoder) } @@ -51,6 +48,5 @@ open class BGImageMoleculeModel: MoleculeContainerModel { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(image, forKey: .image) - try container.encodeIfPresent(cornerRadius, forKey: .cornerRadius) } } From 1d29966d1b6da532613c7b23c0113badcdee69ad Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Thu, 6 Aug 2020 22:35:29 +0530 Subject: [PATCH 6/9] calling super and adding corner radius to container rather than imageView in it --- MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift index 2359f5b3..bd4d1387 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift @@ -249,13 +249,11 @@ import UIKit } if let cornerRadius = imageModel.cornerRadius { - imageView.clipsToBounds = true - imageView.layer.cornerRadius = cornerRadius + clipsToBounds = true + layer.cornerRadius = cornerRadius } - if let backgroundColor = imageModel.backgroundColor?.uiColor { - imageView.backgroundColor = backgroundColor - } + super.set(with: model, delegateObject, additionalData) } // MARK: - load functions From 4cc2a1cda0326cfe2fcff309d750dc82dc9e5693 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Thu, 6 Aug 2020 18:25:12 -0400 Subject: [PATCH 7/9] shim accessibility for testers. --- MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index 8994b340..a00603da 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -63,8 +63,13 @@ - (void)amendAccesibilityLabel { NSString *amendment = [MVMCoreUIUtility hardcodedStringWithKey:@"top_alert_notification"]; - if (![self.buttonView.label.accessibilityLabel hasPrefix:amendment]) { - self.buttonView.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", amendment, self.buttonView.label.accessibilityLabel]; + NSString *accessibilityLabel = self.buttonView.label.accessibilityLabel; + if (!accessibilityLabel) { + // The accessibility label is nil when in non-voice over mode. Therefore assign the label text for the voice over is turned on mid-session (i.e. testers 🤦). + accessibilityLabel = self.buttonView.label.text; + } + if (accessibilityLabel && ![accessibilityLabel hasPrefix:amendment]) { + self.buttonView.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", amendment, accessibilityLabel]; } } From 0c1c7b31f0c7d4d46801f4415523809e38713b3d Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Fri, 7 Aug 2020 16:32:56 +0530 Subject: [PATCH 8/9] Moved super call above --- MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift index bd4d1387..532056cb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift @@ -223,6 +223,8 @@ import UIKit public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.delegateObject = delegateObject + super.set(with: model, delegateObject, additionalData) + guard let imageModel = model as? ImageViewModel else { return } if let accessibilityString = imageModel.accessibilityText { imageView.accessibilityLabel = accessibilityString @@ -252,8 +254,6 @@ import UIKit clipsToBounds = true layer.cornerRadius = cornerRadius } - - super.set(with: model, delegateObject, additionalData) } // MARK: - load functions From d3227649875f4ff43d71e37603cbc81fe4545297 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 7 Aug 2020 11:35:15 -0400 Subject: [PATCH 9/9] code review enhancement --- MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index a00603da..ad9f5e3d 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -414,14 +414,7 @@ if (![focusedElement isKindOfClass:[UIView class]]) { return NO; } - UIView *focusedView = focusedElement; - while (focusedView != nil) { - if (focusedView == self) { - return YES; - } - focusedView = [focusedView superview]; - } - return NO; + return [(UIView *)focusedElement isDescendantOfView:self]; } - (void)accessibilityFocusChanged:(NSNotification *)notification {