Node v6
Starting with v0.19 Astro must be used with Node v6+!
Menu

Counter Badge

Sample Usage

const counterBadgeController = await CounterBadgeController.init('file:///icon.png', 'icon_id')
counterBadgeController.updateCount(12);
const headerIcondata = await counterBadgeController.generateContent()
navigationPlugin.navigate(url, {header: {rightIcon: headerIconData}});

Plugin

The counter badge plugin allows you to overlay an image with a rounded badge in it's top right hand corner. The badge defaults to having a red background with white text. The badge number can contain an integer of zero or greater. The badge is not shown when the number is set to zero.

Methods

CounterBadgePlugin.init() #

Creates and returns an instance of the counter badge plugin that is used to make subsequent method calls.


setImagePath(path) #

Sets the image to be displayed. The image should be sized as a standard icon. The callback will contain an error if the image fails to load.


setCount(count) #

Sets the number to be displayed in the badge. The badge number can contain an integer of zero or greater. The badge is not shown when the number is set to zero.


setBackgroundColor(color) #

Sets the background color of the badge


setTextColor(color) #

Sets the text color of the badge

Controller

The counter badge controller allows the management of a group of counter badge plugins. In Astro when navigating we create a new header bar. Using the current icon in the new header bar would remove it from the previous header bar. When returning to the old header bar (back navigation) the icon would be gone (native UIs cannot display the same icon in two places). Thus when navigating a new identical icon is needed so that the icon on the old header bar remains in place.

The controller will allow all of the badge plugins to display the same image, count, background color, and text color. All of the badge plugin icons will also perform the same behavior when selected.

Methods

CounterBadgeController.init(imagePath, headerId, options) #

Creates and returns an instance of the counter badge controller that is used to make subsequent method calls.


generateContent() #

Creates a new counter badge plugin initialized with the current counter badge state in the controller. Returns a promise which resolves with the header icon data which can be used to reference the newly generated icon.


generatePlugin() #

Creates a new counter badge plugin initialized with the current counter badge state in the controller. Returns a promise which resolves the newly generated plugin.


updateCounterValue(counterValue) #

Sets the number to be displayed in all the badges created by the controller. The badge number can contain an integer of zero or greater. The badge is not shown when the number is set to zero.


updateBackgroundColor(backgroundColor) #

Sets the background color of the badge to be displayed in all the badges created by the controller.


updateTextColor(textColor) #

Sets the text color of the badge to be displayed in all the badges created by the controller.

RPC Methods

AstroRpc.updateCounterValue(count) #

RPC method which updates the counter value in the counter badge controller.