Similar to FunctionStyleProvider, sets styles on a Feathers UI component by passing it to a function, but also provides a way to define alternate functions that may be called based on the contents of the component's variant property.

Alternate functions may be registered with the style provider by calling setStyleFunction() and passing in a variant name and a function. The style provider will search its registered variants to see if a function should be called. If the component's variant has not been registered with the style provider (or if the component has no variant), then the default style function will be called.

In the following example, a ClassVariantStyleProvider is created with a a default style function and an alternate style function:

var styleProvider = new ClassVariantStyleProvider();
styleProvider.setFunctionForStyleName(Button, null, (target:Button) -> {
	target.backgroundSkin = new Bitmap(bitmapData);
	// set other styles...
});
styleProvider.setFunctionForStyleName(Button, "alternate-button", (target:Button) -> {
	target.backgroundSkin = new Bitmap(alternateBitmapData);
	// set other styles...
});

var button = new Button();
button.text = "Click Me";
button.styleProvider = styleProvider;
this.addChild(button);

var alternateButton = new Button()
button.text = "No, click me!";
alternateButton.styleProvider = styleProvider;
alternateButton.variant = "alternate-button";
this.addChild(alternateButton);

Events:

feathers.events.StyleProviderEvent.STYLES_CHANGE

Dispatched when the styles have changed, and style objects should request for their styles to be re-applied.

Available since

1.0.0

.

See also:

Constructor

new()

Creates a new ClassVariantStyleProvider object.

Available since

1.0.0

.

Methods

applyStyles(target:IStyleObject):Void

Applies styles to the target object.

Available since

1.0.0

.

getStyleFunction<T>(type:Class<T>, variant:String):T ‑> Void

Gets a style function registered with setStyleFunction.

Available since

1.0.0

.

setStyleFunction<T>(type:Class<T>, variant:String, callback:T ‑> Void):Void

The target Feathers UI component is passed to this function when applyStyles() is called and the component's variant property contains the specified value.

Available since

1.0.0

.