룰렛 뷰 추가
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// RouletteViewDialog.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/12/07.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct RouletteViewDialog: View {
|
||||
@Binding var isShowing: Bool
|
||||
|
||||
let options: [String]
|
||||
let selectedOption: String
|
||||
let complete: () -> Void
|
||||
|
||||
var body: some View {
|
||||
let model = FortuneWheelModel(
|
||||
titles: options,
|
||||
size: 320,
|
||||
onSpinEnd: onSpinEnd,
|
||||
getWheelItemIndex: getWheelItemIndex
|
||||
)
|
||||
ZStack {
|
||||
FortuneWheel(model: model)
|
||||
}
|
||||
}
|
||||
|
||||
private func onSpinEnd(index: Int) {
|
||||
complete()
|
||||
isShowing = false
|
||||
}
|
||||
|
||||
private func getWheelItemIndex() -> Int {
|
||||
return options.firstIndex(of: selectedOption) ?? 0
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user