룰렛 뷰 추가

This commit is contained in:
Yu Sung
2023-12-07 08:43:18 +09:00
parent 0af16ac000
commit d52f0d1176
8 changed files with 329 additions and 11 deletions

View File

@@ -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
}
}