Skip to content

Rayllienstery/TMSwipeActions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TMSwipeActions (SwiftUI)


Features

  • 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.

Requirements

  • iOS 15.0+
  • Xcode 16+

Installation

Swift Package Manager

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:

or you can add the following dependency to your Package.swift:

.package(url: "https://github.com/Rayllienstery/TMSwipeActions", from: "0.1.0")

Usage example

Just add swipe gestures for the any View

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: {})
])

And UIImage symbols


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: {})
                    ])

Customisation

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)

License


Package released under the Apache 2.0 license, check the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages