From 54f0f9a042cc23cf47f1e39eb74cebc37de51226 Mon Sep 17 00:00:00 2001 From: MING <54872601+1998code@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:29:31 +0800 Subject: [PATCH 1/5] Update OS 26.0 --- Demo/Demo/Samples/_BlankTemplate.swift | 11 +++++- .../SwiftGlass/GlassBackgroundModifier.swift | 37 +++++++++++-------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Demo/Demo/Samples/_BlankTemplate.swift b/Demo/Demo/Samples/_BlankTemplate.swift index 75b16b0..beee55f 100644 --- a/Demo/Demo/Samples/_BlankTemplate.swift +++ b/Demo/Demo/Samples/_BlankTemplate.swift @@ -10,12 +10,19 @@ import SwiftGlass struct BlankTemplate: View { var body: some View { - VStack { - Text("Hello, Developer!") + ZStack { + bg + Text("Hello, Developer!") + .bold() .padding(25) .glass() } } + + var bg: some View { + LinearGradient(colors: [Color.clear, Color.pink.opacity(0.85)], startPoint: .topLeading, endPoint: .bottomTrailing) + .ignoresSafeArea() + } } #Preview("Dark") { diff --git a/Sources/SwiftGlass/GlassBackgroundModifier.swift b/Sources/SwiftGlass/GlassBackgroundModifier.swift index 520272b..d26a02a 100644 --- a/Sources/SwiftGlass/GlassBackgroundModifier.swift +++ b/Sources/SwiftGlass/GlassBackgroundModifier.swift @@ -70,23 +70,28 @@ public struct GlassBackgroundModifier: ViewModifier { /// 2. Gradient stroke for edge highlighting /// 3. Shadow for depth perception public func body(content: Content) -> some View { - content - .background(material) // Use the specified material for the frosted glass base - .cornerRadius(radius) // Rounds the corners - .overlay( - // Adds subtle gradient border for dimensional effect - RoundedRectangle(cornerRadius: radius) - .stroke( - LinearGradient( - gradient: Gradient(colors: gradientColors()), - startPoint: .topLeading, - endPoint: .bottomTrailing - ), - lineWidth: strokeWidth - ) - ) + if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) { + content + .glassEffect() + } else { + content + .background(material) // Use the specified material for the frosted glass base + .cornerRadius(radius) // Rounds the corners + .overlay( + // Adds subtle gradient border for dimensional effect + RoundedRectangle(cornerRadius: radius) + .stroke( + LinearGradient( + gradient: Gradient(colors: gradientColors()), + startPoint: .topLeading, + endPoint: .bottomTrailing + ), + lineWidth: strokeWidth + ) + ) // Adds shadow for depth and elevation - .shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY) + .shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY) + } } /// Generates the gradient colors based on the selected style From dc4f2f44aa2ff290641fd038c7f4f2875d28e401 Mon Sep 17 00:00:00 2001 From: MING <54872601+1998code@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:51:09 +0800 Subject: [PATCH 2/5] Update props --- Sources/SwiftGlass/GlassBackgroundModifier.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftGlass/GlassBackgroundModifier.swift b/Sources/SwiftGlass/GlassBackgroundModifier.swift index d26a02a..c991e0b 100644 --- a/Sources/SwiftGlass/GlassBackgroundModifier.swift +++ b/Sources/SwiftGlass/GlassBackgroundModifier.swift @@ -72,7 +72,10 @@ public struct GlassBackgroundModifier: ViewModifier { public func body(content: Content) -> some View { if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) { content - .glassEffect() + .background(material) + .glassEffect(in: .rect(cornerRadius: radius)) + .cornerRadius(radius) + .shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY) } else { content .background(material) // Use the specified material for the frosted glass base @@ -89,7 +92,7 @@ public struct GlassBackgroundModifier: ViewModifier { lineWidth: strokeWidth ) ) - // Adds shadow for depth and elevation + // Adds shadow for depth and elevation .shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY) } } From a25bdfbb0bd268a50dd33ed2e6076bdccdddf0e3 Mon Sep 17 00:00:00 2001 From: MING <54872601+1998code@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:55:29 +0800 Subject: [PATCH 3/5] Update Buttons.swift --- Demo/Demo/Samples/Essential/Buttons.swift | 60 ++++++++++++++++------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/Demo/Demo/Samples/Essential/Buttons.swift b/Demo/Demo/Samples/Essential/Buttons.swift index 26dafe2..e072b39 100644 --- a/Demo/Demo/Samples/Essential/Buttons.swift +++ b/Demo/Demo/Samples/Essential/Buttons.swift @@ -16,29 +16,51 @@ struct Buttons: View { #if !os(watchOS) .toolbar { ToolbarItemGroup(placement: .navigationBarLeading) { - Button(action: {}) { - HStack(spacing: 3) { - Image(systemName: "chevron.left") - .font(.caption) - .padding(.leading, 6) - Text("Back") - .bold() - .padding(.trailing, 1.5) + if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) { + // No need to apply effect + Button(action: {}) { + HStack(spacing: 3) { + Image(systemName: "chevron.left") + .font(.caption) + .padding(.leading, 6) + Text("Back") + .bold() + .padding(.trailing, 8) + } + .padding(.vertical, 2) + .accentColor(.primary) } - .padding(.vertical, 2) - .accentColor(.primary) - }.background(.primary.opacity(0.1)) - .glass(color: .primary, shadowColor: .primary.opacity(0.75)) + } else { + Button(action: {}) { + HStack(spacing: 3) { + Image(systemName: "chevron.left") + .font(.caption) + .padding(.leading, 6) + Text("Back") + .bold() + .padding(.trailing, 1.5) + } + .padding(.vertical, 2) + .accentColor(.primary) + } + .background(.primary.opacity(0.1)) + .glass(color: .primary, shadowColor: .primary.opacity(0.75)) + } } ToolbarItemGroup(placement: .navigationBarTrailing) { - EditButton() - .bold() - .padding(.vertical, 3) - .padding(.leading, 5) - .padding(.trailing, 11.5) - .background(Color.accentColor.opacity(0.1)) - .glass(color: .accentColor, shadowColor: .accentColor) + if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) { + // No need to apply effect + EditButton() + } else { + EditButton() + .bold() + .padding(.vertical, 3) + .padding(.leading, 5) + .padding(.trailing, 11.5) + .background(Color.accentColor.opacity(0.1)) + .glass(color: .accentColor, shadowColor: .accentColor) + } } } #endif From 15bab752ea11ce68740657e8aecae3f2d1920fca Mon Sep 17 00:00:00 2001 From: MING <54872601+1998code@users.noreply.github.com> Date: Tue, 10 Jun 2025 20:06:45 +0800 Subject: [PATCH 4/5] Add ConditionGlass --- .../Advanced/GlassFlower/GlassFlower.swift | 5 +---- .../GlassFlower/GlassFlowerRotate.swift | 2 +- Sources/SwiftGlass/ConditionGlass.swift | 22 +++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 Sources/SwiftGlass/ConditionGlass.swift diff --git a/Demo/Demo/Samples/Advanced/GlassFlower/GlassFlower.swift b/Demo/Demo/Samples/Advanced/GlassFlower/GlassFlower.swift index f906ec4..0c1a80d 100644 --- a/Demo/Demo/Samples/Advanced/GlassFlower/GlassFlower.swift +++ b/Demo/Demo/Samples/Advanced/GlassFlower/GlassFlower.swift @@ -43,10 +43,7 @@ struct GlassFlower: View { endPoint: .top ) ) - - // Apply glass effect from SwiftGlass library to create translucent look - .glass() - + .conditionalGlass() .frame(width: 55, height: 100) // Petal dimensions .offset(x: 0, y: 0) // Position petals away from center .rotationEffect(.degrees(Double(index) * 45), anchor: .bottom) // Distribute evenly in 360° (8×45°) diff --git a/Demo/Demo/Samples/Advanced/GlassFlower/GlassFlowerRotate.swift b/Demo/Demo/Samples/Advanced/GlassFlower/GlassFlowerRotate.swift index 72ca85d..88c5b91 100644 --- a/Demo/Demo/Samples/Advanced/GlassFlower/GlassFlowerRotate.swift +++ b/Demo/Demo/Samples/Advanced/GlassFlower/GlassFlowerRotate.swift @@ -47,7 +47,7 @@ struct GlassFlowerRotate: View { ) // Apply glass effect from SwiftGlass library to create translucent look - .glass() + .conditionalGlass() .frame(width: 55, height: 100) // Petal dimensions .offset(x: 0, y: 0) // Position petals away from center diff --git a/Sources/SwiftGlass/ConditionGlass.swift b/Sources/SwiftGlass/ConditionGlass.swift new file mode 100644 index 0000000..e4ddbe7 --- /dev/null +++ b/Sources/SwiftGlass/ConditionGlass.swift @@ -0,0 +1,22 @@ +// +// ConditionGlass.swift +// SwiftGlass +// +// Created by Ming on 10/6/2025. +// + +import SwiftUI + +// MARK: - View Extensions + +extension View { + @ViewBuilder + public func conditionalGlass() -> some View { + if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) { + self + } else { + // Apply glass effect from SwiftGlass library to create translucent look + self.glass() + } + } +} From 94fb287c05be32046f8368fa7e12fc9b59cd9d37 Mon Sep 17 00:00:00 2001 From: MING <54872601+1998code@users.noreply.github.com> Date: Tue, 10 Jun 2025 20:12:27 +0800 Subject: [PATCH 5/5] Update swift.yml Add macOS 26 and Xcode 26 --- .github/workflows/swift.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index d6de6d3..d65d037 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -10,6 +10,19 @@ on: branches: [ "main" ] jobs: + xcode-26: + runs-on: macos-26 + env: + DEVELOPER_DIR: /Applications/Xcode_26.app/Contents/Developer + steps: + - uses: actions/checkout@v4 + - name: Version + run: swift --version + - name: Build + run: swift build -v + # - name: Test + # run: swift test -v + xcode-16-3: runs-on: macos-15 env: