I am creating a native script application and I want my tab View to appear on the top for iOS. I know sticking the tabView on the top violates the human interface guideline, but I need to do it this way.
With the new Nativescript 6 there is a new component called "Tabs" that allows you to do this:
Here is how you would do it with Nativescript angular:
<Tabs selectedIndex="1" class="fas font-size">
<!-- Using icon fonts for each TabStripItem -->
<TabStrip>
<TabStripItem title="Home"></TabStripItem>
<TabStripItem title="Account"></TabStripItem>
<TabStripItem title="Search"></TabStripItem>
</TabStrip>
<TabContentItem>
<GridLayout>
<Label text="Home Page" class="h2 text-center"></Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Account Page" class="h2 text-center"></Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Search Page" class="h2 text-center"></Label>
</GridLayout>
</TabContentItem>
</Tabs>
Here is a playground project I created.
Hereis a playground example with Nativescript typescript using both top and low tabs
Here you can find the documentation
important note: this widget is currently on beta
You can achieve that. Here's how i have done the similar thing -
<StackLayout row="0" col="0">
<StackLayout *ngIf="visibility1" id="mainView" visibility="{{ visibility1 ? 'visible' : 'collapsed' }}">
<FirstView></FirstView>
</StackLayout>
<StackLayout *ngIf="visibility2" id="mainView" visibility="{{ visibility2 ? 'visible' : 'collapsed' }}">
<SecondView></SecondView>
</StackLayout>
<StackLayout *ngIf="visibility3" id="mainView" visibility="{{ visibility3 ? 'visible' : 'collapsed' }}">
<ThirdView></ThirdView>
</StackLayout>
</StackLayout>
and change the visibility of each component based on the click events.
You can implement all manners of TabView behaviours/layouts using the SegmentedBar. See this answer for details
Related
I have a screen in Django with a single-select autocomplete and multi-select autocomplete to the same model object (but different model fields). The multi-select is working perfectly, the single-select is functional, but poorly styled and also slightly broken (takes an extra click to get into the box to type).
Help?
EDIT 1: If I remove the multi-select box from the form, the single-select is still poorly styled and broken. So, while the multi-select shows something can work, it is likely otherwise unrelated.
EDIT 2: I hard-refreshed my browser, and tried a different browser (Firefox), so I think it's not just out-of-date assets.
EDIT 3: I disabled the bootstrap form and used a regular form, and it still has odd behavior, but not as odd.
So the problems with how it looks is likely an interaction between django-autocomplete-light and django-bootstrap5.
I thought that a single select would allow you to type within the text box, but instead it drops down another text box for you to type in. Perhaps this is what is expected out of select2.
The only remaining issue is that in my code, it does not autofocus the cursor into the box when I click, whereas on the select2 site it does.
More detail:
Django 4.1.5
django-autocomplete-light 3.9.4
django-bootstrap5 22.2
generated HTML
multi-select (working):
<span
class="select2-selection
select2-selection--multiple
form-select"
role="combobox"
aria-haspopup="true"
aria-expanded="false"
tabindex="-1"
aria-disabled="false"><ul
class="select2-selection__rendered"><li
class="select2-search
select2-search--inline"><input
class="select2-search__field"
type="search"
tabindex="0"
autocomplete="off"
autocorrect="off"
autocapitalize="none"
spellcheck="false"
role="searchbox"
aria-autocomplete="list"
placeholder="Type
here"
style="width:
288px;"></li></ul></span>
.select2-container .select2-selection--multiple: min-height: 32px
single-select (broken):
<span
class="select2-selection
select2-selection--single
form-select"
role="combobox"
aria-haspopup="true"
aria-expanded="false"
tabindex="0"
aria-disabled="false"
aria-labelledby="select2-id_primary_diagnosis-container"><span
class="select2-selection__rendered"
id="select2-id_primary_diagnosis-container"
role="textbox"
aria-readonly="true"><span
class="select2-selection__placeholder">Type
here</span></span><span
class="select2-selection__arrow"
role="presentation"><b
role="presentation"></b></span></span>
"display:inline prevents height:28px from having an effect"
In forms.py:
class MyobjForm(forms.Form):
# NOTE: can't use ModelForm for various reasons not shown
single_select = forms.ModelChoiceField(
label='single select',
queryset=Myobj.objects.all(),
widget=autocomplete.ModelSelect2(
url="myobj-autocomplete",
attrs={
"data-placeholder": "Type here",
# Only autocomplete after 1 character has been typed
"data-minimum-input-length": 1,
},
),
)
multi_select = forms.ModelMultipleChoiceField(
label='multi select',
queryset=Myobj.objects.all(),
required=False,
widget=autocomplete.ModelSelect2Multiple(
url="myobj-autocomplete",
attrs={
"data-placeholder": "Type here",
# Only autocomplete after 1 character has been typed
"data-minimum-input-length": 1,
},
),
)
In templates:
{% load django_bootstrap5 %}
...
{% block head_script %}
{# include jquery and the form media to get django-autocomplete-light to work #}
<script type="text/javascript" src="{% static 'admin/js/vendor/jquery/jquery.js' %}"></script>
{{labeledencounter_form.media}}
{% endblock head_script %}
...
{% bootstrap_form myform %}
Template media headers compile to:
<script type="text/javascript" src="/static/admin/js/vendor/jquery/jquery.js"></script>
<link href="/static/admin/css/vendor/select2/select2.css" media="screen" rel="stylesheet">
<link href="/static/admin/css/autocomplete.css" media="screen" rel="stylesheet">
<link href="/static/autocomplete_light/select2.css" media="screen" rel="stylesheet">
<script src="/static/admin/js/vendor/select2/select2.full.js"></script>
<script src="/static/autocomplete_light/autocomplete_light.js"></script>
<script src="/static/autocomplete_light/select2.js"></script>
<script src="/static/autocomplete_light/i18n/en.js"></script>
...
<label class="form-label" for="id_select_select">single select</label><select name="select_select" data-placeholder="Type here" data-minimum-input-length="1" class="form-select" required id="id_select_select" data-autocomplete-light-language="en" data-autocomplete-light-url="/myobj-autocomplete/" data-autocomplete-light-function="select2">
<option value="" selected>---------</option>
</select></div><div class="mb-3"><label class="form-label" for="id_multi_select">multi select</label><select name="multi_select" data-placeholder="Type here" data-minimum-input-length="1" class="form-select" id="id_multi_select" data-autocomplete-light-language="en" data-autocomplete-light-url="/myobj-autocomplete/" data-autocomplete-light-function="select2" multiple>
a few more screenshots:
functional multi-select open:
broken single-select open:
functional multi-select in chrome debugger:
broken single-select in chrome debugger:
Hey are you sure the CSS override doesn't work for the single choice? I used your suggestion and it seems to be working for me:
.select2-container .select2-selection--single {
min-height: 2.5rem;
}
I thought the display:block would be needed there as well, but it seems to be working without it.
I want to create a custom Date Picker component with Vue version 2 and VeeValidate. I am using vuetify and v-menu component from there: https://vuetifyjs.com/en/components/menus/ . The problem is that ValidationProvider which is responsible for validating fields accepts only one v-model inside of it and I have two: one for triggering v-menu and second for gathering value to v-text-field from v-date-picker. When I remove this v-model from v-menu validation works but I cannot close menu after I choose some values in date-picker.
<ValidationProvider v-slot="{ validate, errors }">
<label>...</label>
<v-menu v-model="menu">
<template v-slot:activator="{ on, attrs }">
<v-text-field
v-bind="attrs"
:value="formatDate"
readonly
v-on="on"
#input="$emit('input', $event) || validate($event)"
/>
</template>
<v-date-picker
:value="value"
no-title
#input="$emit('input', $event) || validate($event)"
#change="menu = false"
/>
</v-menu>
<span
v-if="errors.length > 0"
>{{ errors[0] }}</span>
</ValidationProvider>
trying to follow Xamarin tutorial for a label view at :
Label Tutorial
when applying italic font attribute in a span tag , while setting the size of the label text to any value in the label tag. the text size did not get applied to the text in the span with italic attribute.
<StackLayout Margin="20,35,20,25">
<Label FontSize="50" TextColor="Blue">
<Label.FormattedText>
<FormattedString>
<Span Text="underlined text" TextDecorations="Underline" />
<Span Text=", emphasized" FontAttributes="Italic" />
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
output from android emulator
I also found that it when the span with Italic attribute the FontSize of Label can not work. However , I found a WorkAround for this , you can set FontSize of this Span to solve it .
Have a look at follow code:
<StackLayout Margin="20,35,20,25">
<Label FontSize="50" TextColor="Blue">
<Label.FormattedText>
<FormattedString>
<Span Text="underlined text" TextDecorations="Underline" />
<Span Text=", emphasized" FontSize="50" FontAttributes="Italic" />
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
The effect :
I think next version of Xamarin Forms will fix it as soon as possible .
I want to show font-awesome icons in my nativescript application but its not showing everywhere.
<ScrollView row="0" orientation="vertical" ios.pagingEnabled="true">
<StackLayout #container verticalAlignment="center">
<Image src="res://logo_icon_white" stretch="none" horizontalAlignment="center"></Image>
<label [text]="'WELCOME' | translate" class="welcome-text" horizontalAlignment="center"></label>
<label text=" " class="font-awesome" horizontalAlignment="center"></label> <--- WORKS!
<Button [text]="'LOGIN_WITH_PASWWORD' | translate" (tap)="tapped()"></Button>
<Button>
<FormattedString>
<Span text=" " class="font-awesome"></Span> <--- DOESN'T WORK!
<Span text=" " style="font-family: FontAwesome;"></Span> <--- DOESN'T WORK!
<Span [text]="'PROCEED_WITH_FACEBOOK' | translate" ></Span>
</FormattedString>
</Button>
<Button [text]="'CREATE_AN_ACCOUNT' | translate" class="account-button"></Button>
</StackLayout>
</ScrollView>
When i use it in a Label it shows the icon but when i want to display it in a FormattedString/Button (because i use translation) it doesn't show the icon.
I hope someone can help?
The Span element currently does not support styling through CSS. You should use the span's properties to set the styling. In your case the following should work:
<Span text="" fontFamily="FontAwesome"></Span>
I have a Pivot and 5 Pivot items inside it, by an xml I am adding and removing those pivot items as per the need but the thing is I want some of my ApplicationBarIcons visible on selection of certain pivotitems and collapse on certain pivotitems view,I cannot do this by the help of checking selectedindex because dynamically they are getting changed. How can I do it?
Not sure how you are handling the loading of the app bar. Are you doing in the the XAML code or C#?
If you are doing it in C#, there should be a Visible property for the ApplicationBar object.
Be sure to check out the Cimbalino toolkit for windows phone! It has a bindable application appbar, so you can tweak the IsVisible property when you switch through the pivots! > There is a SelectionChanged event on the Pivot to track what pivot is currently active, I would check the Name of the pivot or a Tag like Techloverr suggests
Example cimbalino http://code.msdn.microsoft.com/wpapps/cimbalino-windows-phone-4de77988
You can create ApplicationBar for certain pivot items of pivot page like this using id.If id =0,it will take automatically pivot Page(Item) 0 .By using this,you can choose which all AppBars has to be in whole pivot pages and in selective pivot pages(Items).
<phone:Pivot>
<i:Interaction.Triggers>
<appBarUtils:SelectedPivotItemChangedTrigger>
<appBarUtils:SelectedPivotItemChangedTrigger.SelectionMappings>
<appBarUtils:SelectionMapping SourceIndex="0" TargetIndex="0"/>
</appBarUtils:SelectedPivotItemChangedTrigger.SelectionMappings>
<appBarUtils:SwitchAppBarAction>
<appBarUtils:AppBar Id="0" BackgroundColor="{StaticResource AppBarBg}" ForegroundColor="{StaticResource Foreground}">
<appBarUtils:AppBarButton IconUri="/Assets\Images\appbar.home.png" Text="home" Command="{Binding HomeNavigationCommand}"/>
</appBarUtils:AppBar>
<appBarUtils:AppBar Id="1" BackgroundColor="{StaticResource AppBarBg}" ForegroundColor="{StaticResource Foreground}">
<appBarUtils:AppBarButton IconUri="/Assets\Images\appbar.home.png" Text="home" Command="{Binding HomeNavigationCommand}"/>
</appBarUtils:AppBar>
<appBarUtils:AppBar Id="2" BackgroundColor="{StaticResource AppBarBg}" ForegroundColor="{StaticResource Foreground}">
<appBarUtils:AppBarButton IconUri="/Assets\Images\appbar.home.png" Text="home" Command="{Binding HomeNavigationCommand}"/>
<appBarUtils:AppBarButton IconUri="/Assets\Images\appbar.money.png" Text="collection" Command="{Binding CollectionPageCommand}"/>
<appBarUtils:AppBarButton IconUri="/Assets\Images\appbar.check.rest.png" Text="ok" Command="{Binding OrderConfirmationButtonCommand}"/>
</appBarUtils:AppBar>
<appBarUtils:AppBar Id="3" BackgroundColor="{StaticResource AppBarBg}" ForegroundColor="{StaticResource Foreground}">
<appBarUtils:AppBarButton x:Name="ConfirmationAppBarButton" IconUri="/Assets\Images\appbar.cancel.rest.png" Text="cancel" Command="{Binding OrderCancelButtonCommand}"/>
<appBarUtils:AppBarButton IconUri="/Assets\Images\appbar.check.rest.png" Text="ok" Command="{Binding OrderConfirmationButtonCommand}" IsEnabled="{Binding Model.EnableCheck,Mode=TwoWay}" />
</appBarUtils:AppBar>
</appBarUtils:SwitchAppBarAction>
</appBarUtils:SelectedPivotItemChangedTrigger>
</i:Interaction.Triggers>
</phone:Pivot>
//Assuming your views are in View Folder
Use AppBarUtils from here and refer in code.
You can have different appbars for each pivot item using the above sample code.Hope this will help you.