Created
December 7, 2019 08:35
-
-
Save SergLam/b69ac98588c1a53a4b048d87b26ddc8c to your computer and use it in GitHub Desktop.
Easy XCUITest + Voice over setup using protocol, extension and Rswift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Rswift // pod 'R.swift' | |
typealias Localizable = R.string.localizable | |
// NOTE: Contains accesibility identifiers (XCUITest) + accesibility labels (Voice over support) | |
struct Accessibility { | |
// MARK: Chat navigation bar | |
static let chatNavigationUserProfileImageId = "ChatNavigationBar.chatOpponentAvatar" | |
static func chatNavigationUserProfileImageLabel(_ name: String) -> String { | |
return Localizable.chatNavigationOtherUserImageAccesibility(name) | |
} | |
static func chatNavigationUserProfileImageHint(_ name: String) -> String { | |
return Localizable.chatNavigationOtherUserImageAccesibilityHint(name) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol AccessibilitySetupable: class { | |
func setupAccessibility() | |
} | |
extension UIView { | |
func setAccessibility(_ identifier: String?, _ label: String?, _ hint: String?) { | |
// NOTE: Important to enable user intaraction for view | |
// to make it interactable while Voice Over is enabled | |
self.isUserInteractionEnabled = label != nil | |
self.isAccessibilityElement = label != nil | |
self.accessibilityIdentifier = identifier | |
self.accessibilityLabel = label | |
self.accessibilityHint = hint | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Chat navigation bar | |
"chat-navigation.other-user-image.accesibility" = "%@ user image"; | |
"chat-navigation.other-user-image.accesibility-hint" = "Double Tap to view %@ profile"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment