UNPKG

@nativescript-community/ui-pager-indicator

Version:

A NativeScript Indicator for Pager / Carousel /CollectionView

70 lines 2.67 kB
import { Color } from '@nativescript/core'; import { Indicator, PagerIndicatorBase, colorProperty, selectedColorProperty } from './index.common'; export * from './index.common'; export class PagerIndicator extends PagerIndicatorBase { createNativeView() { switch (this.type) { case Indicator.Worm: return CHIPageControlAleppo.new(); case Indicator.Fill: return CHIPageControlChimayo.new(); case Indicator.Swap: return CHIPageControlPuya.new(); case Indicator.Thin_worm: return CHIPageControlJalapeno.new(); case Indicator.Flat: return CHIPageControlJaloro.new(); default: case Indicator.None: return CHIPageControlAji.new(); } } initNativeView() { super.initNativeView(); const nativeView = this.nativeView; nativeView.tintColor = UIColor.whiteColor; nativeView.currentPageTintColor = UIColor.whiteColor; switch (this.type) { case Indicator.None: case Indicator.Worm: case Indicator.Fill: case Indicator.Swap: case Indicator.Thin_worm: case Indicator.Disabled: nativeView.radius = 4; break; case Indicator.Flat: nativeView.radius = 2; nativeView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.7, 0.5); break; } } setProgress(position, progress) { NSCProgressHelper.setProgressWithPageControlProgressAnimated(this.nativeViewProtected, progress, true); } getCount() { return this.nativeViewProtected.numberOfPages; } getSelection() { return this.nativeViewProtected.progress; } setInteractiveAnimation(animated) { } setSelection(progress, animated = true) { NSCProgressHelper.setProgressWithPageControlProgressAnimated(this.nativeViewProtected, progress, animated); } setCount(count) { this.nativeViewProtected.numberOfPages = count; } withoutAnimation(callback) { callback(); } [colorProperty.setNative](value) { const color = !value || value instanceof Color ? value : new Color(value); this.nativeViewProtected.tintColor = color ? color.ios : null; } [selectedColorProperty.setNative](value) { const color = !value || value instanceof Color ? value : new Color(value); this.nativeViewProtected.currentPageTintColor = color ? color.ios : null; } } //# sourceMappingURL=index.ios.js.map