Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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