Skip to content

Commit

Permalink
Merge pull request #23 from deliveryhero/Feature/AddingAccessibilityI…
Browse files Browse the repository at this point in the history
…DToTabView

added accessibility ID to tabs config.
  • Loading branch information
Islam-Metwally authored Mar 24, 2020
2 parents a32da90 + 08dba6e commit 270e8a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Sources/Tabs/TabsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion Sources/TabsConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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
Expand All @@ -66,6 +68,7 @@ public struct TabsConfig {
self.horizontalTabTitleInsets = horizontalTabTitleInsets
self.selectionIndicatorHeight = selectionIndicatorHeight
self.selectionIndicatorColor = selectionIndicatorColor
self.accessibilityID = accessibilityID
}
}

0 comments on commit 270e8a7

Please sign in to comment.