Skip to content

Commit

Permalink
Merge pull request #32 from dscyrescotti/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dscyrescotti authored Sep 10, 2022
2 parents 3f7a64e + a3e60ba commit 5207783
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
<img width="70%" src="https://github.com/dscyrescotti/ShuffleIt/blob/main/Assets/ShuffleIt.png?raw=true">
</p>

<p align="center">
<a href="https://swiftpackageindex.com/dscyrescotti/ShuffleIt">
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdscyrescotti%2FShuffleIt%2Fbadge%3Ftype%3Dplatforms"/>
</a>
<a href="https://swiftpackageindex.com/dscyrescotti/ShuffleIt">
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdscyrescotti%2FShuffleIt%2Fbadge%3Ftype%3Dswift-versions"/>
</a>
<a href="https://codecov.io/gh/dscyrescotti/ShuffleIt">
<img src="https://codecov.io/gh/dscyrescotti/ShuffleIt/branch/main/graph/badge.svg?token=D7DRKAD0VP"/>
</a>
<a href="https://github.com/dscyrescotti/ShuffleIt/actions/workflows/swift.yml">
<img src="https://github.com/dscyrescotti/ShuffleIt/actions/workflows/swift.yml/badge.svg" alt="Action Status"/>
</a>
<a href="LICENSE">
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
</a>
</p>

**ShuffleIt** is a user interface library for **SwiftUI** which delivers a collection of customizable stack views with a wide range of elegant shuffling, sliding and swiping behaviours.

<table>
Expand Down Expand Up @@ -58,7 +76,7 @@ dependencies: [
### Documentation
**ShuffleIt** provides a clear documentation to increase the familiarity with the API and shallow learning curve when using it. You can check it out via this [link](https://dscyrescotti.github.io/ShuffleIt/documentation/shuffleit/).

### Demo
### Demo Project
**ShuffleIt** also comes with the demo project which is an optimal spot to explore the API usage for available stack views. To run the demo project, you can use the following commands in your terminal.
```
> git clone https://github.com/dscyrescotti/ShuffleIt.git
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import SwiftUI

/// An environment key for a flag to decide on whether shuffling is disable or not.
@available(iOS 15.0, macOS 12.0, watchOS 8.0, *)
@available(tvOS, unavailable)
struct ShuffleDisabledKey: EnvironmentKey {
static var defaultValue: Bool = false
}

extension EnvironmentValues {
@available(iOS 15.0, macOS 12.0, watchOS 8.0, *)
@available(tvOS, unavailable)
var shuffleDisabled: Bool {
get { self[ShuffleDisabledKey.self] }
set { self[ShuffleDisabledKey.self] = newValue }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public extension View {
/// ```
/// - Parameter disabled: A boolean value to decide whether it should be disabled or not.
/// - Returns: A view with the given boolean.
@available(iOS 15.0, macOS 12.0, watchOS 8.0, *)
@available(tvOS, unavailable)
func swipeDisabled(_ disabled: Bool) -> some View {
environment(\.shuffleDisabled, disabled)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import SwiftUI

extension ShuffleStack {
/// A drag gesture that listens gesture state on content views and calculates rotation and position for shuffling.
@available(iOS 15.0, macOS 12.0, watchOS 8.0, *)
@available(tvOS, unavailable)
internal var dragGesture: some Gesture {
DragGesture()
.updating($isActiveGesture, body: { _, state, _ in
Expand Down
6 changes: 6 additions & 0 deletions Sources/ShuffleIt/ShuffleStack/View/ShuffleStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ import ViewInspector
public struct ShuffleStack<Data: RandomAccessCollection, StackContent: View>: View where Data.Index == Int {
@Environment(\.shuffleStyle) internal var style
@Environment(\.shuffleAnimation) internal var animation
#if !os(tvOS)
@Environment(\.shuffleDisabled) internal var disabled
#endif
@Environment(\.shuffleTrigger) internal var shuffleTrigger
@Environment(\.stackOffset) internal var offset
@Environment(\.stackPadding) internal var padding
Expand Down Expand Up @@ -99,12 +101,16 @@ public struct ShuffleStack<Data: RandomAccessCollection, StackContent: View>: Vi
Group {
leftContent
rightContent
#if os(tvOS)
mainContent
#else
if disabled {
mainContent
} else {
mainContent
.gesture(dragGesture)
}
#endif
}
.background {
GeometryReader { proxy in
Expand Down

0 comments on commit 5207783

Please sign in to comment.