-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DON-1029 Segmented control #2138
base: main
Are you sure you want to change the base?
Conversation
Created new segmented control component Added documentation, tests and screenshots
Snapshots were updated. Please verify the changes match the expected layout.
|
} | ||
} | ||
_selectedIndex = selectedIndex | ||
let appearance = UISegmentedControl.appearance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have 2 issues:
-(1) Changing the style by this approach would affect all instances of Segmented Control globally, not only this instance.
-(2) The style should be customisable by the consumer via a style struct passing as argument to the component, while we can have default
style.
if let accessibilityLabel = accessibilityLabel { | ||
self.itemsAccessibilityLabel = Array(repeating: "", count: items.count) | ||
for index in items.indices { | ||
self.itemsAccessibilityLabel[index] = "\(accessibilityLabel)_\(index)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need itemsAccessibilityLabel
as stored property. Instead we can use a helper when we set the elements. (line 60).
Also in another note for index in items.indices
has potential for out-of-range crash, and if we wanted to keep it we should have changed that to for index in self.items.indices
} | ||
.pickerStyle(.segmented) | ||
.padding(.horizontal, BPKSpacing.base) | ||
.accessibilityIdentifier(accessibilityLabel ?? "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use If
modifier (defined in ConditionalModifier.swift) to avoid setting empty accessibility identifiers.
Created new segmented control component
Added documentation, tests and screenshots
Jira ticket: DON-1029
Figma design: https://www.figma.com/design/irZ3YBx8vOm16ICkAr7mB3/Backpack-Components?m=auto&node-id=49086-3871&t=pQApQKbd31dMaLrK-1
Remember to include the following changes:
README.md
Backpack.h
header fileIf you are curious about how we review, please read through the code review guidelines