SwiftUI extension for OS-specific view modifiers that seems too arcane to implement

I settled on a similar implementation: