Git Product home page Git Product logo

circularprogress's Introduction

CircularProgressbar Titanium Appcelerator Titanium

Alloy Widget for creating a circular progressbar.

Quick Start

Installation gitTio

Download the latest distribution ZIP-file and consult the Titanium Documentation on how install it, or simply use the gitTio CLI:

$ gittio install de.manumaticx.circularprogress

Usage

create in xml

<Alloy>
	<Window class="container">
		<Widget src="de.manumaticx.circularprogress" id="progress" />
	</Window>
</Alloy>

style in tss

".container": {
	backgroundColor:"#fff"
},
"#progress" : {
	margin:4,
	backgroundColor:'#fff',
	progressColor:'#33b5e5',
	progressBackgroundColor:'#333',
	progressWidth: 5,
	showText: true,
	color: '#33b5e5',
	font: {
		fontSize: 26,
		fontFamily: 'Roboto Condensed'
	}
}

update in controller

// either: step-by-step update with setValue
function fakeProgress(){
    var val = 0;
    var pInterval = setInterval(function(){
        $.progress.setValue(++val);
        if (val >= 100) clearInterval(pInterval);
    }, 30);
}

// this is how you customize the value text
$.progress.formatValue = function(val){ return (val / 100 * 360) + 'ยฐ'};

// or: to specific value at once with animation (does not work on iOS)
$.progress.animate({
	value: 75,
	duration: 500
});

API

Properties

  • progressColor (String) - the color of the progress layer (default: "#000")
  • progressBackgroundColor (String) - the color of the outstanding part of progress (default: "#666" ๐Ÿ˜ˆ)
  • progressBackgroundGradient (Gradient) - the progressBackground as gradient
  • progressWidth (Number) - the width of the progress (if not defined, progress becomes a cake)
  • formatValue(Function) - formats the value displayed in the center
  • showText (Boolean) - whether the current progress value should be displayed (default: false)
  • margin (Number) - adds margin to progress (visible if backgroundColor != progressBackgroundColor)

Methods

  • animate(args, callback) - animate the progress to a given value
    • args (Object) - the value args.value and the duration args.duration
    • callback (Function) - gets called when the animation is finished
  • getValue() - Returns the current value
  • setValue(value) - Sets the current value
    • value (Number) - the new value
  • getText() - Returns the text
  • setText(text) - Sets the text
    • text (String) - the new text value
  • hide() - turns off the visibility
  • show() - turns on the visibility

Styles

You can add you own styles with the following classes:

  • .circularprogress_view (Ti.UI.View)
  • .circularprogress_label (Ti.UI.Label)

Credits

License

The MIT License (MIT)

Copyright (c) 2014 Manuel Lehner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

circularprogress's People

Contributors

boarnoah avatar iotashan avatar jei avatar killroyboy avatar m1ga avatar manumaticx avatar topener avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circularprogress's Issues

Android implementation, the progress always fills 100%

I tried following the sample use case scenario, it works on ios but always fills 100% on Android.
Only difference from the sample code is my index.js looks like this:

$.progress.animate({
    value: 75,
    duration: 500
});

Ti.API.info("FINISHED SHOWING indicator");
$.index.open();

Also I didn't notice it animate live (maybe it just happened too fast, but possibly related issues?)

Error on iOS with v0.6.0

When building for iOS I'm getting this:

[ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] Reason:
[ERROR] -[NSNull paintContext:bounds:]: unrecognized selector sent to instance 0x107862180
[ERROR] Stack trace:
[ERROR] 0 CoreFoundation 0x00000001075a5af3 __exceptionPreprocess + 147
[ERROR] 1 libobjc.A.dylib 0x0000000106b3a141 objc_exception_throw + 48
[ERROR] 2 CoreFoundation 0x0000000107615134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
[ERROR] 3 CoreFoundation 0x000000010752c840 forwarding + 1024
[ERROR] 4 CoreFoundation 0x000000010752c3b8 CF_forwarding_prep_0 + 120
[ERROR] 5 App 0x00000001009e8547 -[TiGradientLayer drawInContext:] + 183
[ERROR] 6 QuartzCore 0x0000000105685ae5 CABackingStoreUpdate
+ 2505
[ERROR] 7 QuartzCore 0x000000010576f0fa ___ZN2CA5Layer8display_Ev_block_invoke + 61
[ERROR] 8 QuartzCore 0x000000010576edf3 _ZN2CA5Layer8display_Ev + 1633
[ERROR] 9 QuartzCore 0x000000010576331d _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 315
[ERROR] 10 QuartzCore 0x00000001057633ab _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 35
[ERROR] 11 QuartzCore 0x00000001056f2e92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
[ERROR] 12 QuartzCore 0x000000010571f130 _ZN2CA11Transaction6commitEv + 468
[ERROR] 13 QuartzCore 0x000000010571fb37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
[ERROR] 14 CoreFoundation 0x000000010754b717 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
[ERROR] 15 CoreFoundation 0x000000010754b687 __CFRunLoopDoObservers + 391
[ERROR] 16 CoreFoundation 0x0000000107530720 __CFRunLoopRun + 1200
[ERROR] 17 CoreFoundation 0x0000000107530016 CFRunLoopRunSpecific + 406
[ERROR] 18 GraphicsServices 0x0000000108eb5a24 GSEventRunModal + 62
[ERROR] 19 UIKit 0x00000001025e90d4 UIApplicationMain + 159
.....

Tested on version 0.6.0 and it's perfect. I think could be related to the gradient changes introduced in latest version and maybe related to https://jira.appcelerator.org/browse/TIMOB-14571?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

Thanks,
Yanko

How to get the purple behaviour of your Gif

I liked the behaviors of the purple colored circular progress in your gif.
I've played around with the backgroundColor, progressColor, progressBackgroundColor, and progressWidth with no prevail.

I should note, the background of the circular progress is transparent. It will be shown over an image.

Anyway I can check the code for that specific progress bar? (I'm sure I can manage it by modifying the widget, however I'm curious if there is a cleaner way). Thanks for this Widget by the way!

Animation broken

Hello!
Thanks for all the work with the module, it looks really good.

I'm having some trouble with animation though, it seems to be lagging.
I also need the ability to change colors after the widget is loaded, so it would be nice to export methods for those - I'm happy to contribute with that, should I send a PR?

Gif for animation bug: http://www.gfycat.com/WeirdBestFairyfly
Titanium SDK 5.0.2.GA iOS 8.2

Android Blurred round corner

Hi Can you please help me to fix this issue ? the Round is not perfect. its blurred and not looking good.
this is my setting.
"#progress": {
right: 0,
width: 30,
height: 30,
margin: 0,
backgroundColor:'#fff',
progressColor:'#F1F0D7',
progressBackgroundColor:'#4CA8A1',
progressWidth: 0,
color: '#33b5e5',
font: {
// fontSize: 26,
// fontFamily: 'Roboto Condensed'
}
}

screen shot 2016-06-23 at 6 35 27 am

Progress not rounded

Hey man! I'm developing an alloy app so I decided to give your widget a shot. I got it all working, but the progress seems to not really be circular like my original code. I went through your widget.js briefly and didn't notice anything specifically causing it. Do you have any ideas?

I posted a screenshot below. Just a side note, I increased the progressWidth significantly to magnify the issue. Could it be a problem with my TSS?

'#progress' : {
    width:30,
    height:30,
    bottom:13,
  left:3,
  margin:2,
  backgroundColor:'#fff',
  progressColor:'#4ba818',
  progressBackgroundColor:'#333',
  progressWidth: 10,
  showText: true,
  color: '#333',
    font: {
        fontSize:10,
        fontFamily:Alloy.Globals.fontFamily
  }
}

screen shot 2014-12-11 at 10 21 06 am

Android support

Needs a workaround or fix to rotate the rotation layer around the anchor point

Enhancement request - callback in animate function and ability to change text

Great work, guys! Have a few enhancement requests that should be relatively easy to incorporate:
a) Add callback to the animate function: This is useful to perform certain task AFTER the animation completes, say, to hide the progress indicator, or to change the text on the indicator after the animation completes (which brings me to the next enhancement request).
Here's my attempt to add the above enhancement:
function animate(_args,callback){ //Changes by Parijat Sahai - added callback
...
callback && animation.addEventListener("complete",callback); //Changes by Parijat Sahai - added callback
}

b) Add functions to get and set text of the label that shows in the middle of the circular progress bar. There are situations where the text has to be changed (from one icon to another for example) after the progress goes to 100, or if there is an error in the middle of the progress, or if the user aborts an operation. That said, the current code that sets the text on the label in the widget is too specific - it sets the text to the value of the progress, which isn't always desirable.
Here's my attempt at the above enhancement:
function setText(_text){ $.label.text = _text; }
function getText(){ return $.label.text; }
exports.setText = setText;//Parijat Sahai edits
exports.getText = getText;//Parijat Sahai edits

commonJS

Do we have the chance to get this as a commonJS module for using without alloy?

Ability to handle "click" (tap) events around the circle and update progress?

It would be awesome if this widget could listen for click/tap events around the circle and update the progress value accordingly.

For example, if I tap at any point on the arc of the circle, it would update to that value.

Or event better, publish a "touch" event that includes event args with the calculated value.

How to add "percentage sign"?

Hi, thanks for your library, im trying to add '%' sign to the label, but i haven't been able to do it.
My code:

$.progress.animate({
    value: 78,
    duration: 500,
    formatValue: function(v){return v + '%';},
    showText: true
});

Thanks in advance.

Dumb question.. how can I hide and show and update on upload ?

Hi
I want to hide my progress and show it when I'm uploading something... how can I do that?

I try $.progress.hide() but it's not a exposed method ):

Also I'm facing a little problem when onsendstream function to update the progress...

onsendstream:function(evt){
    Ti.API.info('ONSENDSTREAM - PROGRESS: ' + evt.progress.toFixed(3));

    if(Math.round(evt.progress * 100) <= 100) {
        $.progress.setValue(evt.progress.toFixed(3) * 100 );
    }
}

I'm getting the right progress but sometimes it get weird showing ALOT of numbers then it back to the right %( 10.3% ... 82.5% )

this is my formatValue -> $.progress.formatValue = function(val){ return (val) + '%'};

Thanks

CommonJS module

Hi manumaticx,
is there any chance to convert this Alloy module to classic CommonJS? Pastie.org is down and I can't get to that code provided in that other issue.
Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.