Skip to content

Instantly share code, notes, and snippets.

@jboullianne
Created July 5, 2020 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jboullianne/ec5881409f9b2d52d38c9af1544af9ba to your computer and use it in GitHub Desktop.
Save jboullianne/ec5881409f9b2d52d38c9af1544af9ba to your computer and use it in GitHub Desktop.
import SwiftUI
struct SideMenu: View {
@Binding var selected: Int
var options: [String]
var body: some View {
HStack {
ForEach(options.indices) { i in
Button(action: {
withAnimation {
self.selected = i
}
}, label: {
Text(options[i])
.font(.body)
.fontWeight(.bold)
.padding(.horizontal, 10)
.foregroundColor(self.selected == i ? Color.blue : Color.black.opacity(0.6))
}).buttonStyle(PlainButtonStyle())
if i < options.count - 1 {
Divider()
.frame(width: nil, height: 45, alignment: .center)
.opacity(0.7)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment