-
-
Save laevandus/0b28af7186b7575d9cd74c829d864eec to your computer and use it in GitHub Desktop.
This file contains 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 CollapsibleView<Label, Content>: View where Label: View, Content: View { | |
@State private var isSecondaryViewVisible = false | |
@ViewBuilder let label: () -> Label | |
@ViewBuilder let content: () -> Content | |
var body: some View { | |
Group { | |
Button(action: { isSecondaryViewVisible.toggle() }, label: label) | |
.buttonStyle(.plain) | |
if isSecondaryViewVisible { | |
content() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment