mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
fix(ios): set current tab as topmost frame on load (#5908)
This commit is contained in:
@ -2,7 +2,7 @@ import * as helper from "../helper";
|
|||||||
import TKUnit = require("../../TKUnit");
|
import TKUnit = require("../../TKUnit");
|
||||||
import { isIOS, isAndroid } from "tns-core-modules/platform";
|
import { isIOS, isAndroid } from "tns-core-modules/platform";
|
||||||
import { _resetRootView } from "tns-core-modules/application/";
|
import { _resetRootView } from "tns-core-modules/application/";
|
||||||
import { Frame, NavigationEntry } from "tns-core-modules/ui/frame";
|
import { Frame, NavigationEntry, topmost } from "tns-core-modules/ui/frame";
|
||||||
import { Page } from "tns-core-modules/ui/page";
|
import { Page } from "tns-core-modules/ui/page";
|
||||||
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
|
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
|
||||||
|
|
||||||
@ -56,7 +56,26 @@ function createTabItemsWithFrames(count: number) {
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_ios_and_android_offset_zero_should_raise_same_events() {
|
export function test_frame_topmost_matches_selectedIndex() {
|
||||||
|
const items = createTabItemsWithFrames(3);
|
||||||
|
const tabView = new TabView();
|
||||||
|
tabView.items = items.map(item => item.tabItem);
|
||||||
|
tabView.selectedIndex = 0;
|
||||||
|
|
||||||
|
const entry: NavigationEntry = {
|
||||||
|
create: () => tabView
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.waitUntilNavigatedTo(items[0].page, () => _resetRootView(entry));
|
||||||
|
|
||||||
|
TKUnit.assertEqual(topmost().id, "Tab0 Frame0");
|
||||||
|
|
||||||
|
helper.waitUntilNavigatedTo(items[1].page, () => tabView.selectedIndex = 1);
|
||||||
|
|
||||||
|
TKUnit.assertEqual(topmost().id, "Tab1 Frame1");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_offset_zero_should_raise_same_events() {
|
||||||
let actualEventsRaised = [];
|
let actualEventsRaised = [];
|
||||||
|
|
||||||
function resetActualEventsRaised() {
|
function resetActualEventsRaised() {
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
"nativescript": {
|
"nativescript": {
|
||||||
"id": "org.nativescript.UnitTestApp",
|
"id": "org.nativescript.UnitTestApp",
|
||||||
"tns-ios": {
|
"tns-ios": {
|
||||||
"version": "3.4.1"
|
"version": "4.1.0"
|
||||||
},
|
},
|
||||||
"tns-android": {
|
"tns-android": {
|
||||||
"version": "3.4.1"
|
"version": "4.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -213,6 +213,13 @@ export class TabView extends TabViewBase {
|
|||||||
@profile
|
@profile
|
||||||
public onLoaded() {
|
public onLoaded() {
|
||||||
super.onLoaded();
|
super.onLoaded();
|
||||||
|
|
||||||
|
const selectedIndex = this.selectedIndex;
|
||||||
|
const selectedView = this.items && this.items[selectedIndex] && this.items[selectedIndex].view;
|
||||||
|
if (selectedView instanceof Frame) {
|
||||||
|
selectedView._pushInFrameStack();
|
||||||
|
}
|
||||||
|
|
||||||
this._ios.delegate = this._delegate;
|
this._ios.delegate = this._delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user