Skip to content

Commit 14d2bb4

Browse files
committed
🔆 Add corner radius to HighlightView
1 parent 8fdf449 commit 14d2bb4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎Sources/ShinySwiftUI/Extensions/SwiftUI/View/View+Highlight.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public extension View {
1919
- parameter value: The `Binding` value to check. If it matches `index`, the highlight will display.
2020
*/
2121
@ViewBuilder
22-
func highlight(_ index: Int, monitoring value: Binding<Int?>) -> some View {
23-
HighlightView(content: { self }, index: index, value: value)
22+
func highlight(_ index: Int, cornerRadius: CGFloat = .xs, monitoring value: Binding<Int?>) -> some View {
23+
HighlightView(content: { self }, index: index, cornerRadius: cornerRadius, value: value)
2424
}
2525
}
2626

@@ -31,6 +31,7 @@ fileprivate struct HighlightView<Content>: View where Content: View {
3131
@State var animate: Bool = false
3232

3333
var index: Int
34+
var cornerRadius: CGFloat
3435
var value: Binding<Int?>
3536

3637
var show: Bool {
@@ -40,15 +41,15 @@ fileprivate struct HighlightView<Content>: View where Content: View {
4041
var body: some View {
4142
content
4243
.overlay(
43-
RoundedRectangle(cornerRadius: .xs)
44-
.stroke(value.wrappedValue == index ? .yellow : .clear, lineWidth: 2.0)
44+
RoundedRectangle(cornerRadius: cornerRadius)
45+
.stroke(value.wrappedValue == index ? .orange : .clear, lineWidth: 2.0)
4546
.animation(.none, value: value.wrappedValue)
4647
)
4748
.slickAnimation(value: value.wrappedValue)
4849
.onAppear { animate = true }
4950
.overlay(
5051
Image(systemName: "chevron.down")
51-
.foregroundColor(.yellow.if(value == index))
52+
.foregroundColor(.orange.if(value == index))
5253
.animation(.lightBounce.repeatForever(autoreverses: false), value: animate)
5354
.offset(y: animate ? 10.0 : 0.0)
5455
.offset(y: -50.0)

0 commit comments

Comments
 (0)