Skip to content
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

visionOS support #151

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -8,7 +8,8 @@ let package = Package(
platforms: [
.iOS(.v13),
.macCatalyst(.v13),
.macOS(.v10_15)
.macOS(.v10_15),
.visionOS(.v1)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ internal extension BottomSheetView {
}

func platformDefaultWidth(with geometry: GeometryProxy) -> CGFloat {
#if os(macOS)
#if os(macOS) || os(visionOS)
// On Mac use 30% of the width
return geometry.size.width * 0.3
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,23 @@ internal struct UIScrollViewWrapper<Content: View>: UIViewControllerRepresentabl
0
)
let displacementY = viewController.scrollView.contentOffset.y - restOffsetY
let threshold = 0.5 / UIScreen.main.scale

#if os(visionOS)
let scale = viewController.traitCollection.displayScale
#else
let scale = UIScreen.main.scale
#endif
let threshold = 0.5 / scale

let duration: TimeInterval = {
if abs(displacementY) == 0 && abs(velocityY) == 0 {
return 0
}

let timeInterval1 = 1 / 10 * log(2 * abs(displacementY) / threshold)
let timeInterval2 = 2 / 10 * log(4 * abs(velocityY + 10 * displacementY) / (CGFloat(M_E) * 10 * threshold))

let interval2Threshold = (CGFloat(M_E) * 10 * threshold)
lucaszischka marked this conversation as resolved.
Show resolved Hide resolved
let timeInterval2 = 2 / 10 * log(4 * abs(velocityY + 10 * displacementY) / interval2Threshold)

return TimeInterval(
max(
Expand Down
2 changes: 1 addition & 1 deletion Sources/BottomSheet/Helper/Views/VisualEffectView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public enum VisualEffect: Equatable, Hashable {
case dark(Material)
}

#if os(iOS) || targetEnvironment(macCatalyst)
#if os(iOS) || targetEnvironment(macCatalyst) || os(visionOS)
fileprivate extension VisualEffect {
var blurStyle: UIBlurEffect.Style {
switch self {
Expand Down
Loading