### Install SwipeActions via Swift Package Manager Source: https://github.com/aheze/swipeactions/blob/main/README.md Add the SwipeActions library to your project using Swift Package Manager. ```bash https://github.com/aheze/SwipeActions ``` -------------------------------- ### Basic Swipe Action Implementation Source: https://github.com/aheze/swipeactions/blob/main/README.md Demonstrates how to add a trailing swipe action to a Text view. The action is labeled 'World' and prints 'Tapped!' when executed. ```swift import SwiftUI import SwipeActions struct ContentView: View { var body: some View { SwipeView { Text("Hello") .frame(maxWidth: .infinity) .padding(.vertical, 32) .background(Color.blue.opacity(0.1)) .cornerRadius(32) } trailingActions: { _ in SwipeAction("World") { print("Tapped!") } } .padding() } } ``` -------------------------------- ### Basic SwipeAction with Modifiers Source: https://github.com/aheze/swipeactions/blob/main/README.md Demonstrates applying modifiers to both SwipeAction and SwipeView for customization. Use `.allowSwipeToTrigger()` on SwipeAction and `.swipeActionsStyle()` on SwipeView. ```swift SwipeView { Text("Hello") } leadingActions: { _ in } trailingActions: { _ in SwipeAction("World") { print("Tapped!") } .allowSwipeToTrigger() /// Modifiers for `SwipeAction` go here. } .swipeActionsStyle(.cascade) /// Modifiers for `SwipeView` go here. ``` -------------------------------- ### MIT License Source: https://github.com/aheze/swipeactions/blob/main/README.md This snippet contains the MIT License text for the SwipeActions software. ```text MIT License Copyright (c) 2023 A. Zheng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -------------------------------- ### Enable Swiping on Transparent Areas Source: https://github.com/aheze/swipeactions/blob/main/README.md Add the `.contentShape(Rectangle())` modifier to a view to enable swiping interactions even on its transparent or empty space. ```swift SwipeView { Text("Lots of empty space here.") .frame(maxWidth: .infinity) .padding(.vertical, 32) .contentShape(Rectangle()) /// Enable swiping on the empty space. } trailingActions: { _ in SwipeAction("Hello!") { } } ``` -------------------------------- ### Programmatic Swipe Control Source: https://github.com/aheze/swipeactions/blob/main/README.md Control the expansion and closure of swipe actions programmatically using a Combine PassthroughSubject. This is useful for triggering actions based on external events. ```swift import Combine import SwiftUI import SwipeActions struct ProgrammaticSwipeView: View { @State var open = PassthroughSubject() var body: some View { SwipeView { Button { open.send() /// Fire the `PassthroughSubject`. } label: { Text("Tap to Open") .frame(maxWidth: .infinity) .padding(.vertical, 32) .background(Color.blue.opacity(0.1)) .cornerRadius(32) } } trailingActions: { SwipeAction("Tap to Close") { context.state.wrappedValue = .closed } .onReceive(open) { _ in /// Receive the `PassthroughSubject`. context.state.wrappedValue = .expanded } } } } ``` -------------------------------- ### Accordion Style SwipeViewGroup Source: https://github.com/aheze/swipeactions/blob/main/README.md Use SwipeViewGroup to ensure only one swipe view is open at a time, creating an accordion effect. ```swift SwipeViewGroup { SwipeView {} /// Only one of the actions will be shown. SwipeView {} SwipeView {} } ``` -------------------------------- ### SwipeView Modifier: swipeOffsetExpandAnimation Source: https://github.com/aheze/swipeactions/blob/main/README.md Configures the animation parameters (stiffness and damping) for expanding the swipe actions view. Use this to control the animation's feel. ```swift func swipeOffsetExpandAnimation(stiffness: Double, damping: Double) ``` -------------------------------- ### SwipeView Modifier: swipeReadyToExpandPadding Source: https://github.com/aheze/swipeactions/blob/main/README.md Sets the drag distance required for the swipe actions to enter the 'ready to expand' state. This is the point where actions become visible. ```swift func swipeReadyToExpandPadding(_ value: Double) ``` -------------------------------- ### SwipeView Modifier: swipeReadyToTriggerPadding Source: https://github.com/aheze/swipeactions/blob/main/README.md Sets the drag distance required for the swipe actions to enter the 'ready to trigger' state. This is the point where an action will be executed upon release. ```swift func swipeReadyToTriggerPadding(_ value: Double) ``` -------------------------------- ### SwipeView Modifier: swipeOffsetTriggerAnimation Source: https://github.com/aheze/swipeactions/blob/main/README.md Configures the animation parameters (stiffness and damping) for the trigger animation of swipe actions. Use this to control the animation's feel. ```swift func swipeOffsetTriggerAnimation(stiffness: Double, damping: Double) ``` -------------------------------- ### SwipeView Modifier: swipeOffsetCloseAnimation Source: https://github.com/aheze/swipeactions/blob/main/README.md Configures the animation parameters (stiffness and damping) for closing the swipe actions view. Use this to control the animation's feel. ```swift func swipeOffsetCloseAnimation(stiffness: Double, damping: Double) ``` -------------------------------- ### SwipeView Modifier: swipeActionWidth Source: https://github.com/aheze/swipeactions/blob/main/README.md Specifies a fixed width for each individual swipe action. This can be useful for consistent layout. ```swift func swipeActionWidth(_ value: Double) ``` -------------------------------- ### SwipeView Modifier: swipeSpacing Source: https://github.com/aheze/swipeactions/blob/main/README.md Defines the spacing between adjacent swipe actions and between the actions and the main content view. ```swift func swipeSpacing(_ value: Double) ``` -------------------------------- ### SwipeView Modifier: swipeActionsStyle Source: https://github.com/aheze/swipeactions/blob/main/README.md Defines the visual style for the swipe actions. Accepted values are `.mask`, `.equalWidths`, or `.cascade`. ```swift func swipeActionsStyle(_ value: SwipeActionStyle) ``` -------------------------------- ### SwipeView Modifier: swipeActionsVisibleStartPoint Source: https://github.com/aheze/swipeactions/blob/main/README.md Determines the drag point at which the swipe actions begin to become visible. This is a value between 0 and 1. ```swift func swipeActionsVisibleStartPoint(_ value: Double) ``` -------------------------------- ### SwipeAction Modifier: allowSwipeToTrigger Source: https://github.com/aheze/swipeactions/blob/main/README.md Enables drag-to-trigger functionality for a specific edge action. This modifier is applied directly to a `SwipeAction`. ```swift func allowSwipeToTrigger(_ value: Bool = true) ``` -------------------------------- ### SwipeView Modifier: swipeMinimumDistance Source: https://github.com/aheze/swipeactions/blob/main/README.md Sets the minimum distance the user must drag to initiate the swipe gesture. A value greater than 0 is recommended for better compatibility with other gestures. ```swift func swipeMinimumDistance(_ value: Double) ``` -------------------------------- ### SwipeView Modifier: swipeAllowSingleSwipeAcross Source: https://github.com/aheze/swipeactions/blob/main/README.md If true, allows the user to swipe from leading to trailing actions (or vice versa) in a single continuous gesture. ```swift func swipeAllowSingleSwipeAcross(_ value: Bool) ``` -------------------------------- ### SwipeView Modifier: swipeActionContentTriggerAnimation Source: https://github.com/aheze/swipeactions/blob/main/README.md Specifies the animation used for adjusting the content view when a swipe action is triggered. Accepts any `Animation` type. ```swift func swipeActionContentTriggerAnimation(_ value: Animation) ``` -------------------------------- ### SwipeView Modifier: swipeMinimumPointToTrigger Source: https://github.com/aheze/swipeactions/blob/main/README.md Ensures a minimum drag distance is met to trigger an edge action, even if the total width of actions is small. This prevents accidental triggers. ```swift func swipeMinimumPointToTrigger(_ value: Double) ``` -------------------------------- ### SwipeView Modifier: swipeActionsVisibleEndPoint Source: https://github.com/aheze/swipeactions/blob/main/README.md Determines the drag point at which the swipe actions become fully visible. This is a value between 0 and 1. ```swift func swipeActionsVisibleEndPoint(_ value: Double) ``` -------------------------------- ### SwipeAction Modifier: swipeActionLabelFixedSize Source: https://github.com/aheze/swipeactions/blob/main/README.md Constrains the content size of the swipe action label, which is particularly useful for text-based labels. Set to true to fix the size. ```swift func swipeActionLabelFixedSize(_ value: Bool = true) ``` -------------------------------- ### SwipeView Modifier: swipeEnableTriggerHaptics Source: https://github.com/aheze/swipeactions/blob/main/README.md Enables haptic feedback when an edge action is triggered. This applies when `swipeToTriggerLeadingEdge` or `swipeToTriggerTrailingEdge` is true. ```swift func swipeEnableTriggerHaptics(_ value: Bool) ``` -------------------------------- ### SwipeView Modifier: swipeActionsMaskCornerRadius Source: https://github.com/aheze/swipeactions/blob/main/README.md Sets the corner radius for the mask that encompasses all swipe actions. This is used when the style is `.mask`. ```swift func swipeActionsMaskCornerRadius(_ value: Double) ``` -------------------------------- ### SwipeAction Modifier: swipeActionLabelHorizontalPadding Source: https://github.com/aheze/swipeactions/blob/main/README.md Adds extra horizontal padding around the swipe action's label. The default value is 16. ```swift func swipeActionLabelHorizontalPadding(_ value: Double = 16) ``` -------------------------------- ### SwipeView Modifier: swipeActionCornerRadius Source: https://github.com/aheze/swipeactions/blob/main/README.md Sets the corner radius for individual swipe action views. This applies to each action within the SwipeView. ```swift func swipeActionCornerRadius(_ value: Double) ``` -------------------------------- ### SwipeView Modifier: swipeStretchRubberBandingPower Source: https://github.com/aheze/swipeactions/blob/main/README.md Controls the rubber banding effect when stretching beyond the swipeable area. This modifier is active when swipe-to-trigger is disabled or actions are absent on one side. ```swift func swipeStretchRubberBandingPower(_ value: Double) ``` -------------------------------- ### SwipeAction Modifier: swipeActionChangeLabelVisibilityOnly Source: https://github.com/aheze/swipeactions/blob/main/README.md Controls whether only the label's visibility changes during a swipe, rather than the entire action view. Requires a boolean value. ```swift func swipeActionChangeLabelVisibilityOnly(_ value: Bool) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.