diff --git a/FortuneWheel.podspec b/FortuneWheel.podspec index fcbe886..6a773f9 100644 --- a/FortuneWheel.podspec +++ b/FortuneWheel.podspec @@ -8,8 +8,8 @@ Pod::Spec.new do |s| s.name = 'FortuneWheel' - s.version = '0.1.1' - s.summary = 'A FortuneWheel library for iOS using SwiftUI' + s.version = '0.1.2' + s.summary = 'Fortune spinning wheel library built using SwiftUI, supports dynamic content' # This description is used to generate tags and improve search results. # * Think: What does it do? Why did you write it? What is the focus? @@ -18,11 +18,11 @@ Pod::Spec.new do |s| # * Finally, don't worry about the indent, CocoaPods strips it! s.description = <<-DESC -'A FortuneWheel library for iOS using SwiftUI' +'Fortune spinning wheel library built using SwiftUI, supports dynamic content' DESC s.homepage = 'https://github.com/sameersyd/FortuneWheel' - s.license = { :type => 'MIT', :file => 'LICENSE' } + s.license = { :type => 'Apache License 2.0', :file => 'LICENSE' } s.author = { 'sameersyd' => 'sameer.nwaz@gmail.com' } s.source = { :git => 'https://github.com/sameersyd/FortuneWheel.git', :tag => s.version.to_s } s.social_media_url = 'https://www.linkedin.com/in/sameer-nawaz-linked/' diff --git a/Source/FortuneWheel.swift b/Source/FortuneWheel.swift index 2542531..31cbe3d 100644 --- a/Source/FortuneWheel.swift +++ b/Source/FortuneWheel.swift @@ -14,7 +14,7 @@ public struct FortuneWheel: View { var colors: [Color] = Color.spin_wheel_color, pointerColor: Color = Color(hex: "DA4533") @StateObject var viewModel: FortuneWheelViewModel - public init(titles: [String], size: CGFloat, onSpinEnd: ((Int) -> ())?, colors: [Color]? = nil, pointerColor: Color? = nil, strokeWidth: CGFloat = 15, strokeColor: Color? = nil, animDuration: Double = Double(6), timeCurveAnimation: Animation? = nil) { + public init(titles: [String], size: CGFloat, onSpinEnd: ((Int) -> ())?, colors: [Color]? = nil, pointerColor: Color? = nil, strokeWidth: CGFloat = 15, strokeColor: Color? = nil, animDuration: Double = Double(6), animation: Animation? = nil) { self.titles = titles self.size = size @@ -24,8 +24,8 @@ public struct FortuneWheel: View { if let pointerColor = pointerColor { self.pointerColor = pointerColor } if let strokeColor = strokeColor { self.strokeColor = strokeColor } - let animation = Animation.timingCurve(0.51, 0.97, 0.56, 0.99, duration: animDuration) - _viewModel = StateObject(wrappedValue: FortuneWheelViewModel(titles: titles, animDuration: animDuration, timeCurveAnimation: timeCurveAnimation ?? animation, onSpinEnd: onSpinEnd)) + let timeCurveAnimation = Animation.timingCurve(0.51, 0.97, 0.56, 0.99, duration: animDuration) + _viewModel = StateObject(wrappedValue: FortuneWheelViewModel(titles: titles, animDuration: animDuration, animation: animation ?? timeCurveAnimation, onSpinEnd: onSpinEnd)) } public var body: some View { diff --git a/Source/FortuneWheelViewModel.swift b/Source/FortuneWheelViewModel.swift index dff1d55..e54178f 100644 --- a/Source/FortuneWheelViewModel.swift +++ b/Source/FortuneWheelViewModel.swift @@ -13,21 +13,21 @@ class FortuneWheelViewModel: ObservableObject { @Published var degree = 0.0 private let animDuration: Double - private var timeCurveAnimation: Animation + private var animation: Animation private var pendingRequestWorkItem: DispatchWorkItem? private var onSpinEnd: ((Int) -> ())? - init(titles: [String], animDuration: Double, timeCurveAnimation: Animation, onSpinEnd: ((Int) -> ())?) { + init(titles: [String], animDuration: Double, animation: Animation, onSpinEnd: ((Int) -> ())?) { self.titles = titles self.animDuration = animDuration - self.timeCurveAnimation = timeCurveAnimation + self.animation = animation self.onSpinEnd = onSpinEnd } func spinWheel() { let d = Double.random(in: 720...7200) - withAnimation(timeCurveAnimation) { self.degree += d } + withAnimation(animation) { self.degree += d } // Cancel the currently pending item pendingRequestWorkItem?.cancel() // Wrap our request in a work item diff --git a/Source/SpinWheel/SpinWheelView.swift b/Source/SpinWheel/SpinWheelView.swift index 53fa684..6628008 100644 --- a/Source/SpinWheel/SpinWheelView.swift +++ b/Source/SpinWheel/SpinWheelView.swift @@ -60,7 +60,7 @@ struct SpinWheelView: View { ForEach(0..