Enable clicking on most anyplace in the row
This commit is contained in:
parent
984431eb01
commit
8063488bc8
@ -15,21 +15,25 @@ struct VibrantSelectAction: ViewModifier {
|
|||||||
@GestureState var isLongPressed = false
|
@GestureState var isLongPressed = false
|
||||||
|
|
||||||
func body(content: Content) -> some View {
|
func body(content: Content) -> some View {
|
||||||
content
|
GeometryReader { geometry in
|
||||||
.foregroundColor(isLongPressed || isTapped ? Color(AppAssets.tableViewCellHighlightedTextColor) : .primary)
|
content
|
||||||
.listRowBackground(isLongPressed || isTapped ? Color(AppAssets.tableViewCellSelectionColor) : nil)
|
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .leading)
|
||||||
.gesture(
|
.background(self.isLongPressed || self.isTapped ? Color(AppAssets.tableViewCellSelectionColor) : Color(.secondarySystemGroupedBackground))
|
||||||
LongPressGesture().onEnded( { _ in self.action() })
|
}
|
||||||
.updating($isLongPressed) { value, state, transcation in state = value }
|
.foregroundColor(isLongPressed || isTapped ? Color(AppAssets.tableViewCellHighlightedTextColor) : .primary)
|
||||||
.simultaneously(with:
|
.listRowBackground(isLongPressed || isTapped ? Color(AppAssets.tableViewCellSelectionColor) : nil)
|
||||||
TapGesture().onEnded( {
|
.gesture(
|
||||||
self.isTapped = true
|
LongPressGesture().onEnded( { _ in self.action() })
|
||||||
self.action()
|
.updating($isLongPressed) { value, state, transcation in state = value }
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
|
.simultaneously(with:
|
||||||
self.isTapped = false
|
TapGesture().onEnded( {
|
||||||
}
|
self.isTapped = true
|
||||||
})
|
self.action()
|
||||||
)
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
|
||||||
|
self.isTapped = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user