Created
August 9, 2024 21:48
-
-
Save peterkos/e52b6fc83019e07213ac440619abbb71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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