nativescript-bottom-navigation
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -24,3 +24,5 @@ import { AfterViewInit, ElementRef } from "@angular/core"; | ||
icon: string; | ||
private _selectable; | ||
selectable: boolean; | ||
} | ||
export declare const DIRECTIVES: (typeof BottomNavigationDirective | typeof BottomNavigationTabDirective)[]; |
@@ -149,2 +149,12 @@ "use strict"; | ||
}); | ||
Object.defineProperty(BottomNavigationTabDirective.prototype, "selectable", { | ||
get: function () { | ||
return this._selectable; | ||
}, | ||
set: function (value) { | ||
this._selectable = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return BottomNavigationTabDirective; | ||
@@ -162,2 +172,6 @@ }()); | ||
], BottomNavigationTabDirective.prototype, "icon", null); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], BottomNavigationTabDirective.prototype, "_selectable", void 0); | ||
BottomNavigationTabDirective = __decorate([ | ||
@@ -164,0 +178,0 @@ core_1.Directive({ |
import { BottomNavigationBase, BottomNavigationTabBase } from './bottom-navigation.common'; | ||
export declare class BottomNavigation extends BottomNavigationBase { | ||
readonly android: any; | ||
createNativeView(): Object; | ||
initNativeView(): void; | ||
readonly android: any; | ||
createTabs(tabs: BottomNavigationTab[]): void; | ||
onTabSelected(index: number): void; | ||
protected selectTabNative(index: number): void; | ||
} | ||
export declare class BottomNavigationTab extends BottomNavigationTabBase { | ||
constructor(title: string, icon: string, parent?: WeakRef<BottomNavigationBase>); | ||
constructor(title: string, icon: string, selectable?: boolean, parent?: WeakRef<BottomNavigationBase>); | ||
} |
@@ -14,2 +14,9 @@ "use strict"; | ||
} | ||
Object.defineProperty(BottomNavigation.prototype, "android", { | ||
get: function () { | ||
return this.nativeView; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
BottomNavigation.prototype.createNativeView = function () { | ||
@@ -24,3 +31,3 @@ this.nativeView = new AHBottomNavigation(this._context); | ||
if (this.owner && !wasSelected && this.owner.selectedTabIndex !== position) { | ||
this.owner.onTabSelected(position); | ||
return this.owner.onTabSelected(position); | ||
} | ||
@@ -30,7 +37,2 @@ return true; | ||
})); | ||
this.nativeView.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW); | ||
this.nativeView.setAccentColor(new color_1.Color(this.activeColor).android); | ||
this.nativeView.setInactiveColor(new color_1.Color(this.inactiveColor).android); | ||
this.nativeView.setColored(false); | ||
this.nativeView.setDefaultBackgroundColor(new color_1.Color(this.backgroundColor).android); | ||
return this.nativeView; | ||
@@ -45,16 +47,6 @@ }; | ||
}; | ||
Object.defineProperty(BottomNavigation.prototype, "android", { | ||
get: function () { | ||
return this.nativeView; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
BottomNavigation.prototype[bottom_navigation_common_1.tabsProperty.getDefault] = function () { | ||
return null; | ||
}; | ||
BottomNavigation.prototype[bottom_navigation_common_1.tabsProperty.setNative] = function (value) { | ||
this.createTabs(value); | ||
}; | ||
BottomNavigation.prototype.createTabs = function (tabs) { | ||
if (!this.tabs) { | ||
this.tabs = tabs; | ||
} | ||
for (var _i = 0, tabs_1 = tabs; _i < tabs_1.length; _i++) { | ||
@@ -68,2 +60,8 @@ var tab = tabs_1[_i]; | ||
}; | ||
BottomNavigation.prototype[bottom_navigation_common_1.tabsProperty.getDefault] = function () { | ||
return null; | ||
}; | ||
BottomNavigation.prototype[bottom_navigation_common_1.tabsProperty.setNative] = function (value) { | ||
this.createTabs(value); | ||
}; | ||
BottomNavigation.prototype[bottom_navigation_common_1.activeColorProperty.setNative] = function (activeColor) { | ||
@@ -87,12 +85,2 @@ this.nativeView.setAccentColor(new color_1.Color(activeColor).android); | ||
}; | ||
BottomNavigation.prototype.onTabSelected = function (index) { | ||
var eventData = { | ||
eventName: 'tabSelected', | ||
object: this, | ||
oldIndex: this.selectedTabIndex, | ||
newIndex: index | ||
}; | ||
this.selectedTabIndex = index; | ||
this.notify(eventData); | ||
}; | ||
BottomNavigation.prototype.selectTabNative = function (index) { | ||
@@ -106,4 +94,4 @@ this.nativeView.setCurrentItem(index); | ||
__extends(BottomNavigationTab, _super); | ||
function BottomNavigationTab(title, icon, parent) { | ||
return _super.call(this, title, icon, parent) || this; | ||
function BottomNavigationTab(title, icon, selectable, parent) { | ||
return _super.call(this, title, icon, selectable, parent) || this; | ||
} | ||
@@ -110,0 +98,0 @@ return BottomNavigationTab; |
@@ -17,4 +17,5 @@ import { AddChildFromBuilder, View } from 'tns-core-modules/ui/core/view'; | ||
selectTab(index: number): void; | ||
onTabSelected(index: number): boolean; | ||
_addChildFromBuilder(name: string, value: any): void; | ||
protected abstract selectTabNative(index: number): void; | ||
_addChildFromBuilder(name: string, value: any): void; | ||
} | ||
@@ -29,9 +30,11 @@ export declare const tabsProperty: Property<BottomNavigationBase, BottomNavigationTabBase[]>; | ||
export declare class BottomNavigationTabBase { | ||
constructor(title: string, icon: string, selectable?: boolean, parent?: WeakRef<BottomNavigationBase>); | ||
private _title; | ||
title: string; | ||
private _icon; | ||
icon: string; | ||
private _selectable; | ||
selectable: boolean; | ||
private _parent?; | ||
constructor(title: string, icon: string, parent?: WeakRef<BottomNavigationBase>); | ||
title: string; | ||
icon: string; | ||
parent: WeakRef<BottomNavigationBase>; | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
var color_1 = require("tns-core-modules/color"); | ||
var view_base_1 = require("tns-core-modules/ui/core/view-base"); | ||
var BottomNavigationBase = (function (_super) { | ||
@@ -23,2 +24,15 @@ __extends(BottomNavigationBase, _super); | ||
}; | ||
BottomNavigationBase.prototype.onTabSelected = function (index) { | ||
var eventData = { | ||
eventName: 'tabSelected', | ||
object: this, | ||
oldIndex: this.selectedTabIndex || 0, | ||
newIndex: index | ||
}; | ||
if (this.tabs[index].selectable) { | ||
this.selectedTabIndex = index; | ||
} | ||
this.notify(eventData); | ||
return this.tabs[index].selectable; | ||
}; | ||
BottomNavigationBase.prototype._addChildFromBuilder = function (name, value) { | ||
@@ -74,5 +88,9 @@ if (name === 'BottomNavigationTab') { | ||
var BottomNavigationTabBase = (function () { | ||
function BottomNavigationTabBase(title, icon, parent) { | ||
function BottomNavigationTabBase(title, icon, selectable, parent) { | ||
this._selectable = true; | ||
this._title = title; | ||
this._icon = icon; | ||
if (selectable) { | ||
this._selectable = selectable; | ||
} | ||
if (parent) { | ||
@@ -106,2 +124,12 @@ this._parent = parent; | ||
}); | ||
Object.defineProperty(BottomNavigationTabBase.prototype, "selectable", { | ||
get: function () { | ||
return view_base_1.booleanConverter(this._selectable); | ||
}, | ||
set: function (value) { | ||
this._selectable = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(BottomNavigationTabBase.prototype, "parent", { | ||
@@ -108,0 +136,0 @@ get: function () { |
@@ -10,2 +10,3 @@ import { BottomNavigationBase, BottomNavigationTabBase } from './bottom-navigation.common'; | ||
private _delegate; | ||
readonly ios: any; | ||
createNativeView(): Object; | ||
@@ -15,9 +16,7 @@ initNativeView(): void; | ||
onLoaded(): void; | ||
readonly ios: any; | ||
createTabs(tabs: BottomNavigationTab[]): void; | ||
onTabSelected(index: number): void; | ||
protected selectTabNative(index: number): void; | ||
} | ||
export declare class BottomNavigationTab extends BottomNavigationTabBase { | ||
constructor(title: string, icon: string, parent?: WeakRef<BottomNavigationBase>); | ||
constructor(title: string, icon: string, selectable?: boolean, parent?: WeakRef<BottomNavigationBase>); | ||
} |
@@ -30,2 +30,9 @@ "use strict"; | ||
} | ||
Object.defineProperty(BottomNavigation.prototype, "ios", { | ||
get: function () { | ||
return this.nativeView; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
BottomNavigation.prototype.createNativeView = function () { | ||
@@ -50,16 +57,6 @@ this._delegate = BottomNavigationDelegate.initWithOwner(new WeakRef(this)); | ||
}; | ||
Object.defineProperty(BottomNavigation.prototype, "ios", { | ||
get: function () { | ||
return this.nativeView; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
BottomNavigation.prototype[bottom_navigation_common_1.tabsProperty.getDefault] = function () { | ||
return null; | ||
}; | ||
BottomNavigation.prototype[bottom_navigation_common_1.tabsProperty.setNative] = function (value) { | ||
this.createTabs(value); | ||
}; | ||
BottomNavigation.prototype.createTabs = function (tabs) { | ||
if (!this.tabs) { | ||
this.tabs = tabs; | ||
} | ||
var bottomNavigationTabs = []; | ||
@@ -70,2 +67,3 @@ for (var _i = 0, tabs_1 = tabs; _i < tabs_1.length; _i++) { | ||
var miniTabBarItem = new MiniTabBarItem({ title: tab.title, icon: image_source_1.fromResource(tab.icon).ios }); | ||
miniTabBarItem.selectable = tab.selectable; | ||
bottomNavigationTabs.push(miniTabBarItem); | ||
@@ -75,2 +73,8 @@ } | ||
}; | ||
BottomNavigation.prototype[bottom_navigation_common_1.tabsProperty.getDefault] = function () { | ||
return null; | ||
}; | ||
BottomNavigation.prototype[bottom_navigation_common_1.tabsProperty.setNative] = function (value) { | ||
this.createTabs(value); | ||
}; | ||
BottomNavigation.prototype[bottom_navigation_common_1.activeColorProperty.setNative] = function (activeColor) { | ||
@@ -94,12 +98,2 @@ this.nativeView.tintColor = new color_1.Color(activeColor).ios; | ||
}; | ||
BottomNavigation.prototype.onTabSelected = function (index) { | ||
var eventData = { | ||
eventName: 'tabSelected', | ||
object: this, | ||
oldIndex: this.selectedTabIndex, | ||
newIndex: index | ||
}; | ||
this.selectedTabIndex = index; | ||
this.notify(eventData); | ||
}; | ||
BottomNavigation.prototype.selectTabNative = function (index) { | ||
@@ -113,4 +107,4 @@ this.nativeView.selectItemAnimated(index, true); | ||
__extends(BottomNavigationTab, _super); | ||
function BottomNavigationTab(title, icon, parent) { | ||
return _super.call(this, title, icon, parent) || this; | ||
function BottomNavigationTab(title, icon, selectable, parent) { | ||
return _super.call(this, title, icon, selectable, parent) || this; | ||
} | ||
@@ -117,0 +111,0 @@ return BottomNavigationTab; |
@@ -10,3 +10,2 @@ import { BottomNavigationBase, BottomNavigationTabBase } from './bottom-navigation.common'; | ||
export declare class BottomNavigation extends BottomNavigationBase { | ||
private _delegate; | ||
@@ -23,10 +22,12 @@ public tabs: BottomNavigationTab[]; | ||
readonly ios: any; | ||
private _delegate; | ||
constructor(); | ||
readonly ios: any; | ||
public createTabs(tabs: BottomNavigationTab[]): void; | ||
createTabs(tabs: BottomNavigationTab[]): void; | ||
public selectTab(index: number): void; | ||
selectTab(index: number): void; | ||
protected selectTabNative(index: number): void; | ||
@@ -36,3 +37,3 @@ } | ||
export declare class BottomNavigationTab extends BottomNavigationTabBase { | ||
constructor(title: string, icon: string, parent?: WeakRef<BottomNavigationBase>); | ||
constructor(title: string, icon: string, selectable?: boolean, parent?: WeakRef<BottomNavigationBase>); | ||
} |
{ | ||
"name": "nativescript-bottom-navigation", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Nativescript plugin to add a bottom navigation component for Android & iOS", | ||
@@ -5,0 +5,0 @@ "main": "bottom-navigation", |
@@ -253,1 +253,2 @@ # Nativescript Bottom Navigation | ||
| icon | true | null | `String` | Icon of the tab | | ||
| selectable | false | true | `Boolean` | Determine if the tab can be selected or not (The `tabSelected` event still be fired) | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54940
675
254