mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Add TabView.androidOffscreenTabLimit property
Resolves #2815 * Gets or sets the number of tabs that should be retained to either side of the current tab in the view hierarchy in an idle state. * Tabs beyond this limit will be recreated from the TabView when needed.
This commit is contained in:
@@ -244,6 +244,13 @@ export class TabView extends View implements definition.TabView, AddArrayFromBui
|
||||
//
|
||||
}
|
||||
|
||||
get androidOffscreenTabLimit(): number {
|
||||
return undefined;
|
||||
}
|
||||
set androidOffscreenTabLimit(value: number) {
|
||||
//
|
||||
}
|
||||
|
||||
public _onSelectedIndexPropertyChangedSetNativeValue(data: PropertyChangeData) {
|
||||
var index = this.selectedIndex;
|
||||
if (types.isUndefined(index)) {
|
||||
|
||||
@@ -214,6 +214,9 @@ export class TabView extends common.TabView {
|
||||
}
|
||||
|
||||
this._viewPager = new android.support.v4.view.ViewPager(this._context);
|
||||
if (this._androidOffscreenTabLimit !== 1) {
|
||||
this._viewPager.setOffscreenPageLimit(this._androidOffscreenTabLimit);
|
||||
}
|
||||
this._viewPager.setId(this._androidViewId);
|
||||
var lp = new org.nativescript.widgets.CommonLayoutParams();
|
||||
lp.row = 1;
|
||||
@@ -332,6 +335,20 @@ export class TabView extends common.TabView {
|
||||
public _getAndroidTabView(): org.nativescript.widgets.TabLayout {
|
||||
return this._tabLayout;
|
||||
}
|
||||
|
||||
private _androidOffscreenTabLimit: number = 1;
|
||||
get androidOffscreenTabLimit(): number {
|
||||
return this._androidOffscreenTabLimit;
|
||||
}
|
||||
set androidOffscreenTabLimit(value: number) {
|
||||
if (value !== this._androidOffscreenTabLimit) {
|
||||
this._androidOffscreenTabLimit = value;
|
||||
if (this._viewPager) {
|
||||
this._viewPager.setOffscreenPageLimit(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class TabViewStyler implements style.Styler {
|
||||
|
||||
6
tns-core-modules/ui/tab-view/tab-view.d.ts
vendored
6
tns-core-modules/ui/tab-view/tab-view.d.ts
vendored
@@ -114,6 +114,12 @@ declare module "ui/tab-view" {
|
||||
*/
|
||||
iosIconRenderingMode: string;
|
||||
|
||||
/**
|
||||
* Gets or sets the number of tabs that should be retained to either side of the current tab in the view hierarchy in an idle state.
|
||||
* Tabs beyond this limit will be recreated from the TabView when needed.
|
||||
*/
|
||||
androidOffscreenTabLimit: number;
|
||||
|
||||
/**
|
||||
* String value used when hooking to the selectedIndexChanged event.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user