Skip to content

Commit

Permalink
修改了按钮响应区域
Browse files Browse the repository at this point in the history
  • Loading branch information
fatbobman committed Sep 9, 2020
1 parent 4f92410 commit fd79dde
Showing 1 changed file with 25 additions and 31 deletions.
56 changes: 25 additions & 31 deletions Sources/SwipeCell/SwipeCellViewModifier1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,39 +129,8 @@ struct SwipeCellModifier:ViewModifier{
.overlay(
ZStack(alignment: position == .left ? .trailing : .leading){
Color.clear

buttonView(slot, i)
.contentShape(Rectangle())
.onTapGesture{
if slot.slotStyle == .destructiveDelay && i == slot.slots.count - 1 {
withAnimation(.easeInOut){
if position == .left {
offset = frameWidth
// showDalayButtonWith = slot.buttonWidth * CGFloat(slot.slots.count - 1)
showDalayButtonWith = 0.0001 //修改成iOS14的样式

}
else {
offset = -frameWidth
// showDalayButtonWith = -(slot.buttonWidth * CGFloat(slot.slots.count - 1))
showDalayButtonWith = -0.0001

}
}
if buttons[i].feedback {
successFeedBack(swipeCellStyle.vibrationForDestructive)
}
}
else {
if buttons[i].feedback {
successFeedBack(swipeCellStyle.vibrationForButton)
}
}
buttons[i].action()
if !(slot.slotStyle == .destructiveDelay && i == slot.slots.count - 1) {
resetStatus()
}
}
.frame(width:slot.buttonWidth)
.offset(x:spaceWidth)
.alignmentGuide(.trailing, computeValue: { d in
Expand Down Expand Up @@ -199,7 +168,32 @@ struct SwipeCellModifier:ViewModifier{
)
.contentShape(Rectangle())
.onTapGesture{
if slot.slotStyle == .destructiveDelay && i == slot.slots.count - 1 {
withAnimation(.easeInOut){
if position == .left {
offset = frameWidth
showDalayButtonWith = 0.0001 //修改成iOS14的样式

}
else {
offset = -frameWidth
showDalayButtonWith = -0.0001

}
}
if buttons[i].feedback {
successFeedBack(swipeCellStyle.vibrationForDestructive)
}
}
else {
if buttons[i].feedback {
successFeedBack(swipeCellStyle.vibrationForButton)
}
}
buttons[i].action()
if !(slot.slotStyle == .destructiveDelay && i == slot.slots.count - 1) {
resetStatus()
}
}
}

Expand Down

0 comments on commit fd79dde

Please sign in to comment.