From 08dba6e58fa07b37f3e5242c61eced4663df8cb0 Mon Sep 17 00:00:00 2001 From: Islam Metwally Date: Tue, 24 Mar 2020 16:56:56 +0100 Subject: [PATCH] added accessibility ID to tabs config init, its used as accessibility id for the tab view it self, the container of the button. --- Sources/Tabs/TabsView.swift | 7 +++++-- Sources/TabsConfig.swift | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/Tabs/TabsView.swift b/Sources/Tabs/TabsView.swift index a5ef89a..f55c30e 100644 --- a/Sources/Tabs/TabsView.swift +++ b/Sources/Tabs/TabsView.swift @@ -19,7 +19,8 @@ fileprivate class TabView: UIView { index: Int, horizontalInsets: CGFloat, height: CGFloat, - tabsView: TabsView + tabsView: TabsView, + accessibilityID: String ) { self.index = index self.button = UIButton(type: .custom) @@ -35,6 +36,7 @@ fileprivate class TabView: UIView { super.init(frame: frame) button.addTarget(self, action: #selector(tabClicked), for: .touchUpInside) addSubview(button) + self.accessibilityIdentifier = accessibilityID } func setSelected(selected: Bool) { @@ -103,7 +105,8 @@ public class TabsView: UIView { index: index, horizontalInsets: tabsConfig.horizontalTabTitleInsets, height: self.frame.size.height, - tabsView: self + tabsView: self, + accessibilityID: tabsConfig.accessibilityID ) tab.frame = CGRect( diff --git a/Sources/TabsConfig.swift b/Sources/TabsConfig.swift index 5ca5c43..18d7cd9 100644 --- a/Sources/TabsConfig.swift +++ b/Sources/TabsConfig.swift @@ -47,6 +47,7 @@ public struct TabsConfig { public let horizontalTabTitleInsets: CGFloat public let selectionIndicatorHeight: CGFloat public let selectionIndicatorColor: UIColor + public let accessibilityID: String public init( titles: [TabTitle], @@ -56,7 +57,8 @@ public struct TabsConfig { fullWidth: Bool, horizontalTabTitleInsets: CGFloat, selectionIndicatorHeight: CGFloat, - selectionIndicatorColor: UIColor + selectionIndicatorColor: UIColor, + accessibilityID: String ) { self.titles = titles self.height = height @@ -66,6 +68,7 @@ public struct TabsConfig { self.horizontalTabTitleInsets = horizontalTabTitleInsets self.selectionIndicatorHeight = selectionIndicatorHeight self.selectionIndicatorColor = selectionIndicatorColor + self.accessibilityID = accessibilityID } }