Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created January 26, 2021 14:06
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 sturdysturge/62097e149af219767129de2f229ab46b to your computer and use it in GitHub Desktop.
Save sturdysturge/62097e149af219767129de2f229ab46b to your computer and use it in GitHub Desktop.
struct AquaSegmentedControlView: View {
typealias ButtonData = (text: String, action: () -> Void, selected: Bool)
let buttons: [ButtonData]
var body: some View {
HStack(spacing: 0) {
ForEach(0..<buttons.count, id: \.self) { index in
Button(buttons[index].text, action: buttons[index].action)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.aspectRatio(1.36, contentMode: .fit)
.overlay(Color.aquaBlue.opacity(buttons[index].selected ? 0.5 : 0))
if index + 1 != buttons.count {
Divider()
.foregroundColor(.gray)
}
}
}
.font(.title2)
.foregroundColor(.black)
.background(AquaWaveView())
.cornerRadius(5)
.overlay(RoundedRectangle(cornerRadius: 5)
.stroke(Color.aquaSegmentedControlOutlineStroke, lineWidth: 2))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment