8000 fix(android/action-bar): process Icon Fonts in NavigationButton the s… · NativeScript/NativeScript@4991e6d · GitHub
[go: up one dir, main page]

Skip to content

Commit 4991e6d

Browse files
ycherniavskyiMartoYankov
authored andcommitted
fix(android/action-bar): process Icon Fonts in NavigationButton the same way as in ActionItem (#7842)
* fix(android/action-bar): process Icon Fonts in NavigationButton the same way as in ActionItem * Add NavigationButton with font icons to corresponding page in ui tests app
1 parent 3e8d635 commit 4991e6d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

e2e/ui-tests-app/app/action-bar/font-icons-page.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Page>
22
<Page.actionBar>
33
<ActionBar automationText="actionBar">
4+
<NavigationButton icon="font://&#xF137;" class="font-awesome font-size color"/>
45
<ActionBar.actionItems>
56
<!-- font family + font size + color -->
67
<ActionItem icon="font://&#xF10B;" class="font-awesome font-size color" tap="navigate"/>

tns-core-modules/ui/action-bar/action-bar.android.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,21 @@ export class ActionBar extends ActionBarBase {
227227
}
228228
}
229229
else if (navButton.icon) {
230-
let drawableOrId = getDrawableOrResourceId(navButton.icon, appResources);
231-
if (drawableOrId) {
232-
this.nativeViewProtected.setNavigationIcon(drawableOrId);
230+
if (isFontIconURI(navButton.icon)) {
231+
const fontIconCode = navButton.icon.split("//")[1];
232+
const font = navButton.style.fontInternal;
233+
const color = navButton.style.color;
234+
const is = fromFontIconCode(fontIconCode, font, color);
235+
236+
if (is && is.android) {
237+
const drawable = new android.graphics.drawable.BitmapDrawable(appResources, is.android);
238+
this.nativeViewProtected.setNavigationIcon(drawable);
239+
}
240+
} else {
241+
let drawableOrId = getDrawableOrResourceId(navButton.icon, appResources);
242+
if (drawableOrId) {
243+
this.nativeViewProtected.setNavigationIcon(drawableOrId);
244+
}
233245
}
234246
}
235247

0 commit comments

Comments
 (0)
0