Skip to content

Commit f35e0d4

Browse files
committed
Remove {N}-theme-widgets completely
(should fix the icons and navigation)
1 parent 9c51207 commit f35e0d4

9 files changed

Lines changed: 2106 additions & 1228 deletions

File tree

app/action-bar/action-bar.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<ActionBar title="{{ title }}" loaded="onLoad" xmlns:ui="nativescript-theme-widgets">
1+
<ActionBar title="{{ title }}" loaded="onLoad">
22
<android>
33
<NavigationButton icon="{{ backButton ? 'res://chevron_left' : 'res://menu' }}"
44
tap="{{ backButton ? goBack : toggleSideDrawer }}" />
55
</android>
66
<ios>
77
<NavigationButton visibility="collapsed" />
88
<ActionItem position="left" tap="{{ backButton ? goBack : toggleSideDrawer }}">
9-
<ui:NTIcon name="{{ backButton ? 'chevron-left' : 'bars' }}"/>
9+
<Label name="{{ backButton ? 'chevron-left' : 'bars' | fonticon }}"/>
1010
<Button class="fa" text="{{ backButton ? '&#xf053; Back' : '&#xf0c9;' }}" />
1111
</ActionItem>
1212
</ios>

app/app-root/app-root.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<drawer:RadSideDrawer
22
xmlns:drawer="nativescript-ui-sidedrawer"
3-
xmlns:ui="nativescript-theme-widgets"
43
xmlns:themes="pages/themes"
54
loaded="onLoaded">
65
<drawer:RadSideDrawer.drawerTransition>
@@ -13,8 +12,14 @@
1312
<Image src="~/assets/images/N.png" tap="{{ viewHome }}" class="nt-drawer__header-image"/>
1413
<Label text="NativeScript Theme Project" textWrap="true" class="nt-drawer__header-brand" />
1514
</StackLayout>
16-
<ui:NTMenu row="1" items="{{ pages }}" selected="{{ selectedPage }}"
17-
itemSelected="{{ onNavigationItemTap }}"/>
15+
<ListView row="1" items="{{ pages }}" itemTap="{{ onNavigationItemTap }}">
16+
<ListView.itemTemplate>
17+
<StackLayout orientation="horizontal" class="{{ value === $parent.selectedPage ? 'active' : '' }}">
18+
<Label text="{{ icon | fonticon }}" class="fa" />
19+
<Label text="{{ text || value }}" />
20+
</StackLayout>
21+
</ListView.itemTemplate>
22+
</ListView>
1823
</GridLayout>
1924
</drawer:RadSideDrawer.drawerContent>
2025

app/app.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,37 @@ purpose of the file is to pass control to the app’s first module.
66
import * as app from "tns-core-modules/application";
77
import "nativescript-theme-core";
88

9+
export function fonticon(value) {
10+
if (value) {
11+
const scope = app.getRootView()._styleScope;
12+
13+
if (!scope) {
14+
return;
15+
}
16+
17+
const icon = scope._selectors.class[value];
18+
19+
// eslint-disable-next-line no-unused-expressions
20+
icon && icon
21+
.flatMap((value) => value.sel.ruleset.declarations)
22+
.reverse()
23+
.some((dec) => {
24+
if (dec.property === "content") {
25+
const char = dec.value.replace(/^"|"$/g, "");
26+
27+
value = char.startsWith("\\") ?
28+
String.fromCharCode(`0x${(char.match(/[a-f\d]{2,4}/i) || [])[0]}`) :
29+
char;
30+
31+
return true;
32+
}
33+
});
34+
}
35+
36+
return value;
37+
}
38+
39+
app.setResources({ fonticon });
940
app.run({ moduleName: "app-root/app-root" });
1041

1142
/*

app/pages/buttons.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<Button text="Button.-primary" class="-primary"/>
2626
<Button class="-primary">
2727
<FormattedString>
28-
<ui:NTSpanIcon name="twitter"/>
28+
<Span text="{{ 'twitter' | fonticon }}"/>
2929
<Span text=" Button.-primary with icon"/>
3030
</FormattedString>
3131
</Button>

app/pages/root.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<Page loaded="onLoad"
2-
xmlns:ui="nativescript-theme-widgets"
32
xmlns:actionBar="/action-bar">
43
<actionBar:action-bar ActionBarTitle="NativeScript Themes" />
54

6-
<ui:NTMenu items="{{ somePages }}" selected="{{ selectedPage }}" itemSelected="{{ onNavigationItemTap }}"/>
5+
<ListView items="{{ somePages }}" itemTap="{{ onNavigationItemTap }}">
6+
<ListView.itemTemplate>
7+
<StackLayout orientation="horizontal">
8+
<Label text="{{ icon | fonticon }}" class="fa" />
9+
<Label text="{{ text || value }}" />
10+
</StackLayout>
11+
</ListView.itemTemplate>
12+
</ListView>
13+
<!-- <ui:NTMenu items="{{ somePages }}" selected="{{ selectedPage }}" itemSelected="{{ onNavigationItemTap }}"/>-->
714
</Page>

0 commit comments

Comments
 (0)