accessibility label
This commit is contained in:
parent
f9a57f5fe5
commit
600d9a977e
@ -76,6 +76,7 @@ open class Carousel: View {
|
|||||||
open override func layoutSubviews() {
|
open override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
// Accounts for any collection size changes
|
// Accounts for any collection size changes
|
||||||
|
carouselAccessibilityElement?.accessibilityFrameInContainerSpace = collectionView.frame
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.layoutCollection()
|
self.layoutCollection()
|
||||||
}
|
}
|
||||||
@ -144,7 +145,7 @@ open class Carousel: View {
|
|||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
|
||||||
guard let carouselModel = model as? CarouselModel else { return }
|
guard let carouselModel = model as? CarouselModel else { return }
|
||||||
|
accessibilityLabel = carouselModel.accessibilityText
|
||||||
collectionView.backgroundColor = backgroundColor
|
collectionView.backgroundColor = backgroundColor
|
||||||
collectionView.layer.borderColor = backgroundColor?.cgColor
|
collectionView.layer.borderColor = backgroundColor?.cgColor
|
||||||
collectionView.layer.borderWidth = (carouselModel.border ?? false) ? 1 : 0
|
collectionView.layer.borderWidth = (carouselModel.border ?? false) ? 1 : 0
|
||||||
@ -306,11 +307,7 @@ open class Carousel: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Accessibility element that allows for adjustable carousel.
|
/// Accessibility element that allows for adjustable carousel.
|
||||||
private lazy var carouselAccessibilityElement: CarouselAccessibilityElement = {
|
private var carouselAccessibilityElement: CarouselAccessibilityElement?
|
||||||
let accessibilityElement = CarouselAccessibilityElement(accessibilityContainer: self)
|
|
||||||
accessibilityElement.accessibilityFrameInContainerSpace = collectionView.frame
|
|
||||||
return accessibilityElement
|
|
||||||
}()
|
|
||||||
|
|
||||||
private var _accessibilityElements: [Any]?
|
private var _accessibilityElements: [Any]?
|
||||||
|
|
||||||
@ -326,6 +323,16 @@ open class Carousel: View {
|
|||||||
return _accessibilityElements
|
return _accessibilityElements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the accessibility helper if needed.
|
||||||
|
let carouselAccessibilityElement: CarouselAccessibilityElement
|
||||||
|
if let theCarouselAccessibilityElement = self.carouselAccessibilityElement {
|
||||||
|
carouselAccessibilityElement = theCarouselAccessibilityElement
|
||||||
|
} else {
|
||||||
|
carouselAccessibilityElement = CarouselAccessibilityElement(accessibilityContainer: self)
|
||||||
|
carouselAccessibilityElement.accessibilityFrameInContainerSpace = collectionView.frame
|
||||||
|
self.carouselAccessibilityElement = carouselAccessibilityElement
|
||||||
|
}
|
||||||
|
|
||||||
if let currentCell = collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)) {
|
if let currentCell = collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)) {
|
||||||
_accessibilityElements = [currentCell, carouselAccessibilityElement]
|
_accessibilityElements = [currentCell, carouselAccessibilityElement]
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user