Last active
February 4, 2020 19:53
-
-
Save dfrobison/7f20465a774ae5e7e93e856cd891d128 to your computer and use it in GitHub Desktop.
[Dropdown menu for SwiftUI] from Kavsoft (https://www.youtube.com/watch?v=CwD4cScGCq8)
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 DropDown: View { | |
@State var expand = false | |
var body: some View { | |
VStack(alignment: .leading, spacing: 18, content: { | |
HStack { | |
Text("Expand").fontWeight(.heavy).foregroundColor(.white) | |
Image(systemName: expand ? "chevron.up" : "chevron.down").resizable().frame(width: 13, height: 6).foregroundColor(.white) | |
} | |
.onTapGesture { | |
self.expand.toggle() | |
} | |
if expand { | |
Button(action: { | |
self.expand.toggle() | |
}) { | |
Text("Select 1") | |
}.foregroundColor(.white) | |
Button(action: { | |
self.expand.toggle() | |
}) { | |
Text("Select 2") | |
}.foregroundColor(.white) | |
Button(action: { | |
self.expand.toggle() | |
}) { | |
Text("Select 3") | |
}.foregroundColor(.white) | |
} | |
}) | |
.padding() | |
.background(LinearGradient(gradient: .init(colors: [.red, .orange]), startPoint: .top, endPoint: .bottom)) | |
.cornerRadius(20) | |
.animation(.spring()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment