Skip to content

Instantly share code, notes, and snippets.

@peterkos
Created August 9, 2024 21:48
Show Gist options
  • Save peterkos/e52b6fc83019e07213ac440619abbb71 to your computer and use it in GitHub Desktop.
Save peterkos/e52b6fc83019e07213ac440619abbb71 to your computer and use it in GitHub Desktop.
struct LoadingViewModifier: ViewModifier {
@Binding var isLoading: Bool
func body(content: Content) -> some View {
content
.overlay(
// Wrapping this in a `Group` fixes the error
if isLoading {
ProgressView()
.transition(.opacity) // <-- error: Branches have mismatching types
// 'some View' (result of 'Self.transition') and
// 'some View' (result of 'Self.transition')
} else {
EmptyView()
.transition(.opacity)
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment