{"id":13478982,"url":"https://github.com/aheze/SwipeActions","last_synced_at":"2025-03-27T08:31:13.358Z","repository":{"id":152825583,"uuid":"627232186","full_name":"aheze/SwipeActions","owner":"aheze","description":"Add customizable swipe actions to any view.","archived":false,"fork":false,"pushed_at":"2024-07-09T03:11:33.000Z","size":8945,"stargazers_count":1167,"open_issues_count":25,"forks_count":54,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-26T05:03:34.890Z","etag":null,"topics":["drag","gesture","ios","list","notifications","swift","swiftui","swipe","swipe-actions"],"latest_commit_sha":null,"homepage":"https://twitter.com/aheze0/status/1646399867764510721","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aheze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-04-13T03:38:15.000Z","updated_at":"2025-03-24T09:54:31.000Z","dependencies_parsed_at":"2024-07-09T06:24:11.816Z","dependency_job_id":"dde59a61-9344-4dcb-9e80-d1270e78e9f9","html_url":"https://github.com/aheze/SwipeActions","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheze%2FSwipeActions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheze%2FSwipeActions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheze%2FSwipeActions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheze%2FSwipeActions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aheze","download_url":"https://codeload.github.com/aheze/SwipeActions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245591626,"owners_count":20640692,"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":["drag","gesture","ios","list","notifications","swift","swiftui","swipe","swipe-actions"],"created_at":"2024-07-31T16:02:07.082Z","updated_at":"2025-03-27T08:31:13.333Z","avatar_url":"https://github.com/aheze.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"\u003ca href=\"#\"\u003e\u003cimg src=\"Assets/Header.png\" width=\"400\" alt=\"SwipeActions\"\u003e\u003c/a\u003e\n\nAdd customizable swipe actions to any view.\n\n- Enable swipe actions on any view, not just Lists.\n- Customize literally everything — corner radius, color, etc...\n- Supports drag-to-delete and advanced gesture handling.\n- Fine-tune animations and styling to your taste.\n- Programmatically show/hide swipe actions.\n- Automatically close when interacting with other views.\n- Made with 100% SwiftUI. Supports iOS 14+.\n- Lightweight, no dependencies. One file.\n\n\n![General](Assets/General.png) | ![Basics](Assets/Basics.png) | ![Customization](Assets/Customization.png)\n| --- | --- | --- |\n![Styles](Assets/Styles.png) | ![Animations](Assets/Animations.png) | ![Advanced](Assets/Advanced.png)\n\n\n\n### Installation\n\nSwipeActions is available via the [Swift Package Manager](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app). Alternatively, because all of SwipeActions is contained within a single file, drag [`SwipeActions.swift`](https://github.com/aheze/SwipeActions/blob/main/Sources/SwipeActions.swift) into your project. Requires iOS 14+.\n\n```\nhttps://github.com/aheze/SwipeActions\n```\n\n### Usage\n\n```swift\nimport SwiftUI\nimport SwipeActions\n\nstruct ContentView: View {\n    var body: some View {\n        SwipeView {\n            Text(\"Hello\")\n                .frame(maxWidth: .infinity)\n                .padding(.vertical, 32)\n                .background(Color.blue.opacity(0.1))\n                .cornerRadius(32)\n        } trailingActions: { _ in\n            SwipeAction(\"World\") {\n                print(\"Tapped!\")\n            }\n        }\n        .padding()\n    }\n}\n```\n\n\u003cimg src=\"Assets/Result.png\" width=\"300\" alt=\"The result, 'World' displayed on the right.\"\u003e\n\n\n### Examples\n\nCheck out the [example app](https://github.com/aheze/SwipeActions/archive/refs/heads/main.zip) for all examples and advanced usage!\n\n![2 screenshots of the example app](Assets/ExampleApp.png)\n\n### Customization\n\nSwipeActions supports over 20 modifiers for customization. To use them, simply attach the modifier to `SwipeAction`/`SwipeView`.\n\n```swift\nSwipeView {\n    Text(\"Hello\")\n} leadingActions: { _ in\n} trailingActions: { _ in\n    SwipeAction(\"World\") {\n        print(\"Tapped!\")\n    }\n    .allowSwipeToTrigger() /// Modifiers for `SwipeAction` go here.\n}\n.swipeActionsStyle(.cascade) /// Modifiers for `SwipeView` go here.\n```\n\n```swift\n// MARK: - Available modifiers for `SwipeAction` (the side views)\n\n/**\n Apply this to the edge action to enable drag-to-trigger.\n\n     SwipeView {\n         Text(\"Swipe\")\n     } leadingActions: { _ in\n         SwipeAction(\"1\") {}\n             .allowSwipeToTrigger()\n\n         SwipeAction(\"2\") {}\n     } trailingActions: { _ in\n         SwipeAction(\"3\") {}\n\n         SwipeAction(\"4\") {}\n             .allowSwipeToTrigger()\n     }\n */\nfunc allowSwipeToTrigger(_ value: Bool = true)\n\n/// Constrain the action's content size (helpful for text).\nfunc swipeActionLabelFixedSize(_ value: Bool = true) \n\n/// Additional horizontal padding.\nfunc swipeActionLabelHorizontalPadding(_ value: Double = 16)\n\n/// The opacity of the swipe actions, determined by `actionsVisibleStartPoint` and `actionsVisibleEndPoint`.\nfunc swipeActionChangeLabelVisibilityOnly(_ value: Bool) \n```\n\n```swift\n// MARK: - Available modifiers for `SwipeView` (the main view)\n\n/// The minimum distance needed to drag to start the gesture. Should be more than 0 for best compatibility with other gestures/buttons.\nfunc swipeMinimumDistance(_ value: Double) \n\n/// The style to use (`mask`, `equalWidths`, or `cascade`).\nfunc swipeActionsStyle(_ value: SwipeActionStyle) \n\n/// The corner radius that encompasses all actions.\nfunc swipeActionsMaskCornerRadius(_ value: Double) \n\n/// At what point the actions start becoming visible.\nfunc swipeActionsVisibleStartPoint(_ value: Double) \n\n/// At what point the actions become fully visible.\nfunc swipeActionsVisibleEndPoint(_ value: Double)\n\n/// The corner radius for each action.\nfunc swipeActionCornerRadius(_ value: Double) \n\n/// The width for each action.\nfunc swipeActionWidth(_ value: Double) \n\n/// Spacing between actions and the label view.\nfunc swipeSpacing(_ value: Double) \n\n/// The point where the user must drag to expand actions.\nfunc swipeReadyToExpandPadding(_ value: Double) \n\n/// The point where the user must drag to enter the `triggering` state.\nfunc swipeReadyToTriggerPadding(_ value: Double) \n\n/// Ensure that the user must drag a significant amount to trigger the edge action, even if the actions' total width is small.\nfunc swipeMinimumPointToTrigger(_ value: Double) \n\n/// Applies if `swipeToTriggerLeadingEdge/swipeToTriggerTrailingEdge` is true.\nfunc swipeEnableTriggerHaptics(_ value: Bool) \n\n/// Applies if `swipeToTriggerLeadingEdge/swipeToTriggerTrailingEdge` is false, or when there's no actions on one side.\nfunc swipeStretchRubberBandingPower(_ value: Double)\n\n/// If true, you can change from the leading to the trailing actions in one single swipe.\nfunc swipeAllowSingleSwipeAcross(_ value: Bool) \n\n/// The animation used for adjusting the content's view when it's triggered.\nfunc swipeActionContentTriggerAnimation(_ value: Animation)\n\n/// Values for controlling the close animation.\nfunc swipeOffsetCloseAnimation(stiffness: Double, damping: Double)\n\n/// Values for controlling the expand animation.\nfunc swipeOffsetExpandAnimation(stiffness: Double, damping: Double)\n\n/// Values for controlling the trigger animation.\nfunc swipeOffsetTriggerAnimation(stiffness: Double, damping: Double)\n```\n\nExample usage of these modifiers is available in the [example app](https://github.com/aheze/SwipeActions/archive/refs/heads/main.zip).\n\n### Notes\n\n- To automatically close swipe views when another one is swiped (accordion style), use `SwipeViewGroup`.\n\n```swift\nSwipeViewGroup {\n    SwipeView {} /// Only one of the actions will be shown.\n    SwipeView {}\n    SwipeView {}\n}\n```\n\n- To programmatically show/hide actions, use the `context` parameter.\n\n```swift\nimport Combine\nimport SwiftUI\nimport SwipeActions\n\nstruct ProgrammaticSwipeView: View {\n    @State var open = PassthroughSubject\u003cVoid, Never\u003e()\n\n    var body: some View {\n        SwipeView {\n            Button {\n                open.send() /// Fire the `PassthroughSubject`.\n            } label: {\n                Text(\"Tap to Open\")\n                    .frame(maxWidth: .infinity)\n                    .padding(.vertical, 32)\n                    .background(Color.blue.opacity(0.1))\n                    .cornerRadius(32)\n            }\n        } trailingActions: { context in\n            SwipeAction(\"Tap to Close\") {\n                context.state.wrappedValue = .closed\n            }\n            .onReceive(open) { _ in /// Receive the `PassthroughSubject`.\n                context.state.wrappedValue = .expanded\n            }\n        }\n    }\n}\n```\n\n- To enable swiping on transparent areas, add `.contentShape(Rectangle())`.\n\n```swift\nSwipeView {\n    Text(\"Lots of empty space here.\")\n        .frame(maxWidth: .infinity)\n        .padding(.vertical, 32)\n        .contentShape(Rectangle()) /// Enable swiping on the empty space.\n} trailingActions: { _ in\n    SwipeAction(\"Hello!\") { }\n}\n```\n\n- Everything in the example app is swipeable — even the gray-capsule headers!\n\n\u003cimg src=\"Assets/ExampleAppHeaders.png\" width=\"300\" alt=\"The 'Styles' header swiped to the left and the 'Open' action shown on the right.\"\u003e\n\n\n### Community\n\nAuthor | Contributing | Need Help?\n--- | --- | ---\nSwipeActions is made by [aheze](https://github.com/aheze). | All contributions are welcome. Just [fork](https://github.com/aheze/SwipeActions/fork) the repo, then make a pull request. | Open an [issue](https://github.com/aheze/SwipeActions/issues) or join the [Discord server](https://discord.com/invite/Pmq8fYcus2). You can also ping me on [Twitter](https://twitter.com/aheze0).\n\n### License\n\n```\nMIT License\n\nCopyright (c) 2023 A. Zheng\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n---\n\nhttps://user-images.githubusercontent.com/49819455/231671743-baca394e-fc74-4062-83eb-2024b8add924.mp4\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faheze%2FSwipeActions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faheze%2FSwipeActions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faheze%2FSwipeActions/lists"}