SimpleRoulette
SimpleRoulette helps you to create customizable Roulette, with SwiftUI. (Compatible with both MacOS and iOS.)
Demo
Because of GiF, demo lags
iOS | MacOS |
---|---|
![]() |
![]() |
Install
Swift Package Manager
Create Package.swift
and add dependency like the following.
dependencies: [
.package(url: "https://github.com/fummicc1/SimpleRoulette.git", from: "1.1.0")
// or
.package(url: "https://github.com/fummicc1/SimpleRoulette.git", branch: "main")
]
Cocoapods
Create Podfile
and add dependency like the following.
pod 'SimpleRoulette', '~> 1.0'
Carthage
Create Cartfile
and add dependency like the following.
github "fummicc1/SimpleRoulette"
Usage
RouletteView
RouletteView
confirms to View
, so you can use it like the follwing.
struct ContentView: View {
@ObservedObject var model: RouletteModel
var body: some View {
VStack {
RouletteView(
model: model
)
}.onAppear { model.start() }
}
}
// Call ContentView
ContentView(
model: RouletteModel(
PartData(
index: 0,
content: .label("Swift"),
area: .flex(3),
fillColor: Color.red
),
PartData(
index: 1,
content: .label("Kotlin"),
area: .flex(1),
fillColor: Color.purple
),
PartData(
index: 2,
content: .label("JavaScript"),
area: .flex(2),
fillColor: Color.yellow
),
PartData(
index: 3,
content: .label("Dart"),
area: .flex(1),
fillColor: Color.green
),
PartData(
index: 4,
content: .label("Python"),
area: .flex(2),
fillColor: Color.blue
),
PartData(
index: 5,
content: .label("C++"),
area: .degree(60),
fillColor: Color.orange
),
)
)
RouletteModel
RouletteModel is ObservableObject
. You can observe the notification when roulette has stopped and what has been chosen via onDecide
Publisher.
Usage
RouletteModel.start
function immediately start roulette. By default, roulette will set when-to-stop roulette automatically whenever roulette has started.
Documentation
documentation is under construction.
Contributing
Pull requests, bug reports and feature requests are welcome