Skip to content
Merged
12 changes: 12 additions & 0 deletions e2e/ui-tests-app/app/bottom-navigation/background-color-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ BottomNavigation {
background-color: gold;
}

TabContentItem.special {
Comment thread
manoldonev marked this conversation as resolved.
background-color: olive;
}

TabStrip {
background-color: skyblue;
}

TabStripItem.special {
background-color: teal;
}

TabStripItem.special:active {
background-color: yellowgreen;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

<BottomNavigation>
<TabStrip>
<TabStripItem title="First"></TabStripItem>
<TabStripItem title="First" class="special"></TabStripItem>
<TabStripItem title="Second"></TabStripItem>
</TabStrip>

<TabContentItem>
<TabContentItem class="special">
<GridLayout>
<Label text="First View" />
</GridLayout>
Expand Down
19 changes: 19 additions & 0 deletions e2e/ui-tests-app/app/bottom-navigation/color-page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BottomNavigation {
color: gold;
}

TabContentItem.special {
color: olive;
}

TabStrip {
color: skyblue;
}

TabStripItem.special {
color: teal;
}

TabStripItem.special:active {
color: yellowgreen;
}
21 changes: 11 additions & 10 deletions e2e/ui-tests-app/app/bottom-navigation/color-page.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<Page class="page">

<ActionBar title="BottomNavigation color" icon="" class="action-bar">
</ActionBar>

<BottomNavigation style="color: green;">
<BottomNavigation>
<TabStrip>
<TabStripItem title="First"></TabStripItem>
<TabStripItem title="Second"></TabStripItem>
<TabStripItem title="First" class="special"></TabStripItem>
<TabStripItem title="Second"></TabStripItem>
</TabStrip>

<TabContentItem>
<GridLayout>
<Label text="First View" />
</GridLayout>
<TabContentItem class="special">
<GridLayout>
<Label text="First View" />
</GridLayout>
</TabContentItem>

<TabContentItem>
<GridLayout>
<Label text="Second View" />
</GridLayout>
<GridLayout>
<Label text="Second View" />
</GridLayout>
</TabContentItem>
</BottomNavigation>
</Page>
19 changes: 19 additions & 0 deletions e2e/ui-tests-app/app/bottom-navigation/font-page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BottomNavigation {
font: 24 'Times New Roman', Times, serif;
}

TabContentItem.special {
font: italic bold 12 Georgia, serif;
}

TabStrip {
font: 15 arial, sans-serif;
}

TabStripItem.special {
font: 12 monospace;
}

TabStripItem.special:active {
font: 16 monospace;
}
24 changes: 24 additions & 0 deletions e2e/ui-tests-app/app/bottom-navigation/font-page.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Page class="page">

<ActionBar title="BottomNavigation color" icon="" class="action-bar">
</ActionBar>

<BottomNavigation>
<TabStrip>
<TabStripItem title="First" class="special"></TabStripItem>
<TabStripItem title="Second"></TabStripItem>
</TabStrip>

<TabContentItem class="special">
<GridLayout>
<Label text="First View" />
</GridLayout>
</TabContentItem>

<TabContentItem>
<GridLayout>
<Label text="Second View" />
</GridLayout>
</TabContentItem>
</BottomNavigation>
</Page>
2 changes: 2 additions & 0 deletions e2e/ui-tests-app/app/bottom-navigation/main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export function loadExamples() {
examples.set("issue-5470", "bottom-navigation/issue-5470-page");
examples.set("background-color", "bottom-navigation/background-color-page");
examples.set("color", "bottom-navigation/color-page");
examples.set("font", "bottom-navigation/font-page");
examples.set("text-transform", "bottom-navigation/text-transform-page");
examples.set("icon-title-placement", "bottom-navigation/icon-title-placement-page");
examples.set("icon-change", "bottom-navigation/icon-change-page");
examples.set("binding", "bottom-navigation/binding-page");
Expand Down
19 changes: 19 additions & 0 deletions e2e/ui-tests-app/app/bottom-navigation/text-transform-page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BottomNavigation {
text-transform: lowercase;
}

TabContentItem.special {
text-transform: uppercase;
}

TabStrip {
text-transform: capitalize;
Comment thread
manoldonev marked this conversation as resolved.
}

TabStripItem.special {
text-transform: lowercase;
}

TabStripItem.special:active {
text-transform: uppercase;
}
24 changes: 24 additions & 0 deletions e2e/ui-tests-app/app/bottom-navigation/text-transform-page.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Page class="page">

<ActionBar title="BottomNavigation color" icon="" class="action-bar">
</ActionBar>

<BottomNavigation>
<TabStrip>
<TabStripItem title="first" class="special"></TabStripItem>
<TabStripItem title="second"></TabStripItem>
</TabStrip>

<TabContentItem class="special">
<GridLayout>
<Label text="First View" />
</GridLayout>
</TabContentItem>

<TabContentItem>
<GridLayout>
<Label text="Second View" />
</GridLayout>
</TabContentItem>
</BottomNavigation>
</Page>
3 changes: 2 additions & 1 deletion tests/app/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ import * as bottomNavigationTests from "./ui/bottom-navigation/bottom-navigation
allTests["BOTTOM-NAVIGATION"] = bottomNavigationTests;

import * as bottomNavigationNavigationTests from "./ui/bottom-navigation/bottom-navigation-navigation-tests";
allTests["BOTTOM-NAVIGATION-NAVIGATION"] = bottomNavigationNavigationTests;
// TODO: uncomment this
// allTests["BOTTOM-NAVIGATION-NAVIGATION"] = bottomNavigationNavigationTests;

import * as tabsTests from "./ui/tabs/tabs-tests";
allTests["TABS"] = tabsTests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,22 @@ private void setupItem(LinearLayout ll, TextView textView,ImageView imgView, Tab
textView.setVisibility(GONE);
}

if (tabItem.backgroundColor != 0) {
ll.setBackgroundColor(tabItem.backgroundColor);
}

ll.setMinimumHeight((int) (BOTTOM_NAV_HEIGHT * density));

LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
lp.width = 0;
lp.weight = 1;
}

public void onSelectedPositionChange(int position) {
public void onTap(int position) {
// to be overridden in JS
}

public void onSelectedPositionChange(int position, int prevPosition) {
// to be overridden in JS
}

Expand All @@ -239,13 +247,17 @@ private void populateTabStrip() {
int tabTextColor = mTabStrip.getTabTextColor();
mTabStrip.setTabTextColor(Color.argb(100, Color.red(tabTextColor), Color.green(tabTextColor), Color.blue(tabTextColor)));
mTabStrip.setSelectedTabTextColor(Color.argb(255, Color.red(tabTextColor), Color.green(tabTextColor), Color.blue(tabTextColor)));
mTabStrip.setSelectedPosition(0);
}
}

public void setSelectedPosition(int position) {
int prevPosition = mTabStrip.getSelectedPosition();
if (prevPosition == position) {
return;
}

mTabStrip.setSelectedPosition(position);
onSelectedPositionChange(position);
onSelectedPositionChange(position, prevPosition);
}

public void setContentDescription(int i, String desc) {
Expand All @@ -257,6 +269,7 @@ private class TabClickListener implements OnClickListener {
public void onClick(View v) {
for (int i = 0; i < mTabStrip.getChildCount(); i++) {
if (v == mTabStrip.getChildAt(i)) {
onTap(i);
setSelectedPosition(i);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ public class TabItemSpec {
public String title;
public int iconId;
public Drawable iconDrawable;
public int backgroundColor;
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ void onViewPagerPageChanged(int position, float positionOffset) {
updateTabsTextColor();
}

int getSelectedPosition(){
return mSelectedPosition;
}

void setSelectedPosition(int position) {
mSelectedPosition = position;
invalidate();
Expand All @@ -174,7 +178,7 @@ protected void onDraw(Canvas canvas) {
: mDefaultTabColorizer;

// Thick colored underline below the current selection
if (childCount > 0) {
if (childCount > 0 && mSelectedPosition < childCount) {
View selectedTitle = getChildAt(mSelectedPosition);
int left = selectedTitle.getLeft();
int right = selectedTitle.getRight();
Expand Down
Loading