I am adopting some of the new glass UI, but having to duplicate a lot of code to maintain support for previous UI systems in macOS. An example:
if #available(macOS 26.0, *) {
VStack {
/*some 40+ lines of code clipped here for brevity*/
}
.cueButtons()
.cueStyleGlass()
} else {
VStack {
/*identical 40+ lines of code clipped here for brevity*/
}
.cueButtons()
.cueStyle()
}
If I try to use conditional modifiers as indicated here:
extension View {
func cueStyle(font: Font = .system(size: 45)) -> some View {
if #available(macOS 26.0, *) {
modifier(GlassCueStyle(font: font))
} else {
modifier(CueStyle(font: font))
}
}
}
I get this error:
Conflicting arguments to generic parameter 'τ_1_0' ('ModifiedContent<Self, GlassCueStyle>' vs. 'ModifiedContent<Self, CueStyle>')
Is there a better way to do this?