I'd like to load the right icon based on active light or dark theme.
<NavigationButton icon="res://ic_menu" tap="{{ showSlideout }}" />
Any suggestions?
This will use icon ic_menu or ic_menu2 based on is_dark variable's true/false value which can be changed somewhere as part of bindingContext observable
<NavigationButton icon="{{is_dark? 'res://ic_menu':'res://ic_menu2'}}" tap="{{ showSlideout }}" />
and if that won't work try this way, where you will bind variable for use in expression
<NavigationButton icon="{{is_dark , is_dark? 'res://ic_menu':'res://ic_menu2'}}" tap="{{ showSlideout }}" />
Related
I am having issues with GridLayout losing their column sizing inside a TabView whenever I go to another tab below the current index
An example is below where I am navigating from the 'Freaks' tab to the 'Legends' tab before it and the items inside the GridLayout lose their column position. All of them seem to revert back to column 0'. Both of the tabs uses the same component with only the data being passed as props being different.
Original GridLayout column position in 'Freaks' tab
GridLayout in 'Legends' tab losing column specifications
Gridlayout code would be
<GridLayout columns="40, *, auto" class="w-100 py-7 border-bottom-light" #longPress="optionsOpened">
<TImage :col="0" :src="image" class="w-40 h-40 round" />
<StackLayout :col="1" class="px-20" verticalAlignment="center">
<Label class="text-13" :text="`${data.attributes.first_name} ${data.attributes.last_name}`" textWrap="true" />
<Label v-if="role" class="text-11 text-grey text-capitalize" :text="data.attributes.jersey_number ? `#${data.attributes.jersey_number} ${role}` : role" />
</StackLayout>
<template v-if="!hide_action">
<StackLayout class="action-container" :col="2" orientation="horizontal">
<ActionTile class="at" :text="0xf00c" :is_icon="true" v-if="data.attributes.available == true" #tap.native="markAvailability(!data.attributes.available)" />
<ActionTile class="at" color="red" :text="0xf00d" :is_icon="true" v-if="data.attributes.available == false" #tap.native="markAvailability(!data.attributes.available)" />
</StackLayout>
</template>
</GridLayout>
Has anyone encountered a similar issue? If so, what was your fix? Any help would be much appreciated.
Why does this following code produce this result: https://imgur.com/a/lQhLs8o ?
However, if I move the BottomNavigatorBar component to top position before CountryListComponent, it produces the desired result that looks like this: https://imgur.com/a/23z7bb2 ?
<template>
<Page actionBarHidden="true">
<DockLayout height="100%">
// first
<CountryListComponent dock="top">
// second
<BottomNavigationBar dock="bottom" activeColor="pink"
inactiveColor="yellow"
backgroundColor="black"
verticalAlignment="bottom"
#tabSelected="this.changeTab"
row="1">
<BottomNavigationTab title="Fiaarst" icon="icon-29.png" />
<BottomNavigationTab title="Second" icon="icon-29.png" />
<BottomNavigationTab title="Third" icon="icon-29.png" />
</BottomNavigationBar>
</DockLayout>
</Page>
</template>
CountryListComponent
<template>
<StackLayout backgroundColor="blue">
</StackLayout>
</template>
Refer the DockLayout documentation, by default stretchLastChild will be true which means BottomNavigationBar will take entire space if it's last child and vice versa.
If I use <Label text="Welcome {{ username }}" /> no username appears.
Literally "Welcome {{ username }}" is visible - plaintext appears.
However using just <Label text="{{ username }}" /> works as intended, the username is passed.
I can work with this but am wondering if this is normal and if I'm doing it wrong.
Using plain JS with NativeScript, not angular or typescript.
This won't work:
<Label text="Welcome {{ username }}" />
It should be: <Label text="{{ 'Welcome ' + username }}" />
I'm new in Nativescript.And how I call javascript function when binding? I try try like method below, but get empty result.
<Repeater items="{{ Match }}">
<Repeater.itemTemplate>
<StackLayout>
<Label text="{{ SubStringMatch(MatchNo) }}" />
<Label text="{{ DateTime }}" />
</StackLayout>
</Repeater.itemTemplate>
</Repeater>
function SubStringMatch(value) {
return value.substring(1);
}
exports.SubStringMatch= SubStringMatch;
From the code you posted, I believe, you are trying to convert a number value into a string. This could be achieved by using a converter function. You can read more about it in {N} documentation.
I created a static FlyOut control with multiple buttons. On click of those buttons different JS should fire. I created Commanddefinition for every JS function and made a refernce to them inside buttons controls. But, my buttons become disabled. If all of the buttons refer to the same commanddefinition/ js function, works fine. What am I missing? Any help will be greatly appreciated.
Here's my code:
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="Add_Dynamic_Menu"
Location="Mscrm.Form.new_test.MainTab.Workflow.Controls._children">
<CommandUIDefinition>
<FlyoutAnchor Id="Sample.new_test.form.FlyoutAnchor.Static" Sequence="10"
Command="Mscrm.Enabled"
Image16by16="/_imgs/placeholders/ribbon_placeholder_16.png"
Image32by32="/_imgs/ribbon/newrecord32.png" LabelText="Sample Flyout"
Alt="Sample Flyout" TemplateAlias="isv">
<Menu Id="Sample.new_test.form.Menu">
<MenuSection Id="Sample.new_test.form.MenuSection"
Title="Menu Section Title" Sequence="15">
<Controls Id="Sample.new_test.form.MenuSection.Controls">
<Button Id="Sample.new_test.form.Controls.Button.FirstButton"
Command="Sample.FirstButtonComand" LabelText="First Button"
ToolTipTitle="First Button"
ToolTipDescription="The first button" TemplateAlias="isv"
Sequence="20"/>
<Button Id="Sample.new_test.form.Controls.Button.SecondButton"
Command="Sample.SecondButtonCommand" LabelText="Second Button"
ToolTipTitle="Second Button"
ToolTipDescription="The Second button" TemplateAlias="isv"
Sequence="20"/>
</Controls>
</MenuSection>
</Menu>
</FlyoutAnchor>
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"/>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Sample.FirstButtonCommand">
<EnableRules>
<EnableRule Id="Mscrm.Enabled"/>
</EnableRules>
<DisplayRules/>
<Actions>
<JavaScriptFunction FunctionName="testfirstbutton"
Library="$webresource:new_testfirstbutton"> </JavaScriptFunction>
</Actions>
</CommandDefinition>
<CommandDefinition Id="Sample.SecondButtonCommand">
<EnableRules/>
<DisplayRules/>
<Actions>
<JavaScriptFunction FunctionName="testsecondbutton"
Library="$webresource:new_testsecondbutton"> </JavaScriptFunction>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules/>
<DisplayRules/>
<EnableRules/>
</RuleDefinitions>
<LocLabels/>
</RibbonDiffXml>
What you are doing looks fine, so double check the webresource names and everything.
An approach to troubleshoot
1) Switch everything to the webresource/function that works
2) Add the other function to the JavaScript webresource and see if it still works (if it fails, then it was the javascript function(s)).
3) Switch one of the FunctionName's to the second function while keeping the websresource all the same.
A couple of minor things I noticed. Both of your buttons have the same sequence number. I would change firstbutton to 10. Second, you do not have the Mscrm.Enabled rule on the seconnd buttons command def.
These ribbons love to be finicky.