Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [6.5.1](https://github.com/NativeScript/NativeScript/compare/6.5.0...6.5.1) (2020-03-30)


### Bug Fixes

* **tabs:** dynamic styling colors fixed ([#8460](https://github.com/NativeScript/NativeScript/issues/8460)) ([0a7bee6](https://github.com/NativeScript/NativeScript/commit/0a7bee6))



# [6.5.0](https://github.com/NativeScript/NativeScript/compare/6.4.2...6.5.0) (2020-03-18)


Expand Down
2 changes: 2 additions & 0 deletions api-reports/NativeScript.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,8 @@ export class TabNavigationBase extends View {

setTabBarIconColor(tabStripItem: TabStripItem, value: any): void

setTabBarIconSource(tabStripItem: TabStripItem, value: any): void

setTabBarItemBackgroundColor(tabStripItem: TabStripItem, value: any): void

setTabBarItemColor(tabStripItem: TabStripItem, value: any): void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.font-awesome {
font-family: "FontAwesome";
}

.font-size {
font-size: 36;
}

TabStripItem:active {
background-color: magenta;
}

.tabsClass0 {
}

.tabsClass1 {
background-color: #79d2a6;
highlight-color: green;
selected-item-color: yellow;
un-selected-item-color: blue;
}

.tabsClass2 {
background-color: orangered;
highlight-color: lightgreen;
selected-item-color: whitesmoke;
un-selected-item-color: pink;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { View } from "tns-core-modules/ui/core/view";
import { Page } from "tns-core-modules/ui/page";
import { BottomNavigation } from "tns-core-modules/ui/bottom-navigation";

export function onButtonTap(args) {
const page = <Page>(<View>args.object).page;
const bottomNavigation = <BottomNavigation>(page.getViewById("bottomNavigation"));

switch (bottomNavigation.tabStrip.className) {
case "tabsClass0":
bottomNavigation.tabStrip.className = "tabsClass1";
break;
case "tabsClass1":
bottomNavigation.tabStrip.className = "tabsClass2";
break;
case "tabsClass2":
bottomNavigation.tabStrip.className = "tabsClass0";
break;
}
}

export function onChangeIconSourceTap(args) {
const page = <Page>(<View>args.object).page;
const bottomNavigation = <BottomNavigation>(page.getViewById("bottomNavigation"));

const tabStripItem0 = bottomNavigation.tabStrip.items[0];
const tabStripItem1 = bottomNavigation.tabStrip.items[1];
const tabStripItem2 = bottomNavigation.tabStrip.items[2];

const iconSource0 = tabStripItem0.iconSource;

tabStripItem0.iconSource = tabStripItem1.iconSource;

tabStripItem1.iconClass = "font-awesome font-size";
tabStripItem1.iconSource = tabStripItem2.iconSource;

tabStripItem2.iconClass = "font-awesome font-size";
tabStripItem2.iconSource = iconSource0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<GridLayout rows="auto,*">
<StackLayout row="0" >
<Button text="Change TabStrip styles dynamically" id="changeStyle" automationText="changeStyle" tap="onButtonTap" />
<Button text="Change Icon source dynamically" id="changeIconSource" automationText="changeIconSource" tap="onChangeIconSourceTap" />
</StackLayout>
<GridLayout row="1">
<BottomNavigation automationText="tabNavigation" id="bottomNavigation" >
<TabStrip class="tabsClass0">
<TabStripItem>
<Label text="Home"></Label>
<Image src="font://&#xF10B;" class="font-awesome font-size"></Image>
</TabStripItem>
<TabStripItem>
<Label text="Favorites"></Label>
<Image src="res://add_to_fav"></Image>
</TabStripItem>
<TabStripItem>
<Label text="Up"></Label>
<Image src="res://up"></Image>
</TabStripItem>
</TabStrip>
<TabContentItem>
<GridLayout>
<Label text="Home Page" class="h2 text-center">
</Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Favorites Page" class="h2 text-center">
</Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Up Page" class="h2 text-center">
</Label>
</GridLayout>
</TabContentItem>
</BottomNavigation>
</GridLayout>
</GridLayout>
</Page>
1 change: 1 addition & 0 deletions e2e/ui-tests-app/app/bottom-navigation/main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function loadExamples() {
examples.set("custom-tabstrip", "bottom-navigation/custom-tabstrip-page");
examples.set("reselect", "bottom-navigation/reselect-page");
examples.set("item-color", "bottom-navigation/item-color-page");
examples.set("dynamic-color-change", "bottom-navigation/dynamic-color-change-page");

return examples;
}
28 changes: 28 additions & 0 deletions e2e/ui-tests-app/app/tabs/dynamic-color-change-page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.font-awesome {
font-family: "FontAwesome";
}

.font-size {
font-size: 36;
}

TabStripItem:active {
background-color: magenta;
}

.tabsClass0 {
}

.tabsClass1 {
background-color: #79d2a6;
highlight-color: green;
selected-item-color: yellow;
un-selected-item-color: blue;
}

.tabsClass2 {
background-color: orangered;
highlight-color: lightgreen;
selected-item-color: whitesmoke;
un-selected-item-color: pink;
}
39 changes: 39 additions & 0 deletions e2e/ui-tests-app/app/tabs/dynamic-color-change-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { View } from "tns-core-modules/ui/core/view";
import { Page } from "tns-core-modules/ui/page";
import { Tabs } from "tns-core-modules/ui/tabs";

export function onButtonTap(args) {
const page = <Page>(<View>args.object).page;
const tabs = <Tabs>(page.getViewById("tabs"));

switch (tabs.tabStrip.className) {
case "tabsClass0":
tabs.tabStrip.className = "tabsClass1";
break;
case "tabsClass1":
tabs.tabStrip.className = "tabsClass2";
break;
case "tabsClass2":
tabs.tabStrip.className = "tabsClass0";
break;
}
}

export function onChangeIconSourceTap(args) {
const page = <Page>(<View>args.object).page;
const tabs = <Tabs>(page.getViewById("tabs"));

const tabStripItem0 = tabs.tabStrip.items[0];
const tabStripItem1 = tabs.tabStrip.items[1];
const tabStripItem2 = tabs.tabStrip.items[2];

const iconSource0 = tabStripItem0.iconSource;

tabStripItem0.iconSource = tabStripItem1.iconSource;

tabStripItem1.iconClass = "font-awesome font-size";
tabStripItem1.iconSource = tabStripItem2.iconSource;

tabStripItem2.iconClass = "font-awesome font-size";
tabStripItem2.iconSource = iconSource0;
}
44 changes: 44 additions & 0 deletions e2e/ui-tests-app/app/tabs/dynamic-color-change-page.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<GridLayout rows="auto,*">
<StackLayout row="0" >
<Button text="Change TabStrip styles dynamically" id="changeStyle" automationText="changeStyle" tap="onButtonTap" />
<Button text="Change Icon source dynamically" id="changeIconSource" automationText="changeIconSource" tap="onChangeIconSourceTap" />
</StackLayout>
<GridLayout row="1">
<Tabs automationText="tabNavigation" id="tabs" >
<TabStrip class="tabsClass0">
<TabStripItem>
<Label text="Home"></Label>
<Image src="font://&#xF10B;" class="font-awesome font-size"></Image>
</TabStripItem>
<TabStripItem>
<Label text="Favorites"></Label>
<Image src="res://add_to_fav"></Image>
</TabStripItem>
<TabStripItem>
<Label text="Up"></Label>
<Image src="res://up"></Image>
</TabStripItem>
</TabStrip>
<TabContentItem>
<GridLayout>
<Label text="Home Page" class="h2 text-center">
</Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Favorites Page" class="h2 text-center">
</Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Up Page" class="h2 text-center">
</Label>
</GridLayout>
</TabContentItem>
</Tabs>
</GridLayout>
</GridLayout>
</Page>
1 change: 1 addition & 0 deletions e2e/ui-tests-app/app/tabs/main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function loadExamples() {
examples.set("custom-tabstrip", "tabs/custom-tabstrip-page");
examples.set("frame-in-tabs", "tabs/frame-in-tabs");
examples.set("item-color", "tabs/item-color-page");
examples.set("dynamic-color-change", "tabs/dynamic-color-change-page");

return examples;
}
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,53 @@ describe(`${suite}-${spec}-suite`, async function () {
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
await bottomNavigationBasePage.navigateBackToSuitMainPage();
});

it(`${spec}-dynamic-color-change`, async function () {
await bottomNavigationBasePage.navigateToSample("dynamic-color-change");
await bottomNavigationBasePage.refreshTabItems();
await driver.imageHelper.compareScreen();

// go through the tabs and check that they are loaded
await bottomNavigationBasePage.tabOnItem(1);
await driver.imageHelper.compareScreen();

await bottomNavigationBasePage.tabOnItem(2);
await driver.imageHelper.compareScreen();

await bottomNavigationBasePage.tabOnItem(0);
await driver.imageHelper.compareScreen();

// change icon sources and check the result
const changeIconSource = await driver.waitForElement("changeIconSource");
await changeIconSource.click();
await driver.imageHelper.compareScreen();

const changeStyleBtn = await driver.waitForElement("changeStyle");
await changeStyleBtn.click();
await driver.imageHelper.compareScreen();

// change icon sources again
await changeIconSource.click();
await driver.imageHelper.compareScreen();

await bottomNavigationBasePage.tabOnItem(1);
await driver.imageHelper.compareScreen();

// change style again
await changeStyleBtn.click();
await driver.imageHelper.compareScreen();

await bottomNavigationBasePage.tabOnItem(2);
await driver.imageHelper.compareScreen();

await changeIconSource.click();
await driver.imageHelper.compareScreen();

// change style again
await changeStyleBtn.click();
await driver.imageHelper.compareScreen();

assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
await bottomNavigationBasePage.navigateBackToSuitMainPage();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,53 @@ describe(`${imagePrefix}-suite`, async function () {
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
await tabsViewBasePage.navigateBackToSuitMainPage();
});

it(`${spec}-dynamic-color-change`, async function () {
await tabsViewBasePage.navigateToSample("dynamic-color-change");
await tabsViewBasePage.refreshTabItems();
await driver.imageHelper.compareScreen();

// go through the tabs and check that they are loaded
await tabsViewBasePage.tabOnItem(1);
await driver.imageHelper.compareScreen();

await tabsViewBasePage.tabOnItem(2);
await driver.imageHelper.compareScreen();

await tabsViewBasePage.tabOnItem(0);
await driver.imageHelper.compareScreen();

// change icon sources and check the result
const changeIconSource = await driver.waitForElement("changeIconSource");
await changeIconSource.click();
await driver.imageHelper.compareScreen();

const changeStyleBtn = await driver.waitForElement("changeStyle");
await changeStyleBtn.click();
await driver.imageHelper.compareScreen();

// change icon sources again
await changeIconSource.click();
await driver.imageHelper.compareScreen();

await tabsViewBasePage.tabOnItem(1);
await driver.imageHelper.compareScreen();

// change style again
await changeStyleBtn.click();
await driver.imageHelper.compareScreen();

await tabsViewBasePage.tabOnItem(2);
await driver.imageHelper.compareScreen();

await changeIconSource.click();
await driver.imageHelper.compareScreen();

// change style again
await changeStyleBtn.click();
await driver.imageHelper.compareScreen();

assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
await tabsViewBasePage.navigateBackToSuitMainPage();
});
});
1 change: 1 addition & 0 deletions nativescript-core/image-source/image-source.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export class ImageSource implements ImageSourceDefinition {
}

static fromFontIconCodeSync(source: string, font: Font, color: Color): ImageSource {
font = font || Font.default;
const paint = new android.graphics.Paint();
paint.setTypeface(font.getAndroidTypeface());
paint.setAntiAlias(true);
Expand Down
1 change: 1 addition & 0 deletions nativescript-core/image-source/image-source.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class ImageSource implements ImageSourceDefinition {
}

static fromFontIconCodeSync(source: string, font: Font, color: Color): ImageSource {
font = font || Font.default;
let fontSize = layout.toDevicePixels(font.fontSize);
if (!fontSize) {
// TODO: Consider making 36 font size as default for optimal look on TabView and ActionBar
Expand Down
Loading