Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sameersyd/fortunewheel
Fortune spinning wheel library built using SwiftUI, supports dynamic content.
https://github.com/sameersyd/fortunewheel
cocoapods cocoapods-library custom-animation figma fortune-wheel hacktoberfest ios ios-app ios14 material-design sameersyd spin-wheel spinner spm swift swift-package-manager swiftui ui-design wheel xcode
Last synced: 10 days ago
JSON representation
Fortune spinning wheel library built using SwiftUI, supports dynamic content.
- Host: GitHub
- URL: https://github.com/sameersyd/fortunewheel
- Owner: sameersyd
- License: apache-2.0
- Created: 2021-04-07T14:30:12.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-26T18:58:51.000Z (about 2 years ago)
- Last Synced: 2024-04-24T01:02:17.668Z (7 months ago)
- Topics: cocoapods, cocoapods-library, custom-animation, figma, fortune-wheel, hacktoberfest, ios, ios-app, ios14, material-design, sameersyd, spin-wheel, spinner, spm, swift, swift-package-manager, swiftui, ui-design, wheel, xcode
- Language: Swift
- Homepage:
- Size: 6.24 MB
- Stars: 84
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![CI Status](https://img.shields.io/travis/sameersyd/FortuneWheel.svg?style=flat)](https://travis-ci.org/sameersyd/FortuneWheel)
[![Version](https://img.shields.io/cocoapods/v/FortuneWheel.svg?style=flat)](https://cocoapods.org/pods/FortuneWheel)
[![License](https://img.shields.io/cocoapods/l/FortuneWheel.svg?style=flat)](https://cocoapods.org/pods/FortuneWheel)
[![Platform](https://img.shields.io/cocoapods/p/FortuneWheel.svg?style=flat)](https://cocoapods.org/pods/FortuneWheel)![GitHub Cards Preview](https://github.com/sameersyd/FortuneWheel/blob/master/art/GITHUB-COVER-SPM.png?raw=true)
# Fortune Wheel
Fortune spinning wheel 🎡 library built using SwiftUI, supports dynamic content.
## Preview - Spin Wheel ⚙️
![gif](https://github.com/sameersyd/FortuneWheel/blob/master/art/preview-wheel.gif)
## CocoaPods Installation
FortuneWheel is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'FortuneWheel'
```
## Swift Package Manager
```swift
dependencies: [
.package(url: "https://github.com/sameersyd/FortuneWheel.git", .upToNextMajor(from: "0.1.5"))
]
```
## Sample Code 🌟
Import Fortune Wheel in your file.
```ruby
import FortuneWheel
```Create a `FortuneWheelModel` and pass it to the view.
```swift
struct ContentView: View {private var players = ["Sameer", "Spikey", "Amelia", "Danny", "Karen", "Kathy"]
var body: some View {
let model = FortuneWheelModel(
titles: players, size: 320,
onSpinEnd: onSpinEnd,
getWheelItemIndex: getWheelItemIndex
)
ZStack {
FortuneWheel(model: model)
}
}private func onSpinEnd(index: Int) {
// your action here - based on index
}private func getWheelItemIndex() -> Int {
return getIndexFromAPI()
}
}
```
## Note:
#### When custom animation is used, provide it's duration in `animDuration` parameter
#### Change the `animDuration` only if custom animation is used, or it may cause delay in pointer result.
#### Function `getWheelItemIndex` will be called everytime wheel is spinned. If it's nil or provides invalid index, random element will be selected.
## Fortune Wheel properties
Parameter
Optional
Type
Default Value
titles
false
[String]
nil
size
false
CGFloat
nil
onSpinEnd
false
(Int) -> ()
nil
colors
true
[Color]
Color hex ["FBE488", "75AB53", "D1DC59", "EC9D42", "DE6037", "DA4533", "992C4D", "433589", "4660A8", "4291C8"]
pointerColor
true
Color
Color(hex: "DA4533")
strokeWidth
true
CGFloat
15
strokeColor
true
Color
Color(hex: "252D4F")
animDuration
true
Double
6
animation
true
Animation
Animation.timingCurve(0.51, 0.97, 0.56, 0.99, duration: 6)
getWheelItemIndex
true
() -> (Int)
nil
## UI Design 🎨
The UI for this Fortune Wheel library was designed by @Spikeysanju
## Contribute
If you want to contribute to this app, you're always welcome!
See [Contributing Guidelines](https://github.com/sameersyd/FortuneWheel/blob/master/CONTRIBUTION.md).
## Donation
If this project helped you reduce time to develop, you can buy me a cup of coffee :)
## Author
Sameer Nawaz, [email protected]
## License
```
Apache 2.0 LicenseCopyright 2021 Sameer Nawaz
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.```