Giter Club home page Giter Club logo

progressmanager's Introduction

Progress Manager

A manager that receives a UILabel and a UIProgressView and updates their status accordingly to informations set on Progress Info

Ideal for token generation based on time (TOTP)


Basic Usage

You can set the label and progressView you want to update along with the necessary info

let progressInfo = ProgressInfo(text: "228538", startTime: Date(), timeleft: 10.0, maxTime: 10.0)
let progressManager = ProgressManager(progressInfo: progressInfo, label: label, progressView: progressView)
progressManager.start()

Progress Info

ProgressInfo is the model that defines the information necessary for ProgressManager

struct ProgressInfo {
    let text: String
    let startTime: Date
    let timeleft: Double
    let maxTime: Double
}

In this model you define:

  • text is used to update the label
  • startTime works together with timeleft. The timeleft property is the amount of time (in seconds) left to finish the progress view in relation to startTime
  • maxTime is maximum total time (in seconds) of the progress view

NOTE: If timeleft is bigger than maxTime or less than 0, the progress manager won't function properly.

ProgressInfo

Personalizing

You can perfome some personalizations, such as:

  • direction: defines if the bar progress is increasing or decreasing;
  • smoothness: defines how smooth the progress bar will increase or decrease;
  • shouldRestartAutomatically: flag to indicate if the progress bar should restart automatically after is finished (a loop).
progressManager.smoothness = .high
progressManager.direction = .increasing
progressManager.shouldRestartAutomatically = true

IMPORTANT

If shouldRestartAutomatically is set as true, is important that you set the delegate for the manager, otherwise it will NOT work.

progressManager.delegate = self

Then, use the ProgressManagerDelegate protocol method progressInfo(forProgressManager:) to update the new ProgressInfo

func progressInfo(forProgressManager progressManager: ProgressManager) -> ProgressInfo {
    return ProgressInfo(text: "234534", startTime: Date(), timeleft: 9.0, maxTime: 10.0)
}

OR

Your can restart the progressView by will using

progressManager.restart(withInfo:)

progressmanager's People

Contributors

txm5586 avatar

Watchers

 avatar

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.