Skip to content

Commit

Permalink
readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
fatbobman committed Aug 6, 2020
1 parent cdcbc93 commit 51ea39c
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 2 deletions.
93 changes: 92 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,94 @@
# SwipeCell

A description of this package.
SwipeCell 是一个用Swift 5.3开发的 SwiftUI库.目标是为了实现类似iOS Mail程序实现的左右滑动菜单功能.
SwipeCell可以运行在iOS13及以上版本

## 按钮配置
```swift
let button1 = SwipeCellButton(buttonStyle: .titleAndImage,
title: "Mark",
systemImage: "bookmark",
titleColor: .white,
imageColor: .white,
view: nil,
backgroundColor: .green,
action: {bookmark.toggle()},
feedback:true
)
```

```swift
//你可以将按钮设置成任意View从而实现更复杂的设计以及动态效果
let button3 = SwipeCellButton(buttonStyle: .view, title:"",systemImage: "", view: {
AnyView(
Group{
if unread {
Image(systemName: "envelope.badge")
.foregroundColor(.white)
.font(.title)
}
else {
Image(systemName: "envelope.open")
.foregroundColor(.white)
.font(.title)
}
}
)
}, backgroundColor: .orange, action: {unread.toggle()}, feedback: false)
```

## Slot配置
```swift
let slot1 = SwipeCellSlot(slots: [button2,button1])
let slot2 = SwipeCellSlot(slots: [button4], slotStyle: .destructive, buttonWidth: 60) //销毁模式
```

## 装配
```swift
cellView()
.swipeCell(cellPosition: .left, leftSlot: slot4, rightSlot: nil)
```
*更多的配置选项*
```swift
cellView()
.swipeCell(cellPosition: .both,
leftSlot: slot1,
rightSlot: slot1 ,
swipeCellStyle: SwipeCellStyle(
alignment: .leading,
dismissWidth: 20,
appearWidth: 20,
destructiveWidth: 240,
vibrationForButton: .error,
vibrationForDestructive: .heavy,
autoResetTime: 3)
)
```

## 滚动列表自动消除
```swift
List{
```
}
.dismissSwipeCell()
}
```
* dismissSwipeCell 在editmode下支持选择,但响应较慢
* dismissSwipeCellFast 在editmode下选择cell有问题,但响应迅速
* dismissSwipeCellForScrollView 用于ScrollView

由于SwiftUI没有很好的方案能够获取滚动状态,所以采用了 [Introspect](https://github.com/siteline/SwiftUI-Introspect.git)实现的上述功能.



下载[Demo](https://github.com/fatbobman/SwipeCellDemo.git)

## 当前问题
* 动画细节仍然不足
* 滚动列表自动消除Button的实现还不完全
* EditMode模式下仍有不足


## 欢迎多提宝贵意见


2 changes: 1 addition & 1 deletion Sources/SwipeCell/SwipeCellConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public struct SwipeCellSlot{
public let appearAnimation:Animation
public let dismissAnimation:Animation

public init(slots:[SwipeCellButton],slotStyle:SwipeCellSlotStyle = .normal,buttonWidth:CGFloat = 74,sticky:Bool = true,appearAnimation:Animation = .easeOut(duration:0.5),dismissAnimation:Animation = .interactiveSpring()){
public init(slots:[SwipeCellButton],slotStyle:SwipeCellSlotStyle = .normal,buttonWidth:CGFloat = 74,appearAnimation:Animation = .easeOut(duration:0.5),dismissAnimation:Animation = .interactiveSpring()){
self.buttonWidth = buttonWidth
self.slots = slots
self.slotStyle = slotStyle
Expand Down

0 comments on commit 51ea39c

Please sign in to comment.