How to add Font-awesome icon to tabview in Nativescript Vue platform - vue.js

I'm trying to use font-awesome icon inside the TabView item. I am able to use this same code elsewhere in the page and it works fine. It just wont show any icon inside the tabview.
In my main.js:
import {TNSFontIcon, fonticon} from 'nativescript-fonticon';
TNSFontIcon.debug = true;
TNSFontIcon.paths = {
'fa': './assets/css/font-awesome.css',
'ion': './ionicons.css'
};
TNSFontIcon.loadCss();
Vue.filter('fonticon', fonticon);
In App.vue:
<TabView class="tab-view" :selectedIndex="selectedIndex" androidTabsPosition="bottom">
<TabViewItem class="fa" :text="'fa-plane' | fonticon" >
<Label text="Content for Tab 1"/>
</TabViewItem>
<TabViewItem title="Tab 2">
<Label text="Content for Tab 2" #tap="pretextsTap()" />
</TabViewItem>
</TabView>
I'm using Nativescript Vue platform and couldn't find the example of using font-awesome icon inside the tabview item. In the first TabViewItem, I was trying to add fa-plane icon to see if I got it right. It didn't. I look forward to your tip.
Thanks.

Tab view items have a title property, not text.
Give :title="'fa-plane' | fonticon" a shot.

Related

TabbedPage tab icons not working with font awesome

I'm trying to add icons to my tabs with font awesome, in my Xamarin iOS/android app, I looked in many tutorials and I tried to do the same but something is wrong with the following code:
<TabbedPage.Children>
<mypages:List Title="Lista">
<Tab.Icon>
<FontImageSource FontFamily="{StaticResource FontAwesomeSolid}" Glyph="" Size="Small" />
</Tab.Icon>
</mypages:List>
</TabbedPage.Children>
Everything worked until I add the <Tab.Icon> Stuff.
The error you got is self-explanatory:
"The attachable property "Icon" was not found in type 'Tab' ", with <Tab.Icon> underlined.
There is no property called Icon in type Tab, you can use below but as you can see, it is IconImageSource which requires to provide a resource image name and not a font glyph.
<TabbedPage.Children>
<apptest:Page2 IconImageSource="imageName.png"/>
</TabbedPage.Children>
An alternative in order to use font icons would be to use Shell to build your tabs instead of TabbedPage, which provides font icon support thru FontImageSource:
<Shell>
...
<Tab Title="title">
<Tab.Icon>
<FontImageSource FontFamily="FontAwesome" Glyph="{x:Static fonts:IconFont.AddressBook}"/>
</Tab.Icon>
<ShellContent ContentTemplate="{DataTemplate local:Page1}"/>
</Tab>
Details about fontawesome in xamarin.forms: How to use Font Awesome icons in project as an icon of ImageButton

Is it possible to render elements conditionally in NativeScript-Vue?

I hope you can help me to solve my problem.
I am working on a Nativescript-Vue Application and I want to render this conditionally:
<Label if="isRendering" text="This is a text"></Label>
But this does not work.
I already tried it with <v-template if="..."></v-template> but this also does not work.
If i am not mistaken, in Vue.js it is possible to render conditionally with v-if and i am searching for a possibility to make it in Nativescript-Vue.
Thank you
It's the same like in Vue.js.
Instead of using if you should be using v-if.
Playground example
Example:
<Label v-if="isRendering" text="This is a text"></Label>
But if you want to use an if in a ListView it's different.
Example:
<ListView for="item in listOfItems" #itemTap="onItemTap">
<v-template>
<Label :text="item.text" />
</v-template>
<v-template if="$odd">
<!-- For items with an odd index, shows the label in red. -->
<Label :text="item.text" color="red" />
</v-template>
</ListView>
But more info about that in the docs

titanium alloy raised tab bar with raised center button - dailybooth style

I'm trying to customize my alloy TabGroup to look like the image below (with no luck). no "height" properties on Tab item in the default documentation and with my current version of titanium 3.4.0 can't add View to TabGroup.
anybody know how to create a raised center button using alloy?
that's my index.xml view
<Alloy>
<TabGroup tabsBackgroundColor="white" barColor="#f15b26" activeTabIconTint="black" tintColor="white">
<Require src="home" nr="1" />
<Require src="play" nr="2" />
<Tab icon="/menu/logo.png" height="100">
<Window title="" id="">
<Label></Label>
</Window>
</Tab>
<Require src="chat" nr="3" />
<Require src="config" nr="4" />
</TabGroup>
</Alloy>
you can use an image in the middle of the that exceed the height of the bar.
When we implemented this solution in the past, we did a completely custom tabBar. I dont think you can accomplish what you are trying to do with the base tabBar control

Titanium Alloy LeftNavButton not showing up in simulator

Not sure where I am doing wrong. I tried via code and by xml, but for some reason the left nav button does not show up. I am using the simulator since I don't have an actual device for ios.
The xml view
<!--filename: playType.xml->
<Alloy>
<Window class="container">
<LeftNavButton platform="ios">
<Button title="Back" onClick="closeWindow"/>
</LeftNavButton>
<View class="buttonContainer">
<Button class="menuButton" title="Single Player"/>
<Button class="menuButton" title ="Duel"/>
</View>
</Window>
</Alloy>
The Controller
//playType.js
var args = arguments[0] || {};
var closeWindow = function(){
$.playType.close();
};
The tss style
//playType.tss
".container" : {
backgroundColor:"white",
height:Ti.UI.FILL,
},
".buttonContainer":{
center:{x:"50%",y:"50%"},
height:Ti.UI.SIZE,
layout:"vertical"
}
I using this from the index.js
var playType = Alloy.createController('playType').getView();
playType.open();
The window shows up fine with the two buttons in the center but the back button doesn't appear.
What am I doing wrong. I went through the doc and also tried the code way too. Same result, no back button. :(
You have to create the window using navigation window otherwise navButton wont show up.here goes the code link for you
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.iOS.NavigationWindow
Thanks
Your window must be placed inside a TabGroup which handles all the capabilities of a navigation controller inside each tab.
<Alloy>
<TabGroup>
<Tab id="tab1" title="Tab 1">
<Window id="win1" title="Tab 1">
<LeftNavButton platform="ios">
<Button title="Back" onClick="closeWindow"/>
</LeftNavButton>
...
</Window>
</Tab>
</TabGroup>
</Alloy>
As for the back button, open a child window of the current tab using the tab as the reference to the open method.
tab.open(newWindow);

Problems using a composite view in Titanium Alloy

I am trying to implement a simple app in Alloy that has a very basic structure but I cannot get it to layout reliably. I am trying to bottom align a group of navigation buttons with a working area above them which in the following example would be a TableView.
<Alloy>
<Collection src="book">
<Window height="100%" id="main" title="My Library {opts.username}" exitOnClose="true" onOpen="loadExtras">
<TableView id="content" dataCollection="book" top="10px" bottom="100px" onDragEnd="refreshTable">
<TableViewRow title="{title}" color="black" onClick="showBook"/>
</TableView>
<View bottom="0px" height="72px" layout="horizontal" id="actionPanel">
<Button class="footerBtn" onClick="refreshTable">View</Button>
<Button class="footerBtn" onClick="refreshTable">Help</Button>
<Button class="footerBtn" onClick="refreshTable">List</Button>
<Button class="footerBtn add" onClick="addBook"></Button>
</View>
</Window>
The only way I can get this to work is to specify a height for the TableView such as height="80%" and then play with this value until things layout as I would prefer but I do not want to do as I need this to work independently of the devices physical screen size.
How can I implement this kind of layout in Alloy to get a view to pin to the bottom of the screen with a variable working area above it - or, do I have to assume a standard height and work relative to that?
Try pinning the table to the bottom of the parent view and then setting the height to be 80% of the parent view height. Also, use dp values to be screen independent.
<TableView id="content" height="80%" bottom="100dp"
onDragEnd="refreshTable"
dataCollection="book">