amratab / flexiblesteppedprogressbar Goto Github PK
View Code? Open in Web Editor NEWFlexible Stepped Progress Bar for IOS
License: Other
Flexible Stepped Progress Bar for IOS
License: Other
I am doing live language change to my app but I cant find any way to reload progress bar texts to update texts
hi Amrata,
i was wondering is there a way to fill all states till the last one (currently fill all before current Index)
thanks in advance
I want to make it same color of selected to previous same and next all should be same.
For example: I have 4 progress and if i am at second index, than first and second label text color want same and other text color want different.
second example : If i am at 3rd index, so first/second/third index color want same and forth index color want different. if i will click on previous from 3rd index , means now i am at second, so first/second color want same other want different.
Let me know how to achieve this ?
Please refer attached screenshot.
Hi, for first, good job !
I just see that didSelectItemAtIndex()
delegate method is not fired after setting current index, just need to call in setter
FlexibleSteppedProgressBar.swift
/// The current selected index
open var currentIndex: Int = 0 {
willSet(newValue){
if let delegate = self.delegate {
delegate.progressBar?(self, willSelectItemAtIndex: newValue)
}
}
didSet {
// animationRendering = true
self.setNeedsDisplay()
if let delegate = self.delegate {
delegate.progressBar?(self, didSelectItemAtIndex: currentIndex)
}
}
}
I set the text to "Order\ndelivered" with a "\n" newline in between. but it only shows "Order" not "delivered" on the second line. Can you support that??
I can't seem to figure out why the label text is too large and overflowing into the next item. Any ideas?
var progressBar: FlexibleSteppedProgressBar!
var progressBarWithoutLastState: FlexibleSteppedProgressBar!
var progressBarWithDifferentDimensions: FlexibleSteppedProgressBar!
var backgroundColors = UIColor(red: 112.0 / 255.0, green: 160.0 / 255.0, blue: 71.0 / 255.0, alpha: 1.0)
var progressColor = UIColor(red: 112.0 / 255.0, green: 160.0 / 255.0, blue: 71.0 / 255.0, alpha: 1.0)
var textColorHere = UIColor(red: 153.0 / 255.0, green: 153.0 / 255.0, blue: 153.0 / 255.0, alpha: 1.0)
var maxIndex = -1
override func setSelected(_ selected: Bool, animated: Bool){
super.setSelected(selected, animated: animated)
}
func setupProgressBar(selected: Int) {
progressBar = FlexibleSteppedProgressBar()
progressBar.translatesAutoresizingMaskIntoConstraints = false
for view in self.subviews {
if let progress = view as? FlexibleSteppedProgressBar {
progress.removeFromSuperview()
}
}
self.addSubview(progressBar)
// iOS9+ auto layout code
let horizontalConstraint = progressBar.centerXAnchor.constraint(equalTo: self.centerXAnchor)
let verticalConstraint = progressBar.topAnchor.constraint(
equalTo: self.topAnchor,
constant: 80
)
let widthConstraint = progressBar.widthAnchor.constraint(equalToConstant: SCREEN_WIDTH - 36)
let heightConstraint = progressBar.heightAnchor.constraint(equalToConstant: CGFloat(64))
NSLayoutConstraint.activate([horizontalConstraint, verticalConstraint, widthConstraint, heightConstraint])
// Customise the progress bar here
progressBar.numberOfPoints = 6
progressBar.lineHeight = 2
progressBar.radius = 5
progressBar.progressRadius = 6
progressBar.progressLineHeight = 2
progressBar.delegate = self
progressBar.completedTillIndex = selected
progressBar.useLastState = true
progressBar.lastStateCenterColor = progressColor
progressBar.selectedBackgoundColor = progressColor
progressBar.selectedOuterCircleStrokeColor = progressColor
progressBar.lastStateOuterCircleStrokeColor = progressColor
progressBar.currentSelectedCenterColor = progressColor
progressBar.currentSelectedTextColor = progressColor
progressBar.currentIndex = 0
}
func progressBar(_ progressBar: FlexibleSteppedProgressBar,
didSelectItemAtIndex index: Int) {
progressBar.currentIndex = index
if index > maxIndex {
maxIndex = index
progressBar.completedTillIndex = maxIndex
}
}
func progressBar(_ progressBar: FlexibleSteppedProgressBar,
canSelectItemAtIndex index: Int) -> Bool {
return false
}
func progressBar(_ progressBar: FlexibleSteppedProgressBar,
textAtIndex index: Int, position: FlexibleSteppedProgressBarTextLocation) -> String {
if progressBar == self.progressBar || progressBar == self.progressBarWithoutLastState {
if position == FlexibleSteppedProgressBarTextLocation.top {
switch index {
case 0: return "Quote Pending"
case 1: return "Quote Approved"
case 2: return " Route "
case 3: return "Getting Swerviced"
case 4: return "Swervice Complete"
case 5: return "Delivery Complete"
default: return "Nothing"
}
}
}
return ""
}
How to allow the user click ProggresBar only in backward direction?
Thanks
How can I make the fill color a gradient instead of a solid color?
How can we change the selected index manually ?
I already done pod install but when I try to import FlexibleSteppedProgressBar it gives me error Could not build Objective-c Module 'FlexibleSteppedProgressBar'.
Hi. when I use currentIndex
, it's going to next step but not animated. How can I go to next step programmatically and animated?
Is it possible to set a font for the indices only? I don't set a font at all and get this Warning ->
CoreText performance note: Client called CTFontCreateWithName() using name ".SFUI-Semibold" and got font with PostScript name "TimesNewRomanPSMT". For best performance, only use PostScript names when calling this API.
How can I programatically select the particular index?
Hi,
I created a progress bar with 4 points (progressBar.numberOfPoints = 4
), but later I want to change this existing progress bar to 1 point (progressBar.numberOfPoints = 1
).
The problem is, when I try to change to number of points from 4 to 1, the points disappear, but their texts remain. Following screenshots:
After progressBar.numberOfPoints = 1
, with 1 point:
This is the code in my delegate:
func progressBar(_ progressBar: FlexibleSteppedProgressBar, textAtIndex index: Int,
position: FlexibleSteppedProgressBarTextLocation) -> String {
if position == FlexibleSteppedProgressBarTextLocation.bottom {
switch index {
case 0: return "BOOKED"
case 1: return "ON THE WAY"
case 2: return "SERVICING"
case 3: return "COMPLETED"
default: return "NONE"
}
}
return ""
}
How can I make the text under the points disappear as well when I go from 4 to 1 points?
How can I inform progressbar that my data has updated ? I need a method like reloadData() in tableviews.
Hi
I have an app which support 2 language (arabic, English)
LTR & RTL
so in arabic I need it start form Right to left side
I tried to perform "transform" but it Mirrors the whole view with all its content and I can't control the labels because its text layers , could you provide me with a solution
thanks a lot for this
Just wondering if this library supports arbitrary segmetn lengths? for example i want from segment 1 (point 0 to point 1) to be 100 px, but i want the second segment (point 1 to point 2) to be 400 px. I guess I could just use 2 separate instances now that im thinking about it.
Is there a way to set an image inside of the steps when they have been selected?
possibly even by using a nsattributedstring?
which branch support Swift4.2?
And I have written below code:
func setupProgressBarWithDifferentDimensions() {
progressBarWithDifferentDimensions = FlexibleSteppedProgressBar()
progressBarWithDifferentDimensions.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(progressBarWithDifferentDimensions)
// iOS9+ auto layout code
let horizontalConstraint = progressBarWithDifferentDimensions.centerXAnchor.constraint(equalTo: self.view.centerXAnchor)
let verticalConstraint = progressBarWithDifferentDimensions.topAnchor.constraint(
equalTo: view.topAnchor,
constant: 450
)
let widthConstraint = progressBarWithDifferentDimensions.widthAnchor.constraint(equalToConstant: 320)
let heightConstraint = progressBarWithDifferentDimensions.heightAnchor.constraint(equalToConstant: 25)
NSLayoutConstraint.activate([horizontalConstraint, verticalConstraint, widthConstraint, heightConstraint])
progressBarWithDifferentDimensions.numberOfPoints = 5
progressBarWithDifferentDimensions.lineHeight = 5
progressBarWithDifferentDimensions.progressLineHeight = 6
progressBarWithDifferentDimensions.radius = 16
progressBarWithDifferentDimensions.progressRadius = 16
progressBarWithDifferentDimensions.delegate = self
progressBarWithDifferentDimensions.selectedBackgoundColor = progressColor
progressBarWithDifferentDimensions.backgroundShapeColor = UIColor.lightGray
// progressBarWithDifferentDimensions.centerLayerDarkBackgroundTextColor = UIColor.green
// progressBarWithDifferentDimensions.centerLayerTextFont = UIFont.systemFont(ofSize: 17)
progressBarWithDifferentDimensions.selectedOuterCircleLineWidth = 0.0
progressBarWithDifferentDimensions.completedTillIndex = 2
progressBarWithDifferentDimensions.currentIndex = 2
progressBarWithDifferentDimensions.stepTextColor = UIColor.yellow
progressBarWithDifferentDimensions.currentSelectedTextColor = UIColor.white
progressBarWithDifferentDimensions.centerLayerTextColor = UIColor.gray
}
When I select an index by pressing on the element the line will move but all selected item stuff (like currentSelectedCenterColor) stay on the first index. Only setting index programmatically works but it causes "willSelectItemAtIndex" to trigger so I cannot use it in "willSelectItemAtIndex"
hey, cool stuff.
Is it possible to add RTL support?
Does the control support a vertical position ?
let attString = NSAttributedString(string: self.string as! String, attributes: attributes as! [String : Any]?)
This line is present in file. FSPBTextLayerExtension.swift
I need to show selected outer circle but After I set useLastState to false. It's disappear.
Is this a bug or your propose?
How can I fix it?
thx
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.