Skip to content

Commit 15bab75

Browse files
committed
Add ConditionGlass
1 parent a25bdfb commit 15bab75

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

Demo/Demo/Samples/Advanced/GlassFlower/GlassFlower.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ struct GlassFlower: View {
4343
endPoint: .top
4444
)
4545
)
46-
47-
// Apply glass effect from SwiftGlass library to create translucent look
48-
.glass()
49-
46+
.conditionalGlass()
5047
.frame(width: 55, height: 100) // Petal dimensions
5148
.offset(x: 0, y: 0) // Position petals away from center
5249
.rotationEffect(.degrees(Double(index) * 45), anchor: .bottom) // Distribute evenly in 360° (8×45°)

Demo/Demo/Samples/Advanced/GlassFlower/GlassFlowerRotate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct GlassFlowerRotate: View {
4747
)
4848

4949
// Apply glass effect from SwiftGlass library to create translucent look
50-
.glass()
50+
.conditionalGlass()
5151

5252
.frame(width: 55, height: 100) // Petal dimensions
5353
.offset(x: 0, y: 0) // Position petals away from center
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// ConditionGlass.swift
3+
// SwiftGlass
4+
//
5+
// Created by Ming on 10/6/2025.
6+
//
7+
8+
import SwiftUI
9+
10+
// MARK: - View Extensions
11+
12+
extension View {
13+
@ViewBuilder
14+
public func conditionalGlass() -> some View {
15+
if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) {
16+
self
17+
} else {
18+
// Apply glass effect from SwiftGlass library to create translucent look
19+
self.glass()
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)