룰렛 뷰 추가
This commit is contained in:
51
SodaLive/Sources/FortuneWheel/FortuneWheelModel.swift
Normal file
51
SodaLive/Sources/FortuneWheel/FortuneWheelModel.swift
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// FortuneWheelModel.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/12/07.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct FortuneWheelModel {
|
||||
|
||||
let titles: [String]
|
||||
let size: CGFloat
|
||||
let onSpinEnd: ((Int) -> ())?
|
||||
let colors: [Color]
|
||||
let pointerColor: Color
|
||||
let strokeWidth: CGFloat
|
||||
let strokeColor: Color
|
||||
let animDuration: Double
|
||||
let animation: Animation
|
||||
let getWheelItemIndex: (() -> (Int))?
|
||||
|
||||
public init(
|
||||
titles: [String], size: CGFloat, onSpinEnd: ((Int) -> ())?,
|
||||
colors: [Color]? = nil,
|
||||
pointerColor: Color = .red,
|
||||
strokeWidth: CGFloat = 5,
|
||||
strokeColor: Color = .white,
|
||||
animDuration: Double = Double(2),
|
||||
animation: Animation? = nil,
|
||||
getWheelItemIndex: (() -> (Int))? = nil
|
||||
) {
|
||||
self.titles = titles
|
||||
self.size = size
|
||||
self.onSpinEnd = onSpinEnd
|
||||
self.colors = colors ?? [
|
||||
Color(hex: "#F5D55A"),
|
||||
Color(hex: "#E4813B"),
|
||||
Color(hex: "#E6AAC1"),
|
||||
Color(hex: "#8FCEEA"),
|
||||
Color(hex: "#CD5880"),
|
||||
Color(hex: "#C2C85E")
|
||||
]
|
||||
self.pointerColor = pointerColor
|
||||
self.strokeWidth = strokeWidth
|
||||
self.strokeColor = strokeColor
|
||||
self.animDuration = animDuration
|
||||
self.animation = animation ?? Animation.timingCurve(0.51, 0.97, 0.56, 0.99, duration: animDuration)
|
||||
self.getWheelItemIndex = getWheelItemIndex
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user