Skip to content

Commit

Permalink
vision os support
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan1anderson committed Jan 19, 2024
1 parent ef63533 commit a03cb3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// swift-tools-version:5.8
// swift-tools-version:5.9

import PackageDescription

let package = Package(
name: "HorizonCalendar",
platforms: [
.iOS(.v11),
.visionOS(.v1)
],
products: [
.library(name: "HorizonCalendar", targets: ["HorizonCalendar"]),
Expand Down
11 changes: 9 additions & 2 deletions Sources/Public/ItemViews/DayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,30 @@ public final class DayView: UIView {
case .enabled(let playsHapticsOnTouchDown, _) = invariantViewProperties.interaction,
playsHapticsOnTouchDown
{
#if os(iOS)
feedbackGenerator = UISelectionFeedbackGenerator()
feedbackGenerator?.prepare()
#endif
}
}

public override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)

setHighlightLayerVisibility(isHidden: true, animated: true)

#if os(iOS)
feedbackGenerator?.selectionChanged()
feedbackGenerator = nil
#endif
}

public override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)

setHighlightLayerVisibility(isHidden: true, animated: true)
#if os(iOS)
feedbackGenerator = nil
#endif
}

// MARK: Fileprivate
Expand All @@ -159,8 +164,10 @@ public final class DayView: UIView {
private let highlightLayer: CAShapeLayer?
private let label: UILabel

#if os(iOS)
private var feedbackGenerator: UISelectionFeedbackGenerator?

#endif

private func setHighlightLayerVisibility(isHidden: Bool, animated: Bool) {
guard let highlightLayer else { return }

Expand Down

0 comments on commit a03cb3b

Please sign in to comment.