Skip to content

Commit 4483059

Browse files
authored
feat(tab): migrate template to use BottomNavigation component (#79)
1 parent 8a34758 commit 4483059

File tree

88 files changed

+246
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+246
-99
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

packages/template-tab-navigation-ng/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
"nativescript-theme-core": "~1.0.6",
5454
"reflect-metadata": "~0.1.12",
5555
"rxjs": "^6.4.0",
56-
"tns-core-modules": "~6.0.0",
56+
"tns-core-modules": "next",
5757
"zone.js": "~0.9.1"
5858
},
5959
"devDependencies": {
6060
"@angular/compiler-cli": "~8.2.0",
6161
"@ngtools/webpack": "~8.2.0",
6262
"codelyzer": "~4.5.0",
63-
"nativescript-dev-webpack": "~1.1.0",
63+
"nativescript-dev-webpack": "next",
6464
"node-sass": "^4.7.1",
6565
"tslint": "~5.11.0",
6666
"typescript": "~3.5.3"
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
@import 'app.component';
22

33
// Place any CSS rules you want to apply only on Android here
4-
TabView {
5-
tab-text-color: $blue-dark;
6-
selected-tab-text-color: $item-active-color;
7-
}
4+
TabStripItem Label {
5+
color: $blue-dark;
6+
text-transform: uppercase;
7+
font-weight: bold;
8+
}
9+
10+
TabStripItem:active Label {
11+
color: $item-active-color;
12+
}
13+
14+
TabStripItem Image {
15+
color: $blue-dark;
16+
}
17+
18+
TabStripItem:active Image {
19+
color: $item-active-color;
20+
}
Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
1-
<TabView androidTabsPosition="bottom">
1+
<BottomNavigation>
2+
<TabStrip>
3+
<!--
4+
Besides the approach demonstrated below there is alternative shorthand syntax for setting TabStripItem title and icon:
25
3-
<page-router-outlet
4-
*tabItem="{title: 'Home', iconSource: getIconSource('home')}"
5-
name="homeTab">
6-
</page-router-outlet>
6+
<TabStripItem title="Home" iconSource="res://tabIcons/home" />
77
8-
<page-router-outlet
9-
*tabItem="{title: 'Browse', iconSource: getIconSource('browse')}"
10-
name="browseTab">
11-
</page-router-outlet>
8+
Both shorthand and verbose syntax can use
9+
TabStripItem Label {...} css selector to style the title label,
10+
and TabStriptItem Image {...} css selector to style the icon image (see _app-common.scss).
11+
Note that when working with font icons we recommend the usage of the verbose syntax as it
12+
is explicit and describes better the need to provide font icon as well as set the respective font (e.g. via class name).
13+
-->
14+
<TabStripItem>
15+
<!--
16+
Note TabStripItem will only accept single Label and/or single Image elements that it
17+
will "adopt"; any other layout elements you try to specify will be ignored
18+
-->
19+
<Label text="Home"></Label>
20+
<Image src="font://&#xf015;" class="fa"></Image>
21+
</TabStripItem>
22+
<TabStripItem>
23+
<Label text="Browse"></Label>
24+
<Image src="font://&#xf1ea;" class="fa"></Image>
25+
</TabStripItem>
26+
<TabStripItem>
27+
<Label text="Search"></Label>
28+
<Image src="font://&#xf002;" class="fa"></Image>
29+
</TabStripItem>
30+
</TabStrip>
1231

13-
<page-router-outlet
14-
*tabItem="{title: 'Search', iconSource: getIconSource('search')}"
15-
name="searchTab">
16-
</page-router-outlet>
32+
<TabContentItem>
33+
<page-router-outlet name="homeTab"></page-router-outlet>
34+
</TabContentItem>
1735

18-
</TabView>
36+
<TabContentItem>
37+
<page-router-outlet name="browseTab"></page-router-outlet>
38+
</TabContentItem>
39+
40+
<TabContentItem>
41+
<page-router-outlet name="searchTab"></page-router-outlet>
42+
</TabContentItem>
43+
</BottomNavigation>
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
@import 'app.component';
22

33
// Place any CSS rules you want to apply only on IOS here
4-
TabView {
5-
selected-tab-text-color: $item-active-color;
6-
}
4+
TabStripItem Label {
5+
color: $blue-dark;
6+
}
7+
8+
TabStripItem:active Label {
9+
color: $item-active-color;
10+
}
11+
12+
TabStripItem Image {
13+
color: $blue-dark;
14+
}
15+
16+
TabStripItem:active Image {
17+
color: $item-active-color;
18+
}

packages/template-tab-navigation-ng/src/app/app.component.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,4 @@ export class AppComponent implements OnInit {
1515
ngOnInit(): void {
1616
// Init your component properties here.
1717
}
18-
19-
getIconSource(icon: string): string {
20-
const iconPrefix = isAndroid ? "res://" : "res://tabIcons/";
21-
22-
return iconPrefix + icon;
23-
}
2418
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

packages/template-tab-navigation-ts/app/_app-common.scss

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,20 @@
2525
//Action bar
2626
ActionBar .action-bar-title {
2727
horizontal-align: center;
28-
}
28+
}
29+
30+
TabStripItem Label {
31+
color: $blue-dark;
32+
}
33+
34+
TabStripItem:active Label {
35+
color: $item-active-color;
36+
}
37+
38+
TabStripItem Image {
39+
color: $blue-dark;
40+
}
41+
42+
TabStripItem:active Image {
43+
color: $item-active-color;
44+
}
Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,51 @@
11
<!--
2-
The TabView component provides a simple way to navigate between different views by
3-
tapping on some of the tabs or by swiping between the views.
4-
Learn more about the TabView component in this documentation article:
5-
http://docs.nativescript.org/cookbook/ui/tab-view
2+
The BottomNavigation component provides a way for high level navigation between different views by
3+
tapping on some of the tabs. Learn more about the BottomNavigation component
4+
in this documentation article: https://docs.nativescript.org/ui/ns-ui-widgets/bottom-navigation.
5+
Tabs component is similar to BottomNavigation but suitable for mid level navigation scenarios thus
6+
supports swiping between the views. Learn more about the Tabs component in this documentation article:
7+
https://docs.nativescript.org/angular/ui/ng-ui-widgets/tabs.
68
-->
7-
<TabView androidTabsPosition="bottom">
8-
<TabViewItem title="Home" ios:iconSource="res://tabIcons/home" android:iconSource="res://home">
9-
<Frame defaultPage="home/home-items-page"></Frame>
10-
</TabViewItem>
9+
<BottomNavigation>
10+
<TabStrip>
11+
<!--
12+
Besides the approach demonstrated below there is alternative shorthand syntax for setting TabStripItem title and icon:
1113
12-
<TabViewItem title="Browse" ios:iconSource="res://tabIcons/browse" android:iconSource="res://browse">
13-
<Frame defaultPage="browse/browse-page"></Frame>
14-
</TabViewItem>
14+
<TabStripItem title="Home" iconSource="res://tabIcons/home" />
1515
16-
<TabViewItem title="Search" ios:iconSource="res://tabIcons/search" android:iconSource="res://search">
17-
<Frame defaultPage="search/search-page"></Frame>
18-
</TabViewItem>
19-
</TabView>
16+
Both shorthand and verbose syntax can use
17+
TabStripItem Label {...} css selector to style the title label,
18+
and TabStriptItem Image {...} css selector to style the icon image (see _app-common.scss).
19+
Note that when working with font icons we recommend the usage of the verbose syntax as it
20+
is explicit and describes better the need to provide font icon as well as set the respective font (e.g. via class name).
21+
-->
22+
<TabStripItem>
23+
<!--
24+
Note TabStripItem will only accept single Label and/or single Image elements that it
25+
will "adopt"; any other layout elements you try to specify will be ignored
26+
-->
27+
<Label text="Home" />
28+
<Image src="font://&#xf015;" class="fa" />
29+
</TabStripItem>
30+
<TabStripItem>
31+
<Label text="Browse" />
32+
<Image src="font://&#xf1ea;" class="fa" />
33+
</TabStripItem>
34+
<TabStripItem>
35+
<Label text="Search" />
36+
<Image src="font://&#xf002;" class="fa" />
37+
</TabStripItem>
38+
</TabStrip>
39+
40+
<TabContentItem>
41+
<Frame defaultPage="home/home-items-page" />
42+
</TabContentItem>
43+
44+
<TabContentItem>
45+
<Frame defaultPage="browse/browse-page" />
46+
</TabContentItem>
47+
48+
<TabContentItem>
49+
<Frame defaultPage="search/search-page" />
50+
</TabContentItem>
51+
</BottomNavigation>

packages/template-tab-navigation-ts/app/app.android.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
@import 'app-common';
1010

1111
// Place any CSS rules you want to apply only on Android here
12-
TabView {
13-
tab-text-color: $blue-dark;
14-
selected-tab-text-color: $item-active-color;
12+
TabStripItem Label {
13+
text-transform: uppercase;
14+
font-weight: bold;
1515
}
1616

17-

packages/template-tab-navigation-ts/app/app.ios.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@
99
@import 'app-common';
1010

1111
// Place any CSS rules you want to apply only on iOS here
12-
TabView {
13-
selected-tab-text-color: $item-active-color;
14-
}

packages/template-tab-navigation-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"dependencies": {
4343
"nativescript-theme-core": "~1.0.6",
44-
"tns-core-modules": "~6.0.0"
44+
"tns-core-modules": "next"
4545
},
4646
"devDependencies": {
4747
"nativescript-dev-webpack": "~1.1.0",
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

packages/template-tab-navigation/app/_app-common.scss

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,43 @@
22
// This is where the vast majority of your CSS code goes.
33
// Font icon class
44
.fa {
5-
font-family: "FontAwesome";
6-
}
7-
// Common page class
8-
.page-content {
9-
.page-placeholder {
10-
color: $page-icon-color;
11-
font-size: $page-content-placeholder-font-size;
12-
vertical-align: center;
13-
horizontal-align: center;
14-
}
5+
font-family: "FontAwesome";
6+
}
7+
// Common page class
8+
.page-content {
9+
.page-placeholder {
10+
color: $page-icon-color;
11+
font-size: $page-content-placeholder-font-size;
12+
vertical-align: center;
13+
horizontal-align: center;
14+
}
1515

16-
.page-icon {
17-
font-size: 72;
18-
vertical-align: top;
19-
horizontal-align: center;
20-
color: $page-icon-color;
21-
margin-top: 20%;
22-
}
23-
}
16+
.page-icon {
17+
font-size: 72;
18+
vertical-align: top;
19+
horizontal-align: center;
20+
color: $page-icon-color;
21+
margin-top: 20%;
22+
}
23+
}
2424

25-
//Action bar
26-
ActionBar .action-bar-title {
27-
horizontal-align: center;
28-
}
25+
//Action bar
26+
ActionBar .action-bar-title {
27+
horizontal-align: center;
28+
}
29+
30+
TabStripItem Label {
31+
color: $blue-dark;
32+
}
33+
34+
TabStripItem:active Label {
35+
color: $item-active-color;
36+
}
37+
38+
TabStripItem Image {
39+
color: $blue-dark;
40+
}
41+
42+
TabStripItem:active Image {
43+
color: $item-active-color;
44+
}
Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,51 @@
11
<!--
2-
The TabView component provides a simple way to navigate between different views by
3-
tapping on some of the tabs or by swiping between the views.
4-
Learn more about the TabView component in this documentation article:
5-
http://docs.nativescript.org/cookbook/ui/tab-view
2+
The BottomNavigation component provides a way for high level navigation between different views by
3+
tapping on some of the tabs. Learn more about the BottomNavigation component
4+
in this documentation article: https://docs.nativescript.org/ui/ns-ui-widgets/bottom-navigation.
5+
Tabs component is similar to BottomNavigation but suitable for mid level navigation scenarios thus
6+
supports swiping between the views. Learn more about the Tabs component in this documentation article:
7+
https://docs.nativescript.org/angular/ui/ng-ui-widgets/tabs.
68
-->
7-
<TabView androidTabsPosition="bottom">
8-
<TabViewItem title="Home" ios:iconSource="res://tabIcons/home" android:iconSource="res://home">
9-
<Frame defaultPage="home/home-items-page"></Frame>
10-
</TabViewItem>
9+
<BottomNavigation>
10+
<TabStrip>
11+
<!--
12+
Besides the approach demonstrated below there is alternative shorthand syntax for setting TabStripItem title and icon:
1113
12-
<TabViewItem title="Browse" ios:iconSource="res://tabIcons/browse" android:iconSource="res://browse">
13-
<Frame defaultPage="browse/browse-page"></Frame>
14-
</TabViewItem>
14+
<TabStripItem title="Home" iconSource="res://tabIcons/home" />
1515
16-
<TabViewItem title="Search" ios:iconSource="res://tabIcons/search" android:iconSource="res://search">
17-
<Frame defaultPage="search/search-page"></Frame>
18-
</TabViewItem>
19-
</TabView>
16+
Both shorthand and verbose syntax can use
17+
TabStripItem Label {...} css selector to style the title label,
18+
and TabStriptItem Image {...} css selector to style the icon image (see _app-common.scss).
19+
Note that when working with font icons we recommend the usage of the verbose syntax as it
20+
is explicit and describes better the need to provide font icon as well as set the respective font (e.g. via class name).
21+
-->
22+
<TabStripItem>
23+
<!--
24+
Note TabStripItem will only accept single Label and/or single Image elements that it
25+
will "adopt"; any other layout elements you try to specify will be ignored
26+
-->
27+
<Label text="Home" />
28+
<Image src="font://&#xf015;" class="fa" />
29+
</TabStripItem>
30+
<TabStripItem>
31+
<Label text="Browse" />
32+
<Image src="font://&#xf1ea;" class="fa" />
33+
</TabStripItem>
34+
<TabStripItem>
35+
<Label text="Search" />
36+
<Image src="font://&#xf002;" class="fa" />
37+
</TabStripItem>
38+
</TabStrip>
39+
40+
<TabContentItem>
41+
<Frame defaultPage="home/home-items-page" />
42+
</TabContentItem>
43+
44+
<TabContentItem>
45+
<Frame defaultPage="browse/browse-page" />
46+
</TabContentItem>
47+
48+
<TabContentItem>
49+
<Frame defaultPage="search/search-page" />
50+
</TabContentItem>
51+
</BottomNavigation>

0 commit comments

Comments
 (0)