sh-khashimov / swiftfortunewheel Goto Github PK
View Code? Open in Web Editor NEWThe ultimate spinning wheel view that supports dynamic content and rich customization.
License: MIT License
The ultimate spinning wheel view that supports dynamic content and rich customization.
License: MIT License
I'm curious: Is it easily possible to make the spinImage rotate with the whole wheel?
Thanks.
Hello, Can I use 'SwiftFortuneWheel' in my objective-C project, Thanks for your reply
I've been informed that some users are experiencing a crash in the app when the user taps on the "spin" button. Strangely, I've attempted to reproduce the issue on my device, but it doesn't seem to occur. Crash Log I have attached with this.
Crash log Firebase.txt
I would love the option to make the background of a slice come from an image rather than just setting it to a color.
Hi, is it possible to set image (dynamic size --> fit to slice segment frame) and text in the center of the slice for any no. of slices in the wheel? I actually tried and get the following output but not able to set image and text in the center but with a vertical offset, we can not get desired output. Any help would be appreciated. can you provide some guidance?
Navigating to a view controller that hosts a SwiftFortuneWheel
stops any external audio that might have been being played within Music application.
Commenting the init()
of AudioPlayerManager
seems to fix this problem. But this might have other consequences somewhere else.
Note: I also need the collision sound effect to be enabled.
Please provide the code to let me know how I can get the index or prize at which rotation has stopped?
When using SwiftFortuneWheel without storyboard, startAnimating(finishIndex) vanishes with the wheel. I've did a little research and found out that slices are not assigned on to the SwiftFortuneWheel class, only to WheelView. When startAnimating(finishIndex) tries to calculate the sliceDegree, it tries to divide by zero, hence the bug.
I've fixed this in my code by reassigning to SwiftFortuneWheel slices variable
self.fortuneWheel = SwiftFortuneWheel(frame: frame, slices: mappedSlices, configuration: configuration)
self.fortuneWheel.slices = mappedSlices
But I think this can be easily be solved by assigning it at the init function of the SwiftFortuneWheel
Error on console - Fail to render and update auto layout status for viewController(Tsg-HD-LBo): Failed to launch designable agent because tool was shutting down. check the console for a more detailed description and please file a bug report at feedbackassistant.com
on creating build the archive of app. work fine in debug mode. Please check this issue
Process: IBDesignablesAgent-iOS [49639]
Path: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays/IBDesignablesAgent-iOS
Identifier: IBDesignablesAgent-iOS
Version: 12.3 (17703)
Code Type: X86-64 (Native)
Parent Process: launchd_sim [28516]
Responsible: SimulatorTrampoline [455]
User ID: 501
Date/Time: 2021-05-25 14:56:38.077 +0530
OS Version: macOS 11.1 (20C69)
Report Version: 12
Anonymous UUID: BFE8C29E-ACEE-3C30-748C-C5DF75B4B9C5
Time Awake Since Boot: 10000 seconds
System Integrity Protection: enabled
Crashed Thread: 0
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [49639]
Application Specific Information:
CoreSimulator 757.5 - Device: iPhone 12 mini (1DD1CAF0-0420-4DAD-8DD0-5CDCE573BC9C) - Runtime: iOS 14.3 (18C61) - DeviceType: iPhone 12 mini
SwiftFortuneWheel/SwiftFortuneWheel.swift: 17: 14: Fatal error: Use of unimplemented initializer 'init(frame:)' for class 'SwiftFortuneWheel.SwiftFortuneWheel'
Is there currently any documentation on how to get the wheel implementation wrapped in an UIViewControllerRepresentable such that the package can be used in SwiftUI environments? I have tried to create a bridge myself and initializing a static wheel succeeded but did not manage to bridge the controls of the wheel. Thanks in advance!
how to get the selected value after the wheel is stopped.
First, thank you so much for this project. I have been waiting for something like this for years!
Could you tell me what the best way is to adjust the initial speed of the wheel when it is in the indefinite spin mode?
Hello, @sh-khashimov.
I have an issue that needs you to help with, can you spare time to fix it. Thank XD...
When finished spinning, exit and enter to App on onetime. The result will spin back to default.
I don't understand why func startRotationAnimation(finishIndex: Int, continuousRotationTime: Int, continuousRotationSpeed: CGFloat = 4, _ completion: ((Bool) -> Void)?)
is returning me always false
and why the bool in completion it's returned before the wheel stops.
Hi everyone, before working on a simple fix, just just wanted to check whether everyone is encountering this issue with Xcode 14?
Lines 128-131 of SwiftFortuneWheel.swift
#if os(iOS)
@available(iOS 10.0, iOSApplicationExtension 10.0, *)
private(set) lazy var impactFeedbackgenerator = UIImpactFeedbackGenerator(style: .light)
#endif
Error: Stored properties cannot be marked potentially unavailable with '@available'
Other librairies have encountered the same issue, the fix is not too difficult.
Could someone confirm they have the same issue? Thanks.
Dear @sh-khashimov thanks for creating this library, its very useful.
I'm facing two issues right now can you please let me know how to solve them.
the first thing is that i need to text and position like that as image i did it with some hardcoding values so is there any better solution for that as you can see code its not look good.
second issue is that im getting correct value as you mention in other solve issue the value after rotation, and pin is also correcting a correct value but now i have to update the color for the winning and losing slices for this i try to do add update slice function and checking condition, the issue is that color is updating for all but now position is shifting from the pin. like here the pin should point "Graphic" can you let me know what im doing wrong here.
here is the code which im using right now:
`import UIKit
import SwiftFortuneWheel
class VariousWheelPodiumViewController: UIViewController {
var selectedIndex = -1
@IBOutlet weak var wheelControl: SwiftFortuneWheel!
var prizes = [(id:0,name: "MONEYMONEY", color: #colorLiteral(red: 0.9607843137, green: 0.768627451, blue: 0.568627451, alpha: 1),winningColor: #colorLiteral(red: 0.9333333333, green: 0.6078431373, blue: 0.2705882353, alpha: 1),losingColor: #colorLiteral(red: 0.737254902, green: 0.2901960784, blue: 0.6156862745, alpha: 1), textColor: #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)),
(id:1,name: "GRAPHIC", color: #colorLiteral(red: 0.9843137255, green: 0.9098039216, blue: 0.8274509804, alpha: 1),winningColor: #colorLiteral(red: 0.9607843137, green: 0.768627451, blue: 0.568627451, alpha: 1), losingColor: #colorLiteral(red: 0.737254902, green: 0.2901960784, blue: 0.6156862745, alpha: 1),textColor: #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)),
(id:2,name: "HOME", color: #colorLiteral(red: 0.9607843137, green: 0.768627451, blue: 0.568627451, alpha: 1),winningColor: #colorLiteral(red: 0.9333333333, green: 0.6078431373, blue: 0.2705882353, alpha: 1),losingColor: #colorLiteral(red: 0.737254902, green: 0.2901960784, blue: 0.6156862745, alpha: 1), textColor: #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)),
(id:3,name: "IDEA", color: #colorLiteral(red: 0.9843137255, green: 0.9098039216, blue: 0.8274509804, alpha: 1), winningColor: #colorLiteral(red: 0.9333333333, green: 0.6078431373, blue: 0.2705882353, alpha: 1), losingColor: #colorLiteral(red: 0.737254902, green: 0.2901960784, blue: 0.6156862745, alpha: 1),textColor: #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)),
(id:4,name: "MANAGMENT", color: #colorLiteral(red: 0.9607843137, green: 0.768627451, blue: 0.568627451, alpha: 1),winningColor: #colorLiteral(red: 0.9333333333, green: 0.6078431373, blue: 0.2705882353, alpha: 1), losingColor: #colorLiteral(red: 0.737254902, green: 0.2901960784, blue: 0.6156862745, alpha: 1),textColor: #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)),
(id:5,name: "SEARCH", color: #colorLiteral(red: 0.9843137255, green: 0.9098039216, blue: 0.8274509804, alpha: 1),winningColor: #colorLiteral(red: 0.9333333333, green: 0.6078431373, blue: 0.2705882353, alpha: 1), losingColor: #colorLiteral(red: 0.737254902, green: 0.2901960784, blue: 0.6156862745, alpha: 1),textColor: #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)),
(id:6,name: "TARGET", color: #colorLiteral(red: 0.9607843137, green: 0.768627451, blue: 0.568627451, alpha: 1),winningColor: #colorLiteral(red: 0.9333333333, green: 0.6078431373, blue: 0.2705882353, alpha: 1), losingColor: #colorLiteral(red: 0.737254902, green: 0.2901960784, blue: 0.6156862745, alpha: 1),textColor: #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)),
(id:7,name: "TIME", color: #colorLiteral(red: 0.9843137255, green: 0.9098039216, blue: 0.8274509804, alpha: 1),winningColor: #colorLiteral(red: 0.9333333333, green: 0.6078431373, blue: 0.2705882353, alpha: 1), losingColor: #colorLiteral(red: 0.737254902, green: 0.2901960784, blue: 0.6156862745, alpha: 1),textColor: #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1))]
var slices = [Slice] ()
var finishIndex: Int {
return Int.random(in: 0..<wheelControl.slices.count)
}
override func viewDidLoad() {
super.viewDidLoad()
wheelControl.configuration = .variousWheelPodiumConfiguration
wheelControl.spinImage = "center"
wheelControl.isSpinEnabled = false
updateSlice()
wheelControl.slices = slices
}
@IBAction func rotateTap(_ sender: Any) {
let finishingIndex = self.finishIndex
print(finishingIndex)
wheelControl.startRotationAnimation(finishIndex: finishingIndex, continuousRotationTime: 1) { (isFinished) in
guard isFinished else { return }
print(self.prizes[finishingIndex])
self.selectedIndex = finishingIndex
self.updateSlice()
self.wheelControl.slices = self.slices
self.wheelControl.rotate(toIndex: finishingIndex)
}
}
func updateSlice(){
slices = []
for (index,prize) in prizes.enumerated() {
print(index,prize.name)
var titleTextPreferences = TextPreferences(textColorType: .customPatternColors(colors: nil, defaultColor: .black), font: .systemFont(ofSize: 10, weight: .bold), verticalOffset: 20)
titleTextPreferences.horizontalOffset = 10
titleTextPreferences.orientation = .vertical
titleTextPreferences.spacing = 0
titleTextPreferences.alignment = .left
var descriptionTextPreferences = TextPreferences(textColorType: .customPatternColors(colors: nil, defaultColor: .red), font: .systemFont(ofSize: 10), verticalOffset:-75)
descriptionTextPreferences.horizontalOffset = 0
descriptionTextPreferences.orientation = .vertical
descriptionTextPreferences.spacing = 0
descriptionTextPreferences.alignment = .left
let content: [Slice.ContentType] = [.text(text: prize.name, preferences: titleTextPreferences),.text(text: prize.name, preferences: descriptionTextPreferences)]
var slice = Slice(contents: content)
if selectedIndex == -1{
slice.backgroundColor = prize.color
}else{
slice.backgroundColor = index == selectedIndex ? prize.winningColor : prize.losingColor
}
slices.append(slice)
}
}
}`
How can we detect taps on the slices with their indexes? Any ideas or suggestions?
This issue is repetible.
It could happen in case if SpinningWheelAnimator.addRotationAnimation() starts before the WheelView.addWheelLayer() has been finished. In this case layerToAnimate property of animationObject is nil, so the action animationObject?.layerToAnimate?.add(transformAnim, forKey:"starRotationAnim") did nothing and there will be no animation.
So that I can bind with result text view
Changing the two examples to other implementations in the lib such as
@Published var wheelConfiguration: SFWConfiguration = .blackCyanColorsConfiguration
to
@Published var wheelConfiguration: SFWConfiguration = .variousWheelPodiumConfiguration
does not seem to work for me. A blank wheel is shown with the blackCyan layout.
How can we get the finished index to be at pin image if it was on top?
any idea?
@sh-khashimov
Hello, @sh-khashimov thanks for your awesome library.
I am using Podium Wheel Layout using variousWheelPodiumConfiguration
- What is the issue I am facing
- What I have tried
var wheelPreferences = SFWConfiguration.WheelPreferences(circlePreferences: circlePreferences,
slicePreferences: slicePreferences,
startPosition: .right)
wheelPreferences.contentMargins = Margins(top: 0, left: 0, right: 0, bottom: 0)
var preferences = TextPreferences(textColorType: textColorType,
font: font,
verticalOffset: 0)
preferences.alignment = .left
preferences.orientation = .vertical
preferences.isCurved = false
preferences.spacing = -1
preferences.numberOfLines = 0
public extension ImagePreferences {
static var variousWheelPodiumImage: ImagePreferences {
let imagePreferences = ImagePreferences(preferredSize: CGSize(width: 50, height: 50), verticalOffset: 0)
return imagePreferences
}
}
- Questions ❓
Issue Reference:
There is a delay when presenting a new ViewController that contains the wheel, specifically when updateSlices() gets called. I tried calling updateSlices() in viewDidAppear and the wheel shows but the slices are not drawn yet. They appear after about 1 second.
Firstly, thanks for this wonderful project.
Up until now, you have implemented it for the image to be set from the Assets.xcassets
folder. I'm in a state where I need to be able to set image from external input (like, downloaded image or composed image with the help of UIGraphicsImageRenderer
).
I think this should be a feature of your project which opens up possibilities for anyone in the future.
I've created #4 and awaiting for your consideration.
The circular image is coming from server
we need to add and rotation and set after certain rotations to particular angle range
how can we achieve that
Hello, Thanks!! for the Awsome project
@sh-khashimov I am using the Podium wheel with images so right now I want to rotate the image which is inside the slice
I have reviewed the ImageDrawing.swift
and also played with
func drawImage(in context: CGContext, image: SFWImage, preferences: ImagePreferences, rotation: CGFloat, index: Int, topOffset: CGFloat, radius: CGFloat, margins: SFWConfiguration.Margins) {}
But no luck could you please help me what the best way to achieve the rotation of the image?
Thanks!
Hi
How can I find the the selected index in wheel so can change or highlight that slice if it have any. please help me out of that.
Thanks & Regard
Deepak
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.