- Leading and Trailing gesture for the any SwiftUIView
- Prolonged gesture to activate an edge action
- Managing visibility without relying on a gesture, using a flag.
- Customization of the font, width, color, icon/text of action buttons.
- iOS 15.0+
- Xcode 16+
To install Lottie using Swift Package Manager you can follow the tutorial published by Apple using the URL for the Lottie repo with the current version:
- In Xcode, select “File” -> “Add Packages...”
- Enter the repository path https://github.com/Rayllienstery/TMSwipeActions
or you can add the following dependency to your Package.swift
:
.package(url: "https://github.com/Rayllienstery/TMSwipeActions", from: "0.1.0")
It supports buttons with the text content
import TMSwipeActions
Button { ...action } label: { ...views }
.leadingSwipe([
.init(title: "Just", color: .darkBlue, action: { print("Just on tap") })
])
Button { ...action } label: { ...views }
.trailingSwipe([
.init(title: "Useful", color: .darkBlue, action: {})
])
Button { ...action } label: { ...views }
.swipeActions(leadingActions: [
.init(title: "Just", color: .darkBlue, action: {})
], trailingActions: [
.init(title: "Useful", color: .darkBlue, action: {})
])
Button { ...action } label: { ...views }
.swipeActions(leadingActions: [ ],
trailingActions: [
.init(icon: UIImage(systemName: "square.and.arrow.up")!, color: .darkBlue, action: {}),
.init(icon: UIImage(systemName: "pencil")!, color: .darkBlueSecondary, action: {}),
.init(icon: UIImage(systemName: "bookmark")!, color: .darkBlueTertiary, action: {})
])
Use viewConfig to change the width and font, or to disable prolonged swipe.
Also you can pass flags to controll current actions View state
@State var leadingContentIsPresented: Bool = false
@State var trailingContentIsPresented: Bool = false
Button { ...action } label: { ...views }
.swipeActions(leadingActions: [
.init(title: "Just", color: .darkBlue, action: {})
], trailingActions: [
.init(title: "Hello", color: .darkBlue, action: {}),
.init(title: "World", color: .darkBlueSecondary, action: {}),
.init(title: "!", color: .darkBlueTertiary, action: {})
],
viewConfig: .init(leadingFullSwipeIsEnabled: false,
trailingFullSwipeIsEnabled: false,
actionWidth: 100,
font: .headline),
leadingContentIsPresented: $leadingContentIsPresented,
trailingContentIsPresented: $trailingContentIsPresented)
Package released under the Apache 2.0 license, check the LICENSE file for more info.