Skip to content

Commit 5e61be8

Browse files
authored
Merge pull request #6 from 1998code/1.1
Support OS 26.0
2 parents 2f5da26 + 94fb287 commit 5e61be8

File tree

7 files changed

+112
-43
lines changed

7 files changed

+112
-43
lines changed

.github/workflows/swift.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ on:
1010
branches: [ "main" ]
1111

1212
jobs:
13+
xcode-26:
14+
runs-on: macos-26
15+
env:
16+
DEVELOPER_DIR: /Applications/Xcode_26.app/Contents/Developer
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Version
20+
run: swift --version
21+
- name: Build
22+
run: swift build -v
23+
# - name: Test
24+
# run: swift test -v
25+
1326
xcode-16-3:
1427
runs-on: macos-15
1528
env:

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

Demo/Demo/Samples/Essential/Buttons.swift

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,51 @@ struct Buttons: View {
1616
#if !os(watchOS)
1717
.toolbar {
1818
ToolbarItemGroup(placement: .navigationBarLeading) {
19-
Button(action: {}) {
20-
HStack(spacing: 3) {
21-
Image(systemName: "chevron.left")
22-
.font(.caption)
23-
.padding(.leading, 6)
24-
Text("Back")
25-
.bold()
26-
.padding(.trailing, 1.5)
19+
if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) {
20+
// No need to apply effect
21+
Button(action: {}) {
22+
HStack(spacing: 3) {
23+
Image(systemName: "chevron.left")
24+
.font(.caption)
25+
.padding(.leading, 6)
26+
Text("Back")
27+
.bold()
28+
.padding(.trailing, 8)
29+
}
30+
.padding(.vertical, 2)
31+
.accentColor(.primary)
2732
}
28-
.padding(.vertical, 2)
29-
.accentColor(.primary)
30-
}.background(.primary.opacity(0.1))
31-
.glass(color: .primary, shadowColor: .primary.opacity(0.75))
33+
} else {
34+
Button(action: {}) {
35+
HStack(spacing: 3) {
36+
Image(systemName: "chevron.left")
37+
.font(.caption)
38+
.padding(.leading, 6)
39+
Text("Back")
40+
.bold()
41+
.padding(.trailing, 1.5)
42+
}
43+
.padding(.vertical, 2)
44+
.accentColor(.primary)
45+
}
46+
.background(.primary.opacity(0.1))
47+
.glass(color: .primary, shadowColor: .primary.opacity(0.75))
48+
}
3249
}
3350

3451
ToolbarItemGroup(placement: .navigationBarTrailing) {
35-
EditButton()
36-
.bold()
37-
.padding(.vertical, 3)
38-
.padding(.leading, 5)
39-
.padding(.trailing, 11.5)
40-
.background(Color.accentColor.opacity(0.1))
41-
.glass(color: .accentColor, shadowColor: .accentColor)
52+
if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) {
53+
// No need to apply effect
54+
EditButton()
55+
} else {
56+
EditButton()
57+
.bold()
58+
.padding(.vertical, 3)
59+
.padding(.leading, 5)
60+
.padding(.trailing, 11.5)
61+
.background(Color.accentColor.opacity(0.1))
62+
.glass(color: .accentColor, shadowColor: .accentColor)
63+
}
4264
}
4365
}
4466
#endif

Demo/Demo/Samples/_BlankTemplate.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ import SwiftGlass
1010

1111
struct BlankTemplate: View {
1212
var body: some View {
13-
VStack {
14-
Text("Hello, Developer!")
13+
ZStack {
14+
bg
15+
Text("Hello, Developer!")
16+
.bold()
1517
.padding(25)
1618
.glass()
1719
}
1820
}
21+
22+
var bg: some View {
23+
LinearGradient(colors: [Color.clear, Color.pink.opacity(0.85)], startPoint: .topLeading, endPoint: .bottomTrailing)
24+
.ignoresSafeArea()
25+
}
1926
}
2027

2128
#Preview("Dark") {
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+
}

Sources/SwiftGlass/GlassBackgroundModifier.swift

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,31 @@ public struct GlassBackgroundModifier: ViewModifier {
7070
/// 2. Gradient stroke for edge highlighting
7171
/// 3. Shadow for depth perception
7272
public func body(content: Content) -> some View {
73-
content
74-
.background(material) // Use the specified material for the frosted glass base
75-
.cornerRadius(radius) // Rounds the corners
76-
.overlay(
77-
// Adds subtle gradient border for dimensional effect
78-
RoundedRectangle(cornerRadius: radius)
79-
.stroke(
80-
LinearGradient(
81-
gradient: Gradient(colors: gradientColors()),
82-
startPoint: .topLeading,
83-
endPoint: .bottomTrailing
84-
),
85-
lineWidth: strokeWidth
86-
)
87-
)
88-
// Adds shadow for depth and elevation
89-
.shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY)
73+
if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) {
74+
content
75+
.background(material)
76+
.glassEffect(in: .rect(cornerRadius: radius))
77+
.cornerRadius(radius)
78+
.shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY)
79+
} else {
80+
content
81+
.background(material) // Use the specified material for the frosted glass base
82+
.cornerRadius(radius) // Rounds the corners
83+
.overlay(
84+
// Adds subtle gradient border for dimensional effect
85+
RoundedRectangle(cornerRadius: radius)
86+
.stroke(
87+
LinearGradient(
88+
gradient: Gradient(colors: gradientColors()),
89+
startPoint: .topLeading,
90+
endPoint: .bottomTrailing
91+
),
92+
lineWidth: strokeWidth
93+
)
94+
)
95+
// Adds shadow for depth and elevation
96+
.shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY)
97+
}
9098
}
9199

92100
/// Generates the gradient colors based on the selected style

0 commit comments

Comments
 (0)