{"id":18270065,"url":"https://github.com/fatbobman/SwipeCell","last_synced_at":"2025-04-04T23:31:44.571Z","repository":{"id":39530792,"uuid":"285495162","full_name":"fatbobman/SwipeCell","owner":"fatbobman","description":"SwipeCell is a SwiftUI library, used to achieve the left and right sliding menu effect similar to the iOS mail app.","archived":false,"fork":false,"pushed_at":"2024-12-19T12:09:59.000Z","size":36272,"stargazers_count":299,"open_issues_count":5,"forks_count":43,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-02T05:55:45.131Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fatbobman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"fatbobman","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"fatbobman","thanks_dev":null,"custom":["https://afdian.com","https://www.paypal.com/paypalme/fatbobman"]}},"created_at":"2020-08-06T06:46:04.000Z","updated_at":"2025-04-01T08:03:57.000Z","dependencies_parsed_at":"2024-11-14T08:02:09.026Z","dependency_job_id":"267cb557-2a54-447f-b70b-1340ef8620ad","html_url":"https://github.com/fatbobman/SwipeCell","commit_stats":{"total_commits":59,"total_committers":5,"mean_commits":11.8,"dds":0.288135593220339,"last_synced_commit":"52d87cd7a056fcb2a09bd00db2fa6612c8244c0b"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatbobman%2FSwipeCell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatbobman%2FSwipeCell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatbobman%2FSwipeCell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatbobman%2FSwipeCell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fatbobman","download_url":"https://codeload.github.com/fatbobman/SwipeCell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266476,"owners_count":20910831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T11:38:15.870Z","updated_at":"2025-04-04T23:31:44.565Z","avatar_url":"https://github.com/fatbobman.png","language":"Swift","readme":"# SwipeCell\n\nSwipeCell 是一个用Swift 5.3开发的 SwiftUI库.目标是为了实现类似iOS Mail程序实现的左右滑动菜单功能.\nSwipeCell 需要 XCode 12 ,iOS 14 \n\n![Demo](Image/demo.gif)\n\n## 配置Button\n```swift\nlet button1 = SwipeCellButton(buttonStyle: .titleAndImage,\n                title: \"Mark\", \n                systemImage: \"bookmark\",\n                titleColor: .white, \n                imageColor: .white, \n                view: nil,   \n                backgroundColor: .green,\n                action: {bookmark.toggle()},\n                feedback:true\n                )\n```\n\n```swift\n//你可以将按钮设置成任意View从而实现更复杂的设计以及动态效果\nlet button3 = SwipeCellButton(buttonStyle: .view, title:\"\",systemImage: \"\", view: {\n    AnyView(\n        Group{\n            if unread {\n                Image(systemName: \"envelope.badge\")\n                    .foregroundColor(.white)\n                    .font(.title)\n            }\n            else {\n                Image(systemName: \"envelope.open\")\n                    .foregroundColor(.white)\n                    .font(.title)\n            }\n        }\n    )\n}, backgroundColor: .orange, action: {unread.toggle()}, feedback: false)\n```\n\n## 配置Slot\n```swift\nlet slot1 = SwipeCellSlot(slots: [button2,button1])\nlet slot2 = SwipeCellSlot(slots: [button4], slotStyle: .destructive, buttonWidth: 60) \nlet slot3 = SwipeCellSlot(slots: [button2,button1],slotStyle: .destructiveDelay) \n```\n\n## 装配\n```swift\ncellView()\n    .swipeCell(cellPosition: .left, leftSlot: slot4, rightSlot: nil)\n```\n*更多的配置选项*\n```swift\ncellView()\n    .swipeCell(cellPosition: .both, \n                leftSlot: slot1, \n                rightSlot: slot1 ,\n                swipeCellStyle: SwipeCellStyle(\n                            alignment: .leading,\n                            dismissWidth: 20,\n                            appearWidth: 20,\n                            destructiveWidth: 240, \n                            vibrationForButton: .error, \n                            vibrationForDestructive: .heavy, \n                            autoResetTime: 3)\n                            )\n```\n\n## 滚动列表自动消除\n*For List*\n```swift\n  List{\n     ```\n  }\n  .dismissSwipeCell()\n}\n```\n\n*For single cell in ScrollView*\n```swift\nScrollView{\n    VStack{\n        Text(\"Mail Title\")\n            .dismissSwipeCellForScrollView() \n        Text(\"Mail Content\")\n        ....\n    }\n    .frame(maxWidth:.infinity,maxHeight: .infinity)\n}\n.swipeCell(cellPosition: .both, leftSlot: leftSlot, rightSlot: rightSlot,clip: false)\n```\n\n*For LazyVStack in ScrollView*\n```swift\nScrollView{\n    LazyVStack{\n    ForEach(lists,id:\\.self){ item in\n       Text(\"Swipe in scrollView:\\(item)\")\n        .frame(height:80)\n        .swipeCell(cellPosition: .both, leftSlot:slot, rightSlot: slot)\n        .dismissSwipeCellForScrollViewForLazyVStack()\n    }\n    }\n}\n```\n\nGet Cell Status\n```swift\nHStack{\n    Text(\"Cell Status:\")\n    Text(status.rawValue)\n        .foregroundColor(.red)\n        //get the cell status from Environment\n        .transformEnvironment(\\.cellStatus, transform: { cellStatus in\n            let temp = cellStatus\n            DispatchQueue.main.async {\n                self.status = temp\n            }\n        })\n}\n.frame(maxWidth:.infinity,alignment: .center)\n.frame(height:100)\n.swipeCell(cellPosition: .both, leftSlot: slot, rightSlot: slot)\n```\n\n\n* dismissSwipeCell 在editmode下支持选择\n* dismissSwipeCellForScrollView 用于ScrollView,通常用于只有一个Cell的场景,比如说Mail中的邮件内容显示.参看Demo中的演示\n* dismissSwipeCellForScrollViewForLazyVStack 用于ScrollView中使用LazyVStack场景.个别时候会打断滑动菜单出现动画.个人觉得如无特别需要还是使用List代替LazyVStack比较好.\n\n\n由于SwiftUI没有很好的方案能够获取滚动状态,所以采用了 [Introspect](https://github.com/siteline/SwiftUI-Introspect.git)实现的上述功能.\n\ndestructiveDelay 形式的 button，需要在action中添加 dismissDestructiveDelayButton()已保证在alter执行后，Cell复位\n\n\n\n## 当前问题\n* 动画细节仍然不足\n* EditMode模式下仍有不足\n\n\n## 欢迎多提宝贵意见!\n\nSwipeCell is available under the [MIT license](LICENSE.md).\n\nYou can give your feedback or suggestions by creating Issues. You can also contact me on Twitter [@fatbobman](https://x.com/fatbobman).\n","funding_links":["https://patreon.com/fatbobman","https://buymeacoffee.com/fatbobman","https://afdian.com","https://www.paypal.com/paypalme/fatbobman"],"categories":["etc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatbobman%2FSwipeCell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffatbobman%2FSwipeCell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatbobman%2FSwipeCell/lists"}