Updated the Sample app and Widget targets in the Xcode project to make the app works for visionOS.

This commit is contained in:
2026-07-09 19:31:44 +02:00
parent 80bffd7aae
commit 1e11c4ae5a
4 changed files with 86 additions and 56 deletions
@@ -3,7 +3,8 @@ import SwiftUI
/// The button style for the controls of a ``RecordingView``.
///
/// The style renders the button's label in the primary foreground color over a padded, circular Liquid Glass background tinted by
/// the color given at initialization that reacts fluidly to presses. The whole button dims while disabled, and both the label and its
/// the color given at initialization that reacts fluidly to presses. On visionOS, where Liquid Glass is unavailable, the background is
/// the platform's own glass material overlaid with the tint color. The whole button dims while disabled, and both the label and its
/// padding scale relative to the current dynamic type size.
struct RecordingButtonStyle: ButtonStyle {
@@ -52,6 +53,14 @@ struct RecordingButtonStyle: ButtonStyle {
.padding(padding)
.scaledToFit()
.foregroundStyle(.primary.opacity(opacity))
#if os(visionOS)
.background(
tintColor.opacity(Constant.Opacity.tint),
in: .circle
)
.glassBackgroundEffect(in: .circle)
.opacity(opacity)
#else
.glassEffect(
.regular
.tint(tintColor)
@@ -59,6 +68,7 @@ struct RecordingButtonStyle: ButtonStyle {
in: .circle
)
.opacity(opacity)
#endif
}
}
@@ -108,6 +118,8 @@ private enum Constant {
static let disabled: Double = 0.5
/// The opacity of an enabled button.
static let enabled: Double = 1
/// The opacity of the tint color laid over the glass background on visionOS.
static let tint: Double = 0.5
}
/// The padding constants.