Skip to content

Commit b582cb9

Browse files
Merge pull request #100 from componentskit/card-bug-fix
Improve Card hit-testing and border rendering in SUCard
2 parents 6f8cc9f + 52c1dbc commit b582cb9

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

Sources/ComponentsKit/Components/Card/SUCard.swift

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,30 @@ public struct SUCard<Content: View>: View {
5151
.cornerRadius(self.model.cornerRadius.value)
5252
.overlay(
5353
RoundedRectangle(cornerRadius: self.model.cornerRadius.value)
54-
.stroke(
54+
.strokeBorder(
5555
self.model.borderColor.color,
5656
lineWidth: self.model.borderWidth.value
5757
)
5858
)
5959
.shadow(self.model.shadow)
6060
.observeSize { self.contentSize = $0 }
61-
.simultaneousGesture(DragGesture(minimumDistance: 0.0)
62-
.onChanged { _ in
63-
guard self.model.isTappable else { return }
64-
self.isPressed = true
65-
}
66-
.onEnded { value in
67-
guard self.model.isTappable else { return }
61+
.contentShape(.rect)
62+
.gesture(
63+
DragGesture(minimumDistance: 0.0)
64+
.onChanged { _ in
65+
guard self.model.isTappable else { return }
66+
self.isPressed = true
67+
}
68+
.onEnded { value in
69+
guard self.model.isTappable else { return }
6870

69-
defer { self.isPressed = false }
71+
defer { self.isPressed = false }
7072

71-
if CGRect(origin: .zero, size: self.contentSize).contains(value.location) {
72-
self.onTap()
73+
if CGRect(origin: .zero, size: self.contentSize)
74+
.contains(value.location) {
75+
self.onTap()
76+
}
7377
}
74-
}
7578
)
7679
.scaleEffect(
7780
self.isPressed ? self.model.animationScale.value : 1,

0 commit comments

Comments
 (0)