npm i --save @nstudio/nativescript-fluid-segmented-bar
- Version: 1.0.2
- GitHub: https://github.com/nstudio/nativescript-ui-kit
- NPM: https://www.npmjs.com/package/%40nstudio%2Fnativescript-fluid-segmented-bar
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
@nstudio/nativescript-fluid-segmented-bar
Fluid Segmented Bar to liven up any standard SegmentedBar
control.
- iOS: Uses SJFluidSegmentedControl
- Android: Uses standard SegementedBar - Jetpack Compose will be added in future to replicate
Usage
npm install @nstudio/nativescript-fluid-segmented-bar
Use within any view layout:
<FluidSegmentedBar items="{{items}}" gradientColorSides="{{gradientColorSides}}" selectedIndexChanged="{{selectedIndexChanged}}" didScrollOffset="{{didScrollOffset}}"/>
Provide bindings for properties and events:
const items: Array<FluidSegmentedBarItem> = [
{
title: 'Enjoy',
colors: [new Color('#485ae6'), new Color('#87aeed')],
},
{
title: 'Your',
colors: [new Color('#87aeed'), new Color('#e53ca9')],
},
{
title: 'Life',
colors: [new Color('#c2c96a'), new Color('#678d50')],
},
];
const gradientColorSides: FluidSegmentedBarGradientColorSides = {
left: [new Color('#87aeed')],
right: [new Color('#c2c96a')],
};
function selectedIndexChanged(args: FluidSegmentedBarIndexChangedEvent) {
console.log('selectedIndexChanged:', args.newIndex);
}
function didScrollOffset(args: FluidSegmentedBarDidScrollEvent) {
console.log('didScrollOffset:', args.offset);
}
When using flavors, you can just register the element for usage in your markup:
import { FluidSegmentedBar } from '@nstudio/nativescript-fluid-segmented-bar'
// Angular
import { registerElement } from '@nativescript/angular'
registerElement('FluidSegmentedBar', () => FluidSegmentedBar)
// Solid
import { registerElement } from 'dominative';
registerElement('fluidSegmentedBar', FluidSegmentedBar);
// Svelte
import { registerNativeViewElement } from 'svelte-native/dom'
registerNativeViewElement('fluidSegmentedBar', () => FluidSegmentedBar);
// React
import { registerElement } from 'react-nativescript';
registerElement('fluidSegmentedBar', () => FluidSegmentedBar);
// Vue
import Vue from 'nativescript-vue'
Vue.registerElement('FluidSegmentedBar', () => FluidSegmentedBar)
API
Properties
items: Array<FluidSegmentedBarItem>
: Collection of bar items withtitle
andcolors
.gradientColorSides: FluidSegmentedBarGradientColorSides
: The gradiated side colors.
Events
selectedIndexChanged
: When the selectedIndex changes.didScrollOffset
: Whenever the control animates it's selected position, theoffset
andmaxOffset
will be emitted to provide ability to animate other visuals based on it's movement.
License
Apache License Version 2.0