nativescript-material-bottomnavigationbar
Version:
NativeScript plugin to add a bottom navigation bar component for Android & iOS
181 lines • 7.3 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.iconProperty = exports.isSelectableProperty = exports.BottomNavigationTabBase = exports.inactiveColorCssProperty = exports.activeColorCssProperty = exports.titleVisibilityProperty = exports.tabsProperty = exports.BottomNavigationBarBase = exports.TitleVisibility = void 0;
var image_source_1 = require("@nativescript/core/image-source");
var view_1 = require("@nativescript/core/ui/core/view");
var cssproperties_1 = require("nativescript-material-core/cssproperties");
var TitleVisibility;
(function (TitleVisibility) {
TitleVisibility[TitleVisibility["Selected"] = 0] = "Selected";
TitleVisibility[TitleVisibility["Always"] = 1] = "Always";
TitleVisibility[TitleVisibility["Never"] = 2] = "Never";
})(TitleVisibility = exports.TitleVisibility || (exports.TitleVisibility = {}));
var BottomNavigationBarBase = (function (_super) {
__extends(BottomNavigationBarBase, _super);
function BottomNavigationBarBase() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.selectedTabIndex = 0;
_this.titleVisibility = TitleVisibility.Selected;
_this._items = [];
return _this;
}
BottomNavigationBarBase_1 = BottomNavigationBarBase;
Object.defineProperty(BottomNavigationBarBase.prototype, "items", {
get: function () {
return this._items;
},
enumerable: false,
configurable: true
});
BottomNavigationBarBase.prototype.onLoaded = function () {
var _this = this;
_super.prototype.onLoaded.call(this);
this._items.forEach(function (child) {
_this.loadView(child);
return true;
});
};
BottomNavigationBarBase.prototype.selectTab = function (index) {
if (index === this.selectedTabIndex) {
return;
}
this.selectTabNative(index);
};
BottomNavigationBarBase.prototype._emitTabPressed = function (index) {
var eventData = {
eventName: BottomNavigationBarBase_1.tabPressedEvent,
object: this,
index: index,
};
this.notify(eventData);
this.removeBadge(index);
};
BottomNavigationBarBase.prototype._emitTabSelected = function (index) {
var eventData = {
eventName: BottomNavigationBarBase_1.tabSelectedEvent,
object: this,
oldIndex: this.selectedTabIndex,
newIndex: index,
};
this.selectedTabIndex = index;
this.notify(eventData);
this.removeBadge(index);
};
BottomNavigationBarBase.prototype._emitTabReselected = function (index) {
var eventData = {
eventName: BottomNavigationBarBase_1.tabReselectedEvent,
object: this,
index: index,
};
this.notify(eventData);
};
BottomNavigationBarBase.prototype._addChildFromBuilder = function (name, value) {
if (name === 'BottomNavigationTab') {
if (!this._items) {
this._items = [];
}
this._items.push(value);
}
};
BottomNavigationBarBase.prototype.showBadge = function (index, value) {
this._items[index] && this._items[index].showBadge(value);
};
BottomNavigationBarBase.prototype.removeBadge = function (index) {
this._items[index] && this._items[index].removeBadge();
};
var BottomNavigationBarBase_1;
BottomNavigationBarBase.tabPressedEvent = 'tabPressed';
BottomNavigationBarBase.tabSelectedEvent = 'tabSelected';
BottomNavigationBarBase.tabReselectedEvent = 'tabReselected';
__decorate([
cssproperties_1.cssProperty,
__metadata("design:type", view_1.Color)
], BottomNavigationBarBase.prototype, "activeColor", void 0);
__decorate([
cssproperties_1.cssProperty,
__metadata("design:type", view_1.Color)
], BottomNavigationBarBase.prototype, "inactiveColor", void 0);
BottomNavigationBarBase = BottomNavigationBarBase_1 = __decorate([
view_1.CSSType('BottomNavigationBar')
], BottomNavigationBarBase);
return BottomNavigationBarBase;
}(view_1.View));
exports.BottomNavigationBarBase = BottomNavigationBarBase;
exports.tabsProperty = new view_1.Property({
name: 'tabs',
affectsLayout: true,
});
exports.tabsProperty.register(BottomNavigationBarBase);
exports.titleVisibilityProperty = new view_1.Property({
name: 'titleVisibility',
equalityComparer: function (x, y) { return x === y; },
affectsLayout: true,
defaultValue: TitleVisibility.Selected,
valueConverter: function (v) { return TitleVisibility[v]; },
});
exports.titleVisibilityProperty.register(BottomNavigationBarBase);
exports.activeColorCssProperty = new view_1.CssProperty({
name: 'activeColor',
cssName: 'active-color',
equalityComparer: view_1.Color.equals,
defaultValue: new view_1.Color('black'),
valueConverter: function (v) { return new view_1.Color(v); },
});
exports.activeColorCssProperty.register(view_1.Style);
exports.inactiveColorCssProperty = new view_1.CssProperty({
name: 'inactiveColor',
cssName: 'inactive-color',
equalityComparer: view_1.Color.equals,
defaultValue: new view_1.Color('gray'),
valueConverter: function (v) { return new view_1.Color(v); },
});
exports.inactiveColorCssProperty.register(view_1.Style);
var BottomNavigationTabBase = (function (_super) {
__extends(BottomNavigationTabBase, _super);
function BottomNavigationTabBase(args) {
var _this = _super.call(this) || this;
if (!args) {
return _this;
}
for (var k in args) {
if (args.hasOwnProperty(k)) {
_this[k] = args[k];
}
}
return _this;
}
__decorate([
cssproperties_1.cssProperty,
__metadata("design:type", String)
], BottomNavigationTabBase.prototype, "title", void 0);
__decorate([
cssproperties_1.cssProperty,
__metadata("design:type", image_source_1.ImageSource)
], BottomNavigationTabBase.prototype, "icon", void 0);
__decorate([
cssproperties_1.cssProperty,
__metadata("design:type", view_1.Color)
], BottomNavigationTabBase.prototype, "activeColor", void 0);
__decorate([
cssproperties_1.cssProperty,
__metadata("design:type", view_1.Color)
], BottomNavigationTabBase.prototype, "inactiveColor", void 0);
BottomNavigationTabBase = __decorate([
view_1.CSSType('BottomNavigationTab'),
__metadata("design:paramtypes", [Object])
], BottomNavigationTabBase);
return BottomNavigationTabBase;
}(view_1.View));
exports.BottomNavigationTabBase = BottomNavigationTabBase;
exports.isSelectableProperty = new view_1.Property({
name: 'isSelectable',
defaultValue: true,
valueConverter: view_1.booleanConverter,
});
exports.isSelectableProperty.register(BottomNavigationTabBase);
exports.iconProperty = new view_1.Property({
name: 'icon',
affectsLayout: true,
valueConverter: image_source_1.ImageSource.fromFileOrResourceSync,
});
exports.iconProperty.register(BottomNavigationTabBase);
//# sourceMappingURL=bottomnavigationbar-common.js.map