GithubHelp home page GithubHelp logo

badge's Introduction

Badge

A CommonJS module for Titanium mobile applications.

This module provides the ability to create application badges for use across iOS, Android, and MobileWeb. The default configuration visually mimics the iOS badge, but the styling can be configured further if desired.

Application Usage

This module is a CommonJS file, so we load it with require().

// Load the module.
var Badge = require('Badge');

Create a new badge and attach it to the View for which it is associated.
(By default, it will visually resemble the standard red iOS tab-sized badge.)

// Create a badge and attach it to a fake Tab View.
var badge1 = new Badge.Badge();
badge1.attachToView(fakeTab1);

To interact with the badge, simply call applyValue() and clear().

// Give the badge a number to show. The width will automatically resize as needed for larger numbers.
badge1.applyValue(8);

// Clear the badge, thus hiding it.
badge1.clear();

Application Usage - A more stylized example

// Create a larger rectangular badge that is green with no border or gradient.
// Place it at the upper right corner of the associated view.
var badge2 = new Badge.Badge({
	top : 5,
	right : 5,
	size : Badge.size.APP,
	shape : Badge.shape.SQUARE,
	color : Badge.color.GREEN,
	useBorder : false,
	useShading : false
});
badge2.attachToView(fakeTab2);

// Set a badge value.
badge2.applyValue(23); 

Please NOTE:

Your application should be using Titanium 2.1.0 or newer to take advantage of gradient shading for Android applications.

badge's People

Contributors

patrickseda avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

badge's Issues

Thanks for this

I ended up using this in a project at work, thanks for making this available Patrick! :D

Saved me time not having to write it from scratch myself. Just had to change a bit of the styling to match the designs, but otherwise it works fine on both platforms with the latest SDK. Nice one! :D

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.