mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge branch 'master' into master
This commit is contained in:
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -66,10 +66,8 @@
|
|||||||
"platform": "android",
|
"platform": "android",
|
||||||
"appRoot": "${workspaceRoot}/tests",
|
"appRoot": "${workspaceRoot}/tests",
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
|
"stopOnEntry": true,
|
||||||
"watch": true,
|
"watch": true,
|
||||||
// "tnsArgs": [
|
|
||||||
// "--debug-brk"
|
|
||||||
// ]
|
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// "name": "Test on Android",
|
// "name": "Test on Android",
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
BottomNavigation {
|
||||||
|
background-color: gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
TabStrip {
|
||||||
|
background-color: skyblue;
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<ActionBar title="BottomNavigation background-color" icon="" class="action-bar">
|
<ActionBar title="BottomNavigation background-color" icon="" class="action-bar">
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<BottomNavigation style="background-color: green;">
|
<BottomNavigation>
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabStripItem title="First"></TabStripItem>
|
<TabStripItem title="First"></TabStripItem>
|
||||||
<TabStripItem title="Second"></TabStripItem>
|
<TabStripItem title="Second"></TabStripItem>
|
||||||
@@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="First View" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="First View" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Second View" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Second View" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
</BottomNavigation>
|
</BottomNavigation>
|
||||||
|
|||||||
@@ -4,20 +4,20 @@
|
|||||||
|
|
||||||
<BottomNavigation style="color: green;">
|
<BottomNavigation style="color: green;">
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabStripItem title="First"></TabStripItem>
|
<TabStripItem title="First"></TabStripItem>
|
||||||
<TabStripItem title="Second"></TabStripItem>
|
<TabStripItem title="Second"></TabStripItem>
|
||||||
</TabStrip>
|
</TabStrip>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="First View" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="First View" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Second View" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Second View" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
</BottomNavigation>
|
</BottomNavigation>
|
||||||
</Page>
|
</Page>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BottomNavigation, SelectedIndexChangedEventData } from "tns-core-modules/ui/bottom-navigation";
|
import { BottomNavigation, SelectedIndexChangedEventData } from "tns-core-modules/ui/bottom-navigation";
|
||||||
|
|
||||||
export function onSelectedIndexChanged(args: SelectedIndexChangedEventData) {
|
export function onSelectedIndexChanged(args: SelectedIndexChangedEventData) {
|
||||||
const bottomNav = args.object as BottomNavigation;
|
const bottomNav = <BottomNavigation>args.object;
|
||||||
|
|
||||||
const newItem = bottomNav.tabStrip.items[args.newIndex];
|
const newItem = bottomNav.tabStrip.items[args.newIndex];
|
||||||
if (newItem) {
|
if (newItem) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" class="page" navigatingTo="onNavigatingTo">
|
<Page xmlns="http://schemas.nativescript.org/tns.xsd" class="page" navigatingTo="onNavigatingTo">
|
||||||
<ActionBar title="BottomNavigation icon change" icon="" class="action-bar">
|
<ActionBar title="BottomNavigation icon change" icon="" class="action-bar">
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
|
|||||||
@@ -11,19 +11,19 @@
|
|||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Title and icon" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Title and icon" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Only icon" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Only icon" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Only title" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Only title" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
</BottomNavigation>
|
</BottomNavigation>
|
||||||
|
|||||||
7
e2e/ui-tests-app/app/tabs/background-color-page.css
Normal file
7
e2e/ui-tests-app/app/tabs/background-color-page.css
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Tabs {
|
||||||
|
background-color: gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
TabStrip {
|
||||||
|
background-color: skyblue;
|
||||||
|
}
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
<Page class="page">
|
<Page class="page">
|
||||||
|
|
||||||
<ActionBar title="BottomNavigation background-color" icon="" class="action-bar">
|
<ActionBar title="Tabs background-color" icon="" class="action-bar">
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<BottomNavigation style="background-color: green;">
|
<Tabs>
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabStripItem title="First"></TabStripItem>
|
<TabStripItem title="First"></TabStripItem>
|
||||||
<TabStripItem title="Second"></TabStripItem>
|
<TabStripItem title="Second"></TabStripItem>
|
||||||
</TabStrip>
|
</TabStrip>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="First View" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="First View" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Second View" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Second View" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
</BottomNavigation>
|
</Tabs>
|
||||||
</Page>
|
</Page>
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
<Page class="page">
|
<Page class="page">
|
||||||
<ActionBar title="BottomNavigation color" icon="" class="action-bar">
|
<ActionBar title="Tabs color" icon="" class="action-bar">
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<BottomNavigation style="color: green;">
|
<Tabs style="color: green;">
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabStripItem title="First"></TabStripItem>
|
<TabStripItem title="First"></TabStripItem>
|
||||||
<TabStripItem title="Second"></TabStripItem>
|
<TabStripItem title="Second"></TabStripItem>
|
||||||
</TabStrip>
|
</TabStrip>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="First View" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="First View" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Second View" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Second View" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
</BottomNavigation>
|
</Tabs>
|
||||||
</Page>
|
</Page>
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
import { EventData } from "tns-core-modules/data/observable";
|
import { EventData } from "tns-core-modules/data/observable";
|
||||||
import { Page } from "tns-core-modules/ui/page";
|
import { Page } from "tns-core-modules/ui/page";
|
||||||
import { BottomNavigation } from "tns-core-modules/ui/bottom-navigation";
|
import { Tabs } from "tns-core-modules/ui/tabs";
|
||||||
|
|
||||||
export function goToFirst(args: EventData) {
|
export function goToFirst(args: EventData) {
|
||||||
const page = <Page>(<any>args.object).page;
|
const page = <Page>(<any>args.object).page;
|
||||||
const bottomNav = <BottomNavigation>page.getViewById("bottomNav");
|
const tabsNav = <Tabs>page.getViewById("tabsNav");
|
||||||
|
|
||||||
bottomNav.selectedIndex = 0;
|
tabsNav.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function goToSecond(args: EventData) {
|
export function goToSecond(args: EventData) {
|
||||||
const page = <Page>(<any>args.object).page;
|
const page = <Page>(<any>args.object).page;
|
||||||
const bottomNav = <BottomNavigation>page.getViewById("bottomNav");
|
const tabsNav = <Tabs>page.getViewById("tabsNav");
|
||||||
|
|
||||||
bottomNav.selectedIndex = 1;
|
tabsNav.selectedIndex = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Page>
|
<Page>
|
||||||
|
|
||||||
<ActionBar title="BottomNavigation" icon="" class="action-bar">
|
<ActionBar title="Tabs" icon="" class="action-bar">
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<!-- w/o TabStrip -->
|
<!-- w/o TabStrip -->
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
</BottomNavigation> -->
|
</BottomNavigation> -->
|
||||||
|
|
||||||
<!-- w/ TabStrip -->
|
<!-- w/ TabStrip -->
|
||||||
<Tabs id="bottomNav">
|
<Tabs id="tabsNav">
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabStripItem title="First Tab 11" iconSource="res://icon"></TabStripItem>
|
<TabStripItem title="First Tab 11" iconSource="res://icon"></TabStripItem>
|
||||||
<TabStripItem>
|
<TabStripItem>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { BottomNavigation, SelectedIndexChangedEventData } from "tns-core-modules/ui/bottom-navigation";
|
import { Tabs, SelectedIndexChangedEventData } from "tns-core-modules/ui/tabs";
|
||||||
|
|
||||||
export function onSelectedIndexChanged(args: SelectedIndexChangedEventData) {
|
export function onSelectedIndexChanged(args: SelectedIndexChangedEventData) {
|
||||||
const bottomNav = args.object as BottomNavigation;
|
const tabsNav = <Tabs>args.object;
|
||||||
|
|
||||||
const newItem = bottomNav.tabStrip.items[args.newIndex];
|
const newItem = tabsNav.tabStrip.items[args.newIndex];
|
||||||
if (newItem) {
|
if (newItem) {
|
||||||
newItem.iconSource = "res://icon";
|
newItem.iconSource = "res://icon";
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldItem = bottomNav.tabStrip.items[args.oldIndex];
|
const oldItem = tabsNav.tabStrip.items[args.oldIndex];
|
||||||
if (oldItem) {
|
if (oldItem) {
|
||||||
oldItem.iconSource = "res://testlogo";
|
oldItem.iconSource = "res://testlogo";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" class="page" navigatingTo="onNavigatingTo">
|
<Page xmlns="http://schemas.nativescript.org/tns.xsd" class="page" navigatingTo="onNavigatingTo">
|
||||||
<ActionBar title="BottomNavigation icon change" icon="" class="action-bar">
|
<ActionBar title="Tabs icon change" icon="" class="action-bar">
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<BottomNavigation id="tab-view" selectedIndexChanged="onSelectedIndexChanged">
|
<Tabs id="tab-view" selectedIndexChanged="onSelectedIndexChanged">
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabStripItem iconSource="res://icon"></TabStripItem>
|
<TabStripItem iconSource="res://icon"></TabStripItem>
|
||||||
<TabStripItem iconSource="res://testlogo"></TabStripItem>
|
<TabStripItem iconSource="res://testlogo"></TabStripItem>
|
||||||
@@ -19,5 +19,5 @@
|
|||||||
<Label text="second tab"/>
|
<Label text="second tab"/>
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
</BottomNavigation>
|
</Tabs>
|
||||||
</Page>
|
</Page>
|
||||||
@@ -1,30 +1,30 @@
|
|||||||
<Page class="page">
|
<Page class="page">
|
||||||
<ActionBar title="BottomNavigation icon title placement" icon="" class="action-bar">
|
<ActionBar title="Tabs icon title placement" icon="" class="action-bar">
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<BottomNavigation>
|
<Tabs>
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabStripItem title="Title" iconSource="res://add_to_fav"></TabStripItem>
|
<TabStripItem title="Title" iconSource="res://add_to_fav"></TabStripItem>
|
||||||
<TabStripItem iconSource="res://add_to_fav"></TabStripItem>
|
<TabStripItem iconSource="res://add_to_fav"></TabStripItem>
|
||||||
<TabStripItem title="Title"></TabStripItem>
|
<TabStripItem title="Title"></TabStripItem>
|
||||||
</TabStrip>
|
</TabStrip>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Title and icon" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Title and icon" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Only icon" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Only icon" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
|
|
||||||
<TabContentItem>
|
<TabContentItem>
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
<Label text="Only title" verticalAlignment="center" horizontalAlignment="center"/>
|
<Label text="Only title" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
</BottomNavigation>
|
</Tabs>
|
||||||
</Page>
|
</Page>
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" class="page">
|
<Page xmlns="http://schemas.nativescript.org/tns.xsd" class="page">
|
||||||
|
|
||||||
<ActionBar title="BottomNavigation issue 5470" icon="" class="action-bar">
|
<ActionBar title="Tabs issue 5470" icon="" class="action-bar">
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<BottomNavigation>
|
<Tabs>
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabStripItem title="Tab1"></TabStripItem>
|
<TabStripItem title="Tab1"></TabStripItem>
|
||||||
<TabStripItem title="Tab2"></TabStripItem>
|
<TabStripItem title="Tab2"></TabStripItem>
|
||||||
@@ -22,6 +22,6 @@
|
|||||||
<StackLayout row="1" backgroundColor="red" height="50"></StackLayout>
|
<StackLayout row="1" backgroundColor="red" height="50"></StackLayout>
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</TabContentItem>
|
</TabContentItem>
|
||||||
</BottomNavigation>
|
</Tabs>
|
||||||
|
|
||||||
</Page>
|
</Page>
|
||||||
@@ -11,14 +11,14 @@ export function pageLoaded(args: EventData) {
|
|||||||
|
|
||||||
export function loadExamples() {
|
export function loadExamples() {
|
||||||
const examples = new Map<string, string>();
|
const examples = new Map<string, string>();
|
||||||
examples.set("default", "tabs/default-page");
|
examples.set("tabs", "tabs/tabs-page");
|
||||||
examples.set("issue-5470", "tabs/issue-5470-page");
|
examples.set("issue-5470", "tabs/issue-5470");
|
||||||
examples.set("background-color", "tabs/background-color-page");
|
examples.set("background-color", "tabs/background-color-page");
|
||||||
examples.set("color", "tabs/color-page");
|
examples.set("color", "tabs/color");
|
||||||
examples.set("icon-title-placement", "tabs/icon-title-placement-page");
|
examples.set("icon-title-placement", "tabs/icon-title-placement");
|
||||||
examples.set("icon-change", "tabs/icon-change-page");
|
examples.set("icon-change", "tabs/icon-change");
|
||||||
examples.set("swipe-enabled", "tabs/swipe-enabled-page");
|
examples.set("swipe-enabled", "tabs/swipe-enabled");
|
||||||
examples.set("tabs-position", "tabs/tabs-position-page");
|
examples.set("tabs-position", "tabs/tabs-position");
|
||||||
|
|
||||||
return examples;
|
return examples;
|
||||||
}
|
}
|
||||||
|
|||||||
17
e2e/ui-tests-app/app/tabs/tabs-page.ts
Normal file
17
e2e/ui-tests-app/app/tabs/tabs-page.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { EventData } from "tns-core-modules/data/observable";
|
||||||
|
import { Page } from "tns-core-modules/ui/page";
|
||||||
|
import { Tabs } from "tns-core-modules/ui/tabs";
|
||||||
|
|
||||||
|
export function goToFirst(args: EventData) {
|
||||||
|
const page = <Page>(<any>args.object).page;
|
||||||
|
const tabsNav = <Tabs>page.getViewById("tabsNav");
|
||||||
|
|
||||||
|
tabsNav.selectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function goToSecond(args: EventData) {
|
||||||
|
const page = <Page>(<any>args.object).page;
|
||||||
|
const tabsNav = <Tabs>page.getViewById("tabsNav");
|
||||||
|
|
||||||
|
tabsNav.selectedIndex = 1;
|
||||||
|
}
|
||||||
89
e2e/ui-tests-app/app/tabs/tabs-page.xml
Normal file
89
e2e/ui-tests-app/app/tabs/tabs-page.xml
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<Page>
|
||||||
|
|
||||||
|
<ActionBar title="Tabs" icon="" class="action-bar">
|
||||||
|
</ActionBar>
|
||||||
|
|
||||||
|
<!-- w/o TabStrip -->
|
||||||
|
<!-- <BottomNavigation>
|
||||||
|
<TabContentItem>
|
||||||
|
<GridLayout>
|
||||||
|
<Label text="First View"/>
|
||||||
|
</GridLayout>
|
||||||
|
</TabContentItem>
|
||||||
|
<TabContentItem>
|
||||||
|
<GridLayout>
|
||||||
|
<Label text="Second View"/>
|
||||||
|
</GridLayout>
|
||||||
|
</TabContentItem>
|
||||||
|
</BottomNavigation> -->
|
||||||
|
|
||||||
|
<!-- w/ TabStrip -->
|
||||||
|
<Tabs id="tabsNav">
|
||||||
|
<TabStrip>
|
||||||
|
<TabStripItem title="First Tab 11" iconSource="res://icon"></TabStripItem>
|
||||||
|
<TabStripItem>
|
||||||
|
<!-- <Image src="res://icon" /> -->
|
||||||
|
<Label text="News" />
|
||||||
|
</TabStripItem>
|
||||||
|
<!-- <TabStripItem title="Favorites" iconSource="res://icon"></TabStripItem> -->
|
||||||
|
<TabStripItem>
|
||||||
|
<!-- <Image src="res://icon" /> -->
|
||||||
|
<Label text="Places" />
|
||||||
|
</TabStripItem>
|
||||||
|
<!-- <TabStripItem title="Music" iconSource="res://icon"></TabStripItem> -->
|
||||||
|
</TabStrip>
|
||||||
|
|
||||||
|
<TabContentItem>
|
||||||
|
<StackLayout backgroundColor="blue">
|
||||||
|
<Label text="First View"/>
|
||||||
|
<Button tap="goToSecond" text="go to second" />
|
||||||
|
</StackLayout>
|
||||||
|
</TabContentItem>
|
||||||
|
<TabContentItem>
|
||||||
|
<StackLayout backgroundColor="red">
|
||||||
|
<Label text="Second View"/>
|
||||||
|
<Button tap="goToFirst" text="go to first" />
|
||||||
|
</StackLayout>
|
||||||
|
</TabContentItem>
|
||||||
|
<TabContentItem>
|
||||||
|
<StackLayout backgroundColor="green">
|
||||||
|
<Label text="First View"/>
|
||||||
|
<Button tap="goToSecond" text="go to second" />
|
||||||
|
</StackLayout>
|
||||||
|
</TabContentItem>
|
||||||
|
<!-- <TabContentItem>
|
||||||
|
<StackLayout>
|
||||||
|
<Label text="Second View"/>
|
||||||
|
<Button tap="goToFirst" text="go to first" />
|
||||||
|
</StackLayout>
|
||||||
|
</TabContentItem>
|
||||||
|
<TabContentItem>
|
||||||
|
<StackLayout>
|
||||||
|
<Label text="First View"/>
|
||||||
|
<Button tap="goToSecond" text="go to second" />
|
||||||
|
</StackLayout>
|
||||||
|
</TabContentItem> -->
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
<!-- =============================================================================================== -->
|
||||||
|
|
||||||
|
<!-- Bottom Bar with TabStrip -->
|
||||||
|
<!-- <BottomNavigationBar>
|
||||||
|
<TabStrip>
|
||||||
|
<TabStripItem title="First Tab" iconSource="res://icon"></TabStripItem>
|
||||||
|
<TabStripItem>
|
||||||
|
<Image src="res://icon" />
|
||||||
|
<Label text="Second Tab" />
|
||||||
|
</TabStripItem>
|
||||||
|
</TabStrip>
|
||||||
|
</BottomNavigationBar> -->
|
||||||
|
|
||||||
|
<!-- Bottom Bar w/o TabStrip -->
|
||||||
|
<!-- <BottomNavigationBar>
|
||||||
|
<TabStripItem title="First Tab" iconSource="res://icon"></TabStripItem>
|
||||||
|
<TabStripItem>
|
||||||
|
<Image src="res://icon" />
|
||||||
|
<Label text="Second Tab" />
|
||||||
|
</TabStripItem>
|
||||||
|
</BottomNavigationBar> -->
|
||||||
|
</Page>
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<Page loaded="onLoaded">
|
|
||||||
<StackLayout>
|
|
||||||
<Button id="button" text="button"></Button>
|
|
||||||
</StackLayout>
|
|
||||||
</Page>
|
|
||||||
3
tests/app/livesync/button-scss-page.scss
Normal file
3
tests/app/livesync/button-scss-page.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Button {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
Button {
|
|
||||||
color: cyan;
|
|
||||||
}
|
|
||||||
@@ -3,40 +3,57 @@ import * as TKUnit from "../tk-unit";
|
|||||||
|
|
||||||
import * as app from "tns-core-modules/application/application";
|
import * as app from "tns-core-modules/application/application";
|
||||||
import * as frame from "tns-core-modules/ui/frame";
|
import * as frame from "tns-core-modules/ui/frame";
|
||||||
import * as fs from "tns-core-modules/file-system";
|
|
||||||
import { Color } from "tns-core-modules/color";
|
import { Color } from "tns-core-modules/color";
|
||||||
import { createViewFromEntry } from "tns-core-modules/ui/builder";
|
import { createViewFromEntry } from "tns-core-modules/ui/builder";
|
||||||
import { Page } from "tns-core-modules/ui/page";
|
import { Page } from "tns-core-modules/ui/page";
|
||||||
import { Frame } from "tns-core-modules/ui/frame";
|
import { Frame } from "tns-core-modules/ui/frame";
|
||||||
|
|
||||||
const appCssFileName = "/application-page.css";
|
const LIVESYNC_FOLDER = "livesync/";
|
||||||
const appNewCssFileName = "app-new-page.css";
|
|
||||||
const appNewScssFileName = "app-new-sass-page.css";
|
|
||||||
const buttonCssFileName = "/button-page.css";
|
|
||||||
|
|
||||||
const buttonPageModuleName = "livesync/livesync-button-page";
|
const appCssFileName = `${LIVESYNC_FOLDER}application-page.css`;
|
||||||
const buttonHtmlPageFileName = "./livesync/livesync-button-page.html";
|
const appNewCssFileName = `${LIVESYNC_FOLDER}app-new-page.css`;
|
||||||
const buttonXmlPageFileName = "./livesync/livesync-button-page.xml";
|
// `.scss` module registers in webpack as `.css`
|
||||||
const buttonJsPageFileName = "./livesync/livesync-button-page.js";
|
// https://github.com/NativeScript/NativeScript/blob/5.4.2/tns-core-modules/globals/globals.ts#L32-L33
|
||||||
const buttonTsPageFileName = "./livesync/livesync-button-page.ts";
|
const appNewScssFileNameAsCss = `${LIVESYNC_FOLDER}app-new-scss-page.css`;
|
||||||
const buttonScssPageFileName = "./livesync/livesync-button-page.scss";
|
const appNewScssFileName = `${LIVESYNC_FOLDER}app-new-scss-page.scss`;
|
||||||
const labelPageModuleName = "livesync/livesync-label-page";
|
|
||||||
|
const buttonCssModuleName = `${LIVESYNC_FOLDER}button-css-page`;
|
||||||
|
const buttonScssModuleName = `${LIVESYNC_FOLDER}button-scss-page`;
|
||||||
|
const buttonCssFileName = `${LIVESYNC_FOLDER}button-css-page.css`;
|
||||||
|
const buttonScssFileName = `${LIVESYNC_FOLDER}button-scss-page.scss`;
|
||||||
|
|
||||||
|
const buttonPageModuleName = `${LIVESYNC_FOLDER}livesync-button-page`;
|
||||||
|
const buttonHtmlPageFileName = `${LIVESYNC_FOLDER}livesync-button-page.html`;
|
||||||
|
const buttonXmlPageFileName = `${LIVESYNC_FOLDER}livesync-button-page.xml`;
|
||||||
|
const buttonJsPageFileName = `${LIVESYNC_FOLDER}livesync-button-page.js`;
|
||||||
|
const buttonTsPageFileName = `${LIVESYNC_FOLDER}livesync-button-page.ts`;
|
||||||
|
const buttonScssPageFileName = `${LIVESYNC_FOLDER}livesync-button-page.scss`;
|
||||||
|
const labelPageModuleName = `${LIVESYNC_FOLDER}livesync-label-page`;
|
||||||
|
|
||||||
const green = new Color("green");
|
const green = new Color("green");
|
||||||
|
|
||||||
|
export function setUp() {
|
||||||
|
const labelPage = <Page>createViewFromEntry(({ moduleName: labelPageModuleName }));
|
||||||
|
helper.navigate(() => labelPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function tearDown() {
|
||||||
|
app.setCssFileName(appCssFileName);
|
||||||
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_AppStyle_AppNewCss() {
|
export function test_onLiveSync_ModuleContext_AppStyle_AppNewCss() {
|
||||||
_test_onLiveSync_ModuleContext_AppStyle(appNewCssFileName);
|
_test_onLiveSync_ModuleContext_AppStyle(appNewCssFileName, appNewCssFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_AppStyle_AppNewScss() {
|
export function test_onLiveSync_ModuleContext_AppStyle_AppNewScss() {
|
||||||
_test_onLiveSync_ModuleContext_AppStyle(appNewScssFileName);
|
_test_onLiveSync_ModuleContext_AppStyle(appNewScssFileNameAsCss, appNewScssFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_ContextUndefined() {
|
export function test_onLiveSync_ModuleContext_Undefined() {
|
||||||
_test_onLiveSync_ModuleContext({ type: undefined, path: undefined });
|
_test_onLiveSync_ModuleContext({ type: undefined, path: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_ModuleUndefined() {
|
export function test_onLiveSync_ModuleContext_PathUndefined() {
|
||||||
_test_onLiveSync_ModuleContext({ type: "script", path: undefined });
|
_test_onLiveSync_ModuleContext({ type: "script", path: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +66,11 @@ export function test_onLiveSync_ModuleContext_Script_TsFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_Style_CssFile() {
|
export function test_onLiveSync_ModuleContext_Style_CssFile() {
|
||||||
_test_onLiveSync_ModuleContext_TypeStyle({ type: "style", path: fs.knownFolders.currentApp().path + buttonCssFileName });
|
_test_onLiveSync_ModuleContext_TypeStyle(buttonCssModuleName, buttonCssFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_onLiveSync_ModuleContext_Style_ScssFile() {
|
||||||
|
_test_onLiveSync_ModuleContext_TypeStyle(buttonScssModuleName, buttonScssFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_Markup_HtmlFile() {
|
export function test_onLiveSync_ModuleContext_Markup_HtmlFile() {
|
||||||
@@ -60,14 +81,14 @@ export function test_onLiveSync_ModuleContext_Markup_XmlFile() {
|
|||||||
_test_onLiveSync_ModuleReplace({ type: "markup", path: buttonXmlPageFileName });
|
_test_onLiveSync_ModuleReplace({ type: "markup", path: buttonXmlPageFileName });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_Markup_Script_XmlFile() {
|
export function test_onLiveSync_ModuleContext_MarkupXml_ScriptTs_Files() {
|
||||||
_test_onLiveSync_ModuleReplace_Multiple([
|
_test_onLiveSync_ModuleReplace_Multiple([
|
||||||
{ type: "script", path: buttonTsPageFileName },
|
{ type: "script", path: buttonTsPageFileName },
|
||||||
{ type: "markup", path: buttonXmlPageFileName }
|
{ type: "markup", path: buttonXmlPageFileName }
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_Markup_Script_Style_XmlFile() {
|
export function test_onLiveSync_ModuleContext_MarkupXml_ScriptTs_StyleScss_Files() {
|
||||||
_test_onLiveSync_ModuleReplace_Multiple([
|
_test_onLiveSync_ModuleReplace_Multiple([
|
||||||
{ type: "script", path: buttonTsPageFileName },
|
{ type: "script", path: buttonTsPageFileName },
|
||||||
{ type: "markup", path: buttonXmlPageFileName },
|
{ type: "markup", path: buttonXmlPageFileName },
|
||||||
@@ -75,14 +96,14 @@ export function test_onLiveSync_ModuleContext_Markup_Script_Style_XmlFile() {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_Markup_Script_HtmlFile() {
|
export function test_onLiveSync_ModuleContext_MarkupHtml_ScriptTs_Files() {
|
||||||
_test_onLiveSync_ModuleReplace_Multiple([
|
_test_onLiveSync_ModuleReplace_Multiple([
|
||||||
{ type: "script", path: buttonTsPageFileName },
|
{ type: "script", path: buttonTsPageFileName },
|
||||||
{ type: "markup", path: buttonHtmlPageFileName }
|
{ type: "markup", path: buttonHtmlPageFileName }
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_onLiveSync_ModuleContext_Markup_Script_Style_HtmlFile() {
|
export function test_onLiveSync_ModuleContext_MarkupHtml_ScriptTs_StyleScss_Files() {
|
||||||
_test_onLiveSync_ModuleReplace_Multiple([
|
_test_onLiveSync_ModuleReplace_Multiple([
|
||||||
{ type: "script", path: buttonTsPageFileName },
|
{ type: "script", path: buttonTsPageFileName },
|
||||||
{ type: "markup", path: buttonHtmlPageFileName },
|
{ type: "markup", path: buttonHtmlPageFileName },
|
||||||
@@ -90,23 +111,14 @@ export function test_onLiveSync_ModuleContext_Markup_Script_Style_HtmlFile() {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setUp() {
|
function _test_onLiveSync_ModuleContext_AppStyle(appStyleFileName: string, livesyncStyleFileName: string) {
|
||||||
const labelPage = <Page>createViewFromEntry(({ moduleName: labelPageModuleName }));
|
|
||||||
helper.navigate(() => labelPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function tearDown() {
|
|
||||||
app.setCssFileName(fs.knownFolders.currentApp().path + appCssFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _test_onLiveSync_ModuleContext_AppStyle(styleFileName: string) {
|
|
||||||
const pageBeforeNavigation = helper.getCurrentPage();
|
const pageBeforeNavigation = helper.getCurrentPage();
|
||||||
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
||||||
helper.navigateWithHistory(() => buttonPage);
|
helper.navigateWithHistory(() => buttonPage);
|
||||||
|
|
||||||
app.setCssFileName(fs.knownFolders.currentApp().path + "/" + styleFileName);
|
app.setCssFileName(appStyleFileName);
|
||||||
const pageBeforeLiveSync = helper.getCurrentPage();
|
const pageBeforeLiveSync = helper.getCurrentPage();
|
||||||
global.__onLiveSync({ type: "style", path: fs.knownFolders.currentApp().path + "/" + styleFileName });
|
livesync({ type: "style", path: livesyncStyleFileName });
|
||||||
|
|
||||||
const pageAfterLiveSync = helper.getCurrentPage();
|
const pageAfterLiveSync = helper.getCurrentPage();
|
||||||
TKUnit.waitUntilReady(() => pageAfterLiveSync.getViewById("button").style.color.toString() === green.toString());
|
TKUnit.waitUntilReady(() => pageAfterLiveSync.getViewById("button").style.color.toString() === green.toString());
|
||||||
@@ -121,10 +133,10 @@ function _test_onLiveSync_ModuleContext_AppStyle(styleFileName: string) {
|
|||||||
TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!");
|
TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!");
|
||||||
}
|
}
|
||||||
|
|
||||||
function _test_onLiveSync_ModuleContext(context: { type, path }) {
|
function _test_onLiveSync_ModuleContext(context: ModuleContext) {
|
||||||
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
||||||
helper.navigateWithHistory(() => buttonPage);
|
helper.navigateWithHistory(() => buttonPage);
|
||||||
global.__onLiveSync({ type: context.type, path: context.path });
|
livesync({ type: context.type, path: context.path });
|
||||||
|
|
||||||
TKUnit.waitUntilReady(() => !!frame.topmost());
|
TKUnit.waitUntilReady(() => !!frame.topmost());
|
||||||
const topmostFrame = frame.topmost();
|
const topmostFrame = frame.topmost();
|
||||||
@@ -132,12 +144,12 @@ function _test_onLiveSync_ModuleContext(context: { type, path }) {
|
|||||||
TKUnit.assertTrue(topmostFrame.currentPage.getViewById("label").isLoaded);
|
TKUnit.assertTrue(topmostFrame.currentPage.getViewById("label").isLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _test_onLiveSync_ModuleReplace(context: { type, path }) {
|
function _test_onLiveSync_ModuleReplace(context: ModuleContext) {
|
||||||
const pageBeforeNavigation = helper.getCurrentPage();
|
const pageBeforeNavigation = helper.getCurrentPage();
|
||||||
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
||||||
helper.navigateWithHistory(() => buttonPage);
|
helper.navigateWithHistory(() => buttonPage);
|
||||||
|
|
||||||
global.__onLiveSync({ type: context.type, path: context.path });
|
livesync({ type: context.type, path: context.path });
|
||||||
const topmostFrame = frame.topmost();
|
const topmostFrame = frame.topmost();
|
||||||
waitUntilLivesyncComplete(topmostFrame);
|
waitUntilLivesyncComplete(topmostFrame);
|
||||||
TKUnit.assertTrue(topmostFrame.currentPage.getViewById("button").isLoaded, "Button page is NOT loaded!");
|
TKUnit.assertTrue(topmostFrame.currentPage.getViewById("button").isLoaded, "Button page is NOT loaded!");
|
||||||
@@ -151,37 +163,15 @@ function _test_onLiveSync_ModuleReplace(context: { type, path }) {
|
|||||||
TKUnit.assertEqual(pageBeforeNavigation, pageAfterBackNavigation, "Pages are different!");
|
TKUnit.assertEqual(pageBeforeNavigation, pageAfterBackNavigation, "Pages are different!");
|
||||||
}
|
}
|
||||||
|
|
||||||
function _test_onLiveSync_ModuleReplace_Multiple(context: { type: string, path: string }[]) {
|
function _test_onLiveSync_ModuleContext_TypeStyle(styleModuleName: string, livesyncStyleFileName: string) {
|
||||||
const pageBeforeNavigation = helper.getCurrentPage();
|
|
||||||
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
|
||||||
helper.navigateWithHistory(() => buttonPage);
|
|
||||||
|
|
||||||
context.forEach(item => {
|
|
||||||
global.__onLiveSync(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
const topmostFrame = frame.topmost();
|
|
||||||
waitUntilLivesyncComplete(topmostFrame);
|
|
||||||
TKUnit.assertTrue(topmostFrame.currentPage.getViewById("button").isLoaded, "Button page is NOT loaded!");
|
|
||||||
TKUnit.assertEqual(topmostFrame.backStack.length, 1, "Backstack is clean!");
|
|
||||||
TKUnit.assertTrue(topmostFrame.canGoBack(), "Can NOT go back!");
|
|
||||||
|
|
||||||
helper.goBack();
|
|
||||||
const pageAfterBackNavigation = helper.getCurrentPage();
|
|
||||||
TKUnit.assertTrue(topmostFrame.currentPage.getViewById("label").isLoaded, "Label page is NOT loaded!");
|
|
||||||
TKUnit.assertEqual(topmostFrame.backStack.length, 0, "Backstack is NOT clean!");
|
|
||||||
TKUnit.assertEqual(pageBeforeNavigation, pageAfterBackNavigation, "Pages are different!");
|
|
||||||
}
|
|
||||||
|
|
||||||
function _test_onLiveSync_ModuleContext_TypeStyle(context: { type, path }) {
|
|
||||||
const pageBeforeNavigation = helper.getCurrentPage();
|
const pageBeforeNavigation = helper.getCurrentPage();
|
||||||
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
||||||
helper.navigateWithHistory(() => buttonPage);
|
helper.navigateWithHistory(() => buttonPage);
|
||||||
|
|
||||||
const pageBeforeLiveSync = helper.getCurrentPage();
|
const pageBeforeLiveSync = helper.getCurrentPage();
|
||||||
pageBeforeLiveSync._moduleName = "button-page";
|
pageBeforeLiveSync._moduleName = styleModuleName;
|
||||||
|
|
||||||
global.__onLiveSync({ type: context.type, path: context.path });
|
livesync({ type: "style", path: livesyncStyleFileName });
|
||||||
const topmostFrame = frame.topmost();
|
const topmostFrame = frame.topmost();
|
||||||
waitUntilLivesyncComplete(topmostFrame);
|
waitUntilLivesyncComplete(topmostFrame);
|
||||||
|
|
||||||
@@ -197,6 +187,33 @@ function _test_onLiveSync_ModuleContext_TypeStyle(context: { type, path }) {
|
|||||||
TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!");
|
TKUnit.assertTrue(pageAfterNavigationBack._cssState.isSelectorsLatestVersionApplied(), "Latest selectors version is NOT applied!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _test_onLiveSync_ModuleReplace_Multiple(context: ModuleContext[]) {
|
||||||
|
const pageBeforeNavigation = helper.getCurrentPage();
|
||||||
|
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
|
||||||
|
helper.navigateWithHistory(() => buttonPage);
|
||||||
|
|
||||||
|
context.forEach(item => {
|
||||||
|
livesync(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
const topmostFrame = frame.topmost();
|
||||||
|
waitUntilLivesyncComplete(topmostFrame);
|
||||||
|
TKUnit.assertTrue(topmostFrame.currentPage.getViewById("button").isLoaded, "Button page is NOT loaded!");
|
||||||
|
TKUnit.assertEqual(topmostFrame.backStack.length, 1, "Backstack is clean!");
|
||||||
|
TKUnit.assertTrue(topmostFrame.canGoBack(), "Can NOT go back!");
|
||||||
|
|
||||||
|
helper.goBack();
|
||||||
|
const pageAfterBackNavigation = helper.getCurrentPage();
|
||||||
|
TKUnit.assertTrue(topmostFrame.currentPage.getViewById("label").isLoaded, "Label page is NOT loaded!");
|
||||||
|
TKUnit.assertEqual(topmostFrame.backStack.length, 0, "Backstack is NOT clean!");
|
||||||
|
TKUnit.assertEqual(pageBeforeNavigation, pageAfterBackNavigation, "Pages are different!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function livesync(context: ModuleContext) {
|
||||||
|
const ls = (<any>global).__hmrSyncBackup || global.__onLiveSync;
|
||||||
|
ls(context);
|
||||||
|
}
|
||||||
|
|
||||||
function waitUntilLivesyncComplete(frame: Frame) {
|
function waitUntilLivesyncComplete(frame: Frame) {
|
||||||
TKUnit.waitUntilReady(() => frame.navigationQueueIsEmpty());
|
TKUnit.waitUntilReady(() => frame.navigationQueueIsEmpty());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,9 +280,8 @@ allTests["SEARCH-BAR"] = searchBarTests;
|
|||||||
import * as navigationTests from "./navigation/navigation-tests";
|
import * as navigationTests from "./navigation/navigation-tests";
|
||||||
allTests["NAVIGATION"] = navigationTests;
|
allTests["NAVIGATION"] = navigationTests;
|
||||||
|
|
||||||
// TODO: These test should be run with --no-hrm
|
import * as livesyncTests from "./livesync/livesync-tests";
|
||||||
// import * as livesyncTests from "./livesync/livesync-tests";
|
allTests["LIVESYNC"] = livesyncTests;
|
||||||
// allTests["LIVESYNC"] = livesyncTests;
|
|
||||||
|
|
||||||
import * as tabViewRootTests from "./ui/tab-view/tab-view-root-tests";
|
import * as tabViewRootTests from "./ui/tab-view/tab-view-root-tests";
|
||||||
allTests["TAB-VIEW-ROOT"] = tabViewRootTests;
|
allTests["TAB-VIEW-ROOT"] = tabViewRootTests;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"version": "next"
|
"version": "next"
|
||||||
},
|
},
|
||||||
"tns-ios": {
|
"tns-ios": {
|
||||||
"version": "6.0.0-2019-06-13-141312-01"
|
"version": "next"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { TabContentItem } from "../tab-navigation-base/tab-content-item";
|
|||||||
|
|
||||||
// Requires
|
// Requires
|
||||||
import { TabNavigationBase, itemsProperty, selectedIndexProperty, tabStripProperty } from "../tab-navigation-base/tab-navigation-base";
|
import { TabNavigationBase, itemsProperty, selectedIndexProperty, tabStripProperty } from "../tab-navigation-base/tab-navigation-base";
|
||||||
import { CSSType } from "../core/view";
|
import { CSSType, Color } from "../core/view";
|
||||||
import { Frame } from "../frame";
|
import { Frame } from "../frame";
|
||||||
import { RESOURCE_PREFIX, ad, layout } from "../../utils/utils";
|
import { RESOURCE_PREFIX, ad, layout } from "../../utils/utils";
|
||||||
import { fromFileOrResource } from "../../image-source";
|
import { fromFileOrResource } from "../../image-source";
|
||||||
@@ -352,6 +352,11 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._bottomNavigationBar.setItems(tabItems);
|
this._bottomNavigationBar.setItems(tabItems);
|
||||||
|
this.tabStrip.setNativeView(this._bottomNavigationBar);
|
||||||
|
this.tabStrip.items.forEach((item, i, arr) => {
|
||||||
|
const tv = this._bottomNavigationBar.getTextViewForItemAt(i);
|
||||||
|
item.setNativeView(tv);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,6 +364,18 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
this._bottomNavigationBar.updateItemAt(index, spec);
|
this._bottomNavigationBar.updateItemAt(index, spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getTabBarBackgroundColor(): android.graphics.drawable.Drawable {
|
||||||
|
return this._bottomNavigationBar.getBackground();
|
||||||
|
}
|
||||||
|
|
||||||
|
public setTabBarBackgroundColor(value: android.graphics.drawable.Drawable | Color): void {
|
||||||
|
if (value instanceof Color) {
|
||||||
|
this._bottomNavigationBar.setBackgroundColor(value.android);
|
||||||
|
} else {
|
||||||
|
this._bottomNavigationBar.setBackground(tryCloneDrawable(value, this.nativeViewProtected.getResources));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[selectedIndexProperty.setNative](value: number) {
|
[selectedIndexProperty.setNative](value: number) {
|
||||||
// const smoothScroll = false;
|
// const smoothScroll = false;
|
||||||
|
|
||||||
@@ -383,3 +400,14 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
this.setAdapterItems([]);
|
this.setAdapterItems([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tryCloneDrawable(value: android.graphics.drawable.Drawable, resources: android.content.res.Resources): android.graphics.drawable.Drawable {
|
||||||
|
if (value) {
|
||||||
|
const constantState = value.getConstantState();
|
||||||
|
if (constantState) {
|
||||||
|
return constantState.newDrawable(resources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|||||||
@@ -277,6 +277,14 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
super.onSelectedIndexChanged(oldIndex, newIndex);
|
super.onSelectedIndexChanged(oldIndex, newIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getTabBarBackgroundColor(): UIColor {
|
||||||
|
return this._ios.tabBar.barTintColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setTabBarBackgroundColor(value: UIColor | Color): void {
|
||||||
|
this._ios.tabBar.barTintColor = value instanceof Color ? value.ios : value;
|
||||||
|
}
|
||||||
|
|
||||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||||
const width = layout.getMeasureSpecSize(widthMeasureSpec);
|
const width = layout.getMeasureSpecSize(widthMeasureSpec);
|
||||||
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
|
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
|
||||||
@@ -384,6 +392,10 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
const controllers = NSMutableArray.alloc<UIViewController>().initWithCapacity(length);
|
const controllers = NSMutableArray.alloc<UIViewController>().initWithCapacity(length);
|
||||||
const states = getTitleAttributesForStates(this);
|
const states = getTitleAttributesForStates(this);
|
||||||
|
|
||||||
|
if (this.tabStrip) {
|
||||||
|
this.tabStrip.setNativeView(this._ios.tabBar);
|
||||||
|
}
|
||||||
|
|
||||||
items.forEach((item, i) => {
|
items.forEach((item, i) => {
|
||||||
const controller = this.getViewController(item);
|
const controller = this.getViewController(item);
|
||||||
|
|
||||||
@@ -401,6 +413,7 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
applyStatesToItem(tabBarItem, states);
|
applyStatesToItem(tabBarItem, states);
|
||||||
|
|
||||||
controller.tabBarItem = tabBarItem;
|
controller.tabBarItem = tabBarItem;
|
||||||
|
tabStripItem.setNativeView(tabBarItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
controllers.addObject(controller);
|
controllers.addObject(controller);
|
||||||
|
|||||||
@@ -82,6 +82,18 @@ export class TabNavigationBase extends View {
|
|||||||
* Method is intended to be overridden by inheritors and used as "protected"
|
* Method is intended to be overridden by inheritors and used as "protected"
|
||||||
*/
|
*/
|
||||||
onSelectedIndexChanged(oldIndex: number, newIndex: number): void;
|
onSelectedIndexChanged(oldIndex: number, newIndex: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* Method is intended to be overridden by inheritors and used as "protected"
|
||||||
|
*/
|
||||||
|
getTabBarBackgroundColor(): any
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* Method is intended to be overridden by inheritors and used as "protected"
|
||||||
|
*/
|
||||||
|
setTabBarBackgroundColor(value: any): void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const itemsProperty: Property<TabNavigationBase, TabContentItem[]>;
|
export const itemsProperty: Property<TabNavigationBase, TabContentItem[]>;
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
|
|||||||
}
|
}
|
||||||
this.items.push(<TabContentItem>value);
|
this.items.push(<TabContentItem>value);
|
||||||
this._addView(value);
|
this._addView(value);
|
||||||
selectedIndexProperty.coerce(this);
|
// selectedIndexProperty.coerce(this);
|
||||||
} else if (name === "TabStrip") {
|
} else if (name === "TabStrip") {
|
||||||
this.tabStrip = value;
|
this.tabStrip = value;
|
||||||
|
this._addView(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +60,11 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
|
|||||||
callback(item);
|
callback(item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tabStrip = this.tabStrip;
|
||||||
|
if (tabStrip) {
|
||||||
|
callback(tabStrip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public eachChildView(callback: (child: View) => boolean) {
|
public eachChildView(callback: (child: View) => boolean) {
|
||||||
@@ -102,6 +108,15 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
|
|||||||
// to be overridden in platform specific files
|
// to be overridden in platform specific files
|
||||||
this.notify(<SelectedIndexChangedEventData>{ eventName: TabNavigationBase.selectedIndexChangedEvent, object: this, oldIndex, newIndex });
|
this.notify(<SelectedIndexChangedEventData>{ eventName: TabNavigationBase.selectedIndexChangedEvent, object: this, oldIndex, newIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getTabBarBackgroundColor(): any {
|
||||||
|
// overridden by inheritors
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setTabBarBackgroundColor(value: any): void {
|
||||||
|
// overridden by inheritors
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TabNavigationBase {
|
export interface TabNavigationBase {
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
* @module "ui/tab-navigation/tab-strip"
|
* @module "ui/tab-navigation/tab-strip"
|
||||||
*/ /** */
|
*/ /** */
|
||||||
|
|
||||||
import { ViewBase, Property } from "../../core/view";
|
import { View, Property } from "../../core/view";
|
||||||
|
import { Color } from "../../../color";
|
||||||
import { TabStripItem } from "../tab-strip-item";
|
import { TabStripItem } from "../tab-strip-item";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a tab strip.
|
* Represents a tab strip.
|
||||||
*/
|
*/
|
||||||
export class TabStrip extends ViewBase {
|
export class TabStrip extends View {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or sets the items of the tab strip.
|
* Gets or sets the items of the tab strip.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
// Types
|
// Types
|
||||||
import { TabStrip as TabStripDefinition } from ".";
|
import { TabStrip as TabStripDefinition } from ".";
|
||||||
import { TabStripItem } from "../tab-strip-item";
|
import { TabStripItem } from "../tab-strip-item";
|
||||||
|
import { TabNavigationBase } from "../tab-navigation-base";
|
||||||
|
import { Color } from "../../../color";
|
||||||
import { AddArrayFromBuilder, AddChildFromBuilder } from "../../core/view";
|
import { AddArrayFromBuilder, AddChildFromBuilder } from "../../core/view";
|
||||||
|
|
||||||
// Requires
|
// Requires
|
||||||
import { ViewBase, Property, CSSType } from "../../core/view";
|
import { View, Property, CSSType, backgroundColorProperty, backgroundInternalProperty } from "../../core/view";
|
||||||
|
|
||||||
export const traceCategory = "TabView";
|
export const traceCategory = "TabView";
|
||||||
|
|
||||||
@CSSType("TabStrip")
|
@CSSType("TabStrip")
|
||||||
export class TabStrip extends ViewBase implements TabStripDefinition, AddChildFromBuilder, AddArrayFromBuilder {
|
export class TabStrip extends View implements TabStripDefinition, AddChildFromBuilder, AddArrayFromBuilder {
|
||||||
public items: TabStripItem[];
|
public items: TabStripItem[];
|
||||||
public iosIconRenderingMode: "automatic" | "alwaysOriginal" | "alwaysTemplate";
|
public iosIconRenderingMode: "automatic" | "alwaysOriginal" | "alwaysTemplate";
|
||||||
|
|
||||||
@@ -29,6 +31,24 @@ export class TabStrip extends ViewBase implements TabStripDefinition, AddChildFr
|
|||||||
// selectedIndexProperty.coerce(this);
|
// selectedIndexProperty.coerce(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[backgroundColorProperty.getDefault](): Color {
|
||||||
|
const parent = <TabNavigationBase>this.parent;
|
||||||
|
|
||||||
|
return parent && parent.getTabBarBackgroundColor();
|
||||||
|
}
|
||||||
|
[backgroundColorProperty.setNative](value: Color) {
|
||||||
|
const parent = <TabNavigationBase>this.parent;
|
||||||
|
|
||||||
|
return parent && parent.setTabBarBackgroundColor(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[backgroundInternalProperty.getDefault](): any {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
[backgroundInternalProperty.setNative](value: any) {
|
||||||
|
// disable the background CSS properties
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const iosIconRenderingModeProperty = new Property<TabStrip, "automatic" | "alwaysOriginal" | "alwaysTemplate">({ name: "iosIconRenderingMode", defaultValue: "automatic" });
|
export const iosIconRenderingModeProperty = new Property<TabStrip, "automatic" | "alwaysOriginal" | "alwaysTemplate">({ name: "iosIconRenderingMode", defaultValue: "automatic" });
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { TabStripItem } from "../tab-navigation-base/tab-strip-item";
|
|||||||
import { selectedIndexProperty, itemsProperty, tabStripProperty } from "../tab-navigation-base/tab-navigation-base";
|
import { selectedIndexProperty, itemsProperty, tabStripProperty } from "../tab-navigation-base/tab-navigation-base";
|
||||||
import { TabsBase, swipeEnabledProperty, offscreenTabLimitProperty } from "./tabs-common";
|
import { TabsBase, swipeEnabledProperty, offscreenTabLimitProperty } from "./tabs-common";
|
||||||
import { Frame } from "../frame";
|
import { Frame } from "../frame";
|
||||||
|
import { Color } from "../core/view";
|
||||||
import { fromFileOrResource } from "../../image-source";
|
import { fromFileOrResource } from "../../image-source";
|
||||||
import { RESOURCE_PREFIX, ad, layout } from "../../utils/utils";
|
import { RESOURCE_PREFIX, ad, layout } from "../../utils/utils";
|
||||||
import * as application from "../../application";
|
import * as application from "../../application";
|
||||||
@@ -529,6 +530,7 @@ export class Tabs extends TabsBase {
|
|||||||
|
|
||||||
const tabLayout = this._tabLayout;
|
const tabLayout = this._tabLayout;
|
||||||
tabLayout.setItems(tabItems, this._viewPager);
|
tabLayout.setItems(tabItems, this._viewPager);
|
||||||
|
this.tabStrip.setNativeView(tabLayout);
|
||||||
items.forEach((item, i, arr) => {
|
items.forEach((item, i, arr) => {
|
||||||
const tv = tabLayout.getTextViewForItemAt(i);
|
const tv = tabLayout.getTextViewForItemAt(i);
|
||||||
item.setNativeView(tv);
|
item.setNativeView(tv);
|
||||||
@@ -569,6 +571,18 @@ export class Tabs extends TabsBase {
|
|||||||
this._tabLayout.updateItemAt(index, spec);
|
this._tabLayout.updateItemAt(index, spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getTabBarBackgroundColor(): android.graphics.drawable.Drawable {
|
||||||
|
return this._tabLayout.getBackground();
|
||||||
|
}
|
||||||
|
|
||||||
|
public setTabBarBackgroundColor(value: android.graphics.drawable.Drawable | Color): void {
|
||||||
|
if (value instanceof Color) {
|
||||||
|
this._tabLayout.setBackgroundColor(value.android);
|
||||||
|
} else {
|
||||||
|
this._tabLayout.setBackground(tryCloneDrawable(value, this.nativeViewProtected.getResources));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[selectedIndexProperty.setNative](value: number) {
|
[selectedIndexProperty.setNative](value: number) {
|
||||||
const smoothScroll = true;
|
const smoothScroll = true;
|
||||||
|
|
||||||
@@ -610,3 +624,14 @@ export class Tabs extends TabsBase {
|
|||||||
this._viewPager.setOffscreenPageLimit(value);
|
this._viewPager.setOffscreenPageLimit(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tryCloneDrawable(value: android.graphics.drawable.Drawable, resources: android.content.res.Resources): android.graphics.drawable.Drawable {
|
||||||
|
if (value) {
|
||||||
|
const constantState = value.getConstantState();
|
||||||
|
if (constantState) {
|
||||||
|
return constantState.newDrawable(resources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { selectedIndexProperty, itemsProperty, tabStripProperty } from "../tab-n
|
|||||||
import { TabsBase, swipeEnabledProperty } from "./tabs-common";
|
import { TabsBase, swipeEnabledProperty } from "./tabs-common";
|
||||||
import { Frame } from "../frame";
|
import { Frame } from "../frame";
|
||||||
import { ios as iosView, View } from "../core/view";
|
import { ios as iosView, View } from "../core/view";
|
||||||
|
import { Color } from "../../color";
|
||||||
import { /*ios as iosUtils,*/ layout } from "../../utils/utils";
|
import { /*ios as iosUtils,*/ layout } from "../../utils/utils";
|
||||||
// import { device } from "../../platform";
|
// import { device } from "../../platform";
|
||||||
import { fromFileOrResource } from "../../image-source";
|
import { fromFileOrResource } from "../../image-source";
|
||||||
@@ -845,11 +846,13 @@ export class Tabs extends TabsBase {
|
|||||||
items.forEach((item: TabStripItem, i, arr) => {
|
items.forEach((item: TabStripItem, i, arr) => {
|
||||||
const tabBarItem = UITabBarItem.alloc().initWithTitleImageTag(item.title, null, 0);
|
const tabBarItem = UITabBarItem.alloc().initWithTitleImageTag(item.title, null, 0);
|
||||||
tabBarItems.push(tabBarItem);
|
tabBarItems.push(tabBarItem);
|
||||||
|
item.setNativeView(tabBarItem);
|
||||||
});
|
});
|
||||||
this.tabBarItems = tabBarItems;
|
this.tabBarItems = tabBarItems;
|
||||||
|
|
||||||
if (this.viewController && this.viewController.tabBar) {
|
if (this.viewController && this.viewController.tabBar) {
|
||||||
this.viewController.tabBar.items = NSArray.arrayWithArray(tabBarItems);
|
this.viewController.tabBar.items = NSArray.arrayWithArray(tabBarItems);
|
||||||
|
this.tabStrip.setNativeView(this.viewController.tabBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// tabBar.items = <NSArray<UITabBarItem>>NSArray.alloc().initWithArray([
|
// tabBar.items = <NSArray<UITabBarItem>>NSArray.alloc().initWithArray([
|
||||||
@@ -934,6 +937,14 @@ export class Tabs extends TabsBase {
|
|||||||
// this._updateIOSTabBarColorsAndFonts();
|
// this._updateIOSTabBarColorsAndFonts();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public getTabBarBackgroundColor(): UIColor {
|
||||||
|
return this._ios.tabBar.barTintColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setTabBarBackgroundColor(value: UIColor | Color): void {
|
||||||
|
this._ios.tabBar.barTintColor = value instanceof Color ? value.ios : value;
|
||||||
|
}
|
||||||
|
|
||||||
[selectedIndexProperty.setNative](value: number) {
|
[selectedIndexProperty.setNative](value: number) {
|
||||||
// TODO
|
// TODO
|
||||||
// if (traceEnabled()) {
|
// if (traceEnabled()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user