nativescript-bubble-navigation
Version:
Nativescript plugin for Android & iOS that create beautiful navigation tabs
96 lines • 4.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var bubble_navigation_common_1 = require("./bubble-navigation.common");
var color_1 = require("tns-core-modules/color");
var utils = require("tns-core-modules/utils/utils");
var BubbleNavigationLinearView = com.gauravk.bubblenavigation.BubbleNavigationLinearView;
var BubbleToggleView = com.gauravk.bubblenavigation.BubbleToggleView;
var BubbleNavigation = (function (_super) {
__extends(BubbleNavigation, _super);
function BubbleNavigation() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(BubbleNavigation.prototype, "android", {
get: function () {
return this.nativeView;
},
enumerable: true,
configurable: true
});
BubbleNavigation.prototype.createNativeView = function () {
this.nativeView = new BubbleNavigationLinearView(this._context);
var owner = new WeakRef(this);
this.nativeView.setNavigationChangeListener(new com.gauravk.bubblenavigation.listener.BubbleNavigationChangeListener({
onNavigationChanged: function (view, index) {
owner.get().onTabSelected(index);
}
}));
return this.nativeView;
};
BubbleNavigation.prototype.initNativeView = function () {
this.viewID = android.view.View.generateViewId();
this.nativeView.setId(this.viewID);
};
BubbleNavigation.prototype.bindTabs = function (tabs) {
this._tabs = tabs;
for (var _i = 0, tabs_1 = tabs; _i < tabs_1.length; _i++) {
var tab = tabs_1[_i];
var bubbleToggle = new BubbleToggleView(this._context);
var id = android.view.View.generateViewId();
bubbleToggle.setId(id);
bubbleToggle.setBtDuration(300);
var icon = utils.ad.resources.getDrawableId(tab.icon);
bubbleToggle.setBtIcon(icon);
bubbleToggle.setBtTitle(tab.title);
if (tab.colorActive) {
bubbleToggle.setBtColorActive(new color_1.Color(tab.colorActive).android);
}
if (tab.colorInactive) {
bubbleToggle.setBtColorInactive(new color_1.Color(tab.colorInactive).android);
}
this.nativeView.addView(bubbleToggle);
}
};
BubbleNavigation.prototype[bubble_navigation_common_1.tabsProperty.getDefault] = function () {
return null;
};
BubbleNavigation.prototype[bubble_navigation_common_1.tabsProperty.setNative] = function (value) {
this.bindTabs(value);
};
BubbleNavigation.prototype[bubble_navigation_common_1.tabBackgroundColorProperty.getDefault] = function () {
return null;
};
BubbleNavigation.prototype[bubble_navigation_common_1.tabBackgroundColorProperty.setNative] = function (color) {
this.nativeView.setBackgroundColor(new color_1.Color(color).android);
};
BubbleNavigation.prototype[bubble_navigation_common_1.paddingProperty.getDefault] = function () {
return null;
};
BubbleNavigation.prototype[bubble_navigation_common_1.paddingProperty.setNative] = function (value) {
var density = this._context.getResources().getDisplayMetrics().density;
var dp = +value * density;
this.nativeView.setPadding(dp, dp, dp, dp);
};
BubbleNavigation.prototype[bubble_navigation_common_1.elevationProperty.getDefault] = function () {
return null;
};
BubbleNavigation.prototype[bubble_navigation_common_1.elevationProperty.setNative] = function (value) {
var density = this._context.getResources().getDisplayMetrics().density;
var dp = +value * density;
this.nativeView.setElevation(dp);
};
BubbleNavigation.prototype.selectTabNative = function (index) {
this.nativeView.setCurrentActiveItem(index);
};
return BubbleNavigation;
}(bubble_navigation_common_1.BubbleNavigationBase));
exports.BubbleNavigation = BubbleNavigation;
var BubbleNavigationItem = (function (_super) {
__extends(BubbleNavigationItem, _super);
function BubbleNavigationItem(title, icon, colorActive, colorInactive) {
return _super.call(this, title, icon, colorActive, colorInactive) || this;
}
return BubbleNavigationItem;
}(bubble_navigation_common_1.BubbleNavigationItemBase));
exports.BubbleNavigationItem = BubbleNavigationItem;
//# sourceMappingURL=bubble-navigation.android.js.map