CustomButtons.swift (1387B)
1 import SwiftUI 2 3 extension View { 4 @ViewBuilder 5 func pencilGlass(isActive: Bool, tint: Color) -> some View { 6 if #available(iOS 26.0, *) { 7 glassEffect(isActive ? .regular.tint(tint) : .identity, in: Circle()) 8 } else { 9 background { 10 if isActive { 11 Circle().fill(tint) 12 } 13 } 14 } 15 } 16 17 @ViewBuilder 18 func replayGlass() -> some View { 19 if #available(iOS 26.0, *) { 20 glassEffect(.regular.interactive(), in: .capsule) 21 } else { 22 overlay { 23 Capsule().strokeBorder(.quaternary, lineWidth: 0.5) 24 } 25 } 26 } 27 28 @ViewBuilder 29 func nudgeGlass(isLabeled: Bool = false) -> some View { 30 if #available(iOS 26.0, *) { 31 if isLabeled { 32 glassEffect(.regular.interactive(), in: Capsule()) 33 } else { 34 glassEffect(.regular.interactive(), in: Circle()) 35 } 36 } else { 37 // Pre-glass fallback: outline the shape so the control still reads 38 // as a button, mirroring `replayGlass()`. 39 if isLabeled { 40 overlay { Capsule().strokeBorder(.quaternary, lineWidth: 0.5) } 41 } else { 42 overlay { Circle().strokeBorder(.quaternary, lineWidth: 0.5) } 43 } 44 } 45 } 46 }