Skip to content

Commit

Permalink
Fix visionOS SwiftUI bar interaction (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryankeller authored Apr 16, 2024
1 parent e25f291 commit 688aed5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
approach to resolve an issue that could cause collection view cells to layout with
unexpected dimensions
- Made new layout-based SwiftUI cell rendering option the default.
- Fixed interaction of SwiftUI bars on visionOS

## [0.10.0](https://github.com/airbnb/epoxy-ios/compare/0.9.0...0.10.0) - 2023-06-29

Expand Down
5 changes: 4 additions & 1 deletion Sources/EpoxyBars/BarInstaller/BarStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ public class BarStackView: UIStackView, EpoxyableView {
for (index, wrapper) in zOrderedWrappers.enumerated() {
// We pick 1000 as a sensible max to decrement from since we would never have that may bars.
// We don't decrement from 0 since that causes bars to be invisible for some reason.
wrapper.layer.zPosition = CGFloat(1000 - index)
// Due to a bug on visionOS, we need to clamp this to be between -1 and 1, otherwise
// interaction breaks for SwiftUI views.
// http://openradar.appspot.com/radar?id=5534724382523392
wrapper.layer.zPosition = CGFloat(1000 - index) / 1000
wrapper.zOrder = zOrder
}
}
Expand Down

0 comments on commit 688aed5

Please sign in to comment.