Skip to content

Commit

Permalink
Merge pull request #29 from ajunjunandtmac/main
Browse files Browse the repository at this point in the history
Make compatible to swift 6.0 and iOS 18
  • Loading branch information
fatbobman authored Dec 19, 2024
2 parents d2a50d3 + afe1e82 commit 0196fcf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
20 changes: 10 additions & 10 deletions Sources/SwipeCell/SwipeCellViewModifier2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,14 @@ extension SwipeCellModifier {
.environment(\.cellStatus, status)
}
.zIndex(3)
.highPriorityGesture(
TapGesture(count: 1),
including: currentCellID == nil ? .subviews : .none
)
.contentShape(Rectangle())
//解决Button冲突问题.
.onTapGesture(
count: currentCellID != nil ? 1 : 4,
perform: {
.highPriorityGesture(
TapGesture(count: 1)
.onEnded {
resetStatus()
dismissNotification()
}
},
including: currentCellID == nil ? .subviews : .gesture
)
.offset(x: offset)
}
Expand Down Expand Up @@ -183,7 +179,11 @@ extension View {
@ViewBuilder
func myGesture(_ g:_EndedGesture<_ChangedGesture<DragGesture>>) -> some View {
if #available(iOS 18, *) {
simultaneousGesture(g)
#if compiler(>=6.0)
highPriorityGesture(g)
#else
gesture(g)
#endif
} else {
gesture(g)
}
Expand Down
10 changes: 9 additions & 1 deletion Sources/SwipeCell/SwipeCellViewModifier3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ import SwiftUI
extension SwipeCellModifier {
func getGesture() -> _EndedGesture<_ChangedGesture<DragGesture>> {
//为了避免editMode切换时的异常动画,所以在进入editmode后仍然继续绘制Slots,只是对手势做了处理,避免了滑动
let nonEditGragMinDistance: CGFloat = {
if #available(iOS 18, *) {
#if compiler(>=6.0)
return 20
#endif
}
return 0
}()
return DragGesture(
minimumDistance: editMode?.wrappedValue == .active ? 10000 : 0,
minimumDistance: editMode?.wrappedValue == .active ? 10000 : nonEditGragMinDistance,
coordinateSpace: .local
)
.onChanged { value in
Expand Down

0 comments on commit 0196fcf

Please sign in to comment.