File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ? ' Back' : ' ' }}" />
1111 </ActionItem >
1212 </ios >
Original file line number Diff line number Diff line change 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>
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
Original file line number Diff line number Diff line change @@ -6,6 +6,37 @@ purpose of the file is to pass control to the app’s first module.
66import * as app from "tns-core-modules/application" ;
77import "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 } ) ;
940app . run ( { moduleName : "app-root/app-root" } ) ;
1041
1142/*
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments