-
-
Save sturdysturge/62097e149af219767129de2f229ab46b 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 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