Git Product home page Git Product logo

fortunewheel's Introduction

CI Status Version License Platform

GitHub Cards Preview

Fortune Wheel

Fortune spinning wheel ๐ŸŽก library built using SwiftUI, supports dynamic content.


Preview - Spin Wheel โš™๏ธ

gif


CocoaPods Installation

FortuneWheel is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'FortuneWheel'

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/sameersyd/FortuneWheel.git", .upToNextMajor(from: "0.1.5"))
]

Sample Code ๐ŸŒŸ

Import Fortune Wheel in your file.

import FortuneWheel

Create a FortuneWheelModel and pass it to the view.

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.


Donation

If this project helped you reduce time to develop, you can buy me a cup of coffee :)

Buy Me A Coffee


Author

Sameer Nawaz, [email protected]


License

    Apache 2.0 License


    Copyright 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 at

       http://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.

fortunewheel's People

Contributors

rosendev avatar sameersyd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fortunewheel's Issues

End wheel on predefined slice

is it possible to predefine which slice the wheel will stop at? For real-world implementations, we would want to get a predefined prize from an API and show it on the fortune wheel.

Cocoapods.org page redirecting to GitHub

You seem to have the same problem as I do, my library PermissionsSwiftUI is pushed to Cocoapod's server, but the page on their website is redirecting to my GitHub repo page instead of a parsed README.md on Cocoapods.org. Any clues?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.