GithubHelp home page GithubHelp logo

johngraham262 / jwgcirclecounter Goto Github PK

View Code? Open in Web Editor NEW
131.0 10.0 29.0 304 KB

A handy timer that counts down in a circular view.

License: MIT License

Objective-C 94.99% Ruby 0.66% C 0.45% Shell 3.90%

jwgcirclecounter's Introduction

JWGCircleCounter Build Status

This control is a simple view that counts down a specified amount and alerts you on completion. You can see this live in Teleportante.

alt tag

Demo

This example uses Cocoapods, please install before running.

Navigate to DemoApp and run pod install in your terminal. Open DemoApp.xcworkspace and run the application.

Installation

Easiest installation is through Cocoapods. Add the following line to your Podfile:

pod `JWGCircleCounter`

and run pod install in your terminal.

Alternatively, you can manually add the files in the JWGCircleCounter directory to your project.

Usage

Start by creating a JWGCircleCounter of your own and add it to your view:

JWGCircleCounter *circleCounter = [[JWGCircleCounter alloc] initWithFrame:CGRectMake(0,0,40,40)];
...
[your_view addSubview:circleCounter];

After initialization, start the counter by:

[circleCounter startWithSeconds:5];

Once it's been started, the counter can be managed with:

[circleCounter stop];
[circleCounter resume];

Customization & counter state

When the frame is set, the circle counter will expand to fit the bounds.

The following properties can be set:

@property (nonatomic, strong) UIColor *circleColor;
@property (nonatomic, strong) UIColor *circleBackgroundColor;
@property (nonatomic, assign) CGFloat circleTimerWidth;

You can inspect the state of a counter through a few readonly properties:

@property (nonatomic, assign, readonly) BOOL didStart;
@property (nonatomic, assign, readonly) BOOL isRunning;
@property (nonatomic, assign, readonly) BOOL didFinish;

Contributing

Please write tests and ensure that existing tests pass too. Open a pull request when you're ready.

Roadmap

  1. Move didStart, isRunning, and didFinish properties to an enum.
  2. Create a single "smart" method that can do start/pause/restart.

Shoutout

This was inspired by pppoe's Circle-Counter-Down. Thank you!

jwgcirclecounter's People

Contributors

johngraham262 avatar justinjiadev avatar rsrbk avatar s424242 avatar sbonami 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jwgcirclecounter's Issues

Reset does not work

@johngraham262

When my app goes to the background i do circleCounter.reset() which stop's the counter however when the app returns to the foreground, the elapsed time is still animated. I expect the behaviour where the circleCounter goes back to 0. How can I fix that?

Reset?

Hi John, very nice work with the circle counter. I'm trying to implement it in an app now. I haven't been able to figure out how to do a 'reset'.

Also, another minor issue I noticed is that the animation isn't as smooth on longer timeframes. It looks great for ~10 secs.

Tim

Set start Time with a DatePicker?

Hi,

is it possible that i can set the "startWithSeconds" with the value of a UIDatePicker in CountDownTimerMode?

Now i can change a uilabel with the datepicker and start a countdown. How is it possible that the circle has the same time that i picked from the datepicker?

Thank you,

blackyE1

Allow time format in Minutes

@johngraham262

Ive been having trouble with this since i dont know objective c.
Can you enable time label to show minutes instead of seconds. it appears the counter.timeLabel.text is a get only property so I can't set my own time format.

Also on that note, i played around with your code and I could get it to show minutes by dividing by 60 (_totalTime - _elapsedTime)/60 however when the countdown happens, it starts from 9.... and goes to 0. Which means numbers 9,8,7,6,5,4,3,2,1,0 appear for 1 minute each and number 10 appears only for a split second. I'd rather 10....1.

Thanks

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.