How to enable swipe gesture when tabView is positioned bottom - nativescript

I am using nativescript-vue and I wanted to play around with tab-view. The problem is, when I set my tabs to be positioned at the bottom of the screen, the swipe gesture no longer works and is somewhat disabled. I want to enable swipe gesture.
Because I'm new to native-script or android, I'm not really sure how to enable it.
<Page actionBarHidden="true">
<TabView androidTabsPosition="bottom">
<TabViewItem title="Tab 1">
<GridLayout columns="*" rows="*">
<Label class="message" :text="msg" col="0" row="0"/>
</GridLayout>
</TabViewItem>
<TabViewItem title="Tab 2">
<GridLayout columns="*" rows="*">
<Label class="message" text="Tab 2 Content"/>
</GridLayout>
</TabViewItem>
<TabViewItem title="Tab 3">
<GridLayout columns="*" rows="*">
<Label class="message" text="Tab 3 Content"/>
</GridLayout>
</TabViewItem>
</TabView>
</Page>
The above script creates tabview with 3 tabs, but the problem is, now you can't swipe between the tabs. If I set androidTabsPosition="top", then swipe gesture works.
Can someone please enlighten me how to enable swipe gestures.
Here's the documentary for tabView in nativescript-vue

Enable swipe on the view pager from the TabView's loaded event. I didn't notice any side effect with this behaviour, incase if you hit anything let me know.
Template
...
<TabView androidTabsPosition="bottom" #loaded="onTabViewLoaded">
...
JS
onTabViewLoaded: function(args) {
if (args.object.android) {
args.object.android.viewPager.setSwipePageEnabled(true);
}
}

Related

Nativescript - having a scrollView in a GridLayout not working on iOS

I'm trying to create a layout that has a button row at the top and then a scrollView beneath that:
<GridLayout columns="*,40,10" rows="10,40,*">
<Label row="1" col="1" text="X" tap="close" />
<ScrollView orientation="vertical" col="0" row="2" colSpan="3">
…
</ScrollView>
</GridLayout>
This works on Android, I get a ScrollView that's 50 from the top and the Label with the «X» in it on top.
On iOS, the ScrollView always is at the top of the view, overlapping the «X»-Label.
Any ideas what I'm doing wrong?
NS 8.x
I suspect the issue is that you have two rows but reference them as 1 and 2 rather than 0 and 1.

Tap event is incorrectly fired when swiping a RadListView

I have a RadListView that displays a list of items. In each item template I have a (tap) event that fires when tapping on the item, to redirect to the item details screen. However, for some reason whenever I swipe the RadListView vertically to traverse the list, it fires the (tap) event wherever I start swiping from and incorrectly redirects to the item details screen instead of just moving up or down the list.
<RadListView
class="list transparent"
[class.visible]="!data.loading"
[visibility]="!data.loading ? 'visible' : 'collapse'"
[items]="data.items"
swipeActions="true"
(itemSwipeProgressStarted)="onSwipeCellStarted($event)">
<ng-template let-item="item">
<StackLayout class="item" orientation="horizontal" (tap)="view(item)">
<Image
[src]="item.photos?.length ? item.photos[0] : ''"
[visibility]="item.photos?.length ? 'visible' : 'collapse'">
</Image>
<StackLayout orientation="vertical">
<Label
class="title"
[text]="item.address">
</Label>
</StackLayout>
</StackLayout>
</ng-template>
<GridLayout *tkListItemSwipeTemplate columns="*, auto">
<StackLayout id="delete" col="1" (tap)="deleteRow($event)" class="delete">
<Label class="fas" [text]="IconsEnum.trashAlt"></Label>
</StackLayout>
</GridLayout>
</RadListView>
I tried getting rid of the (tap) event and instead using the following on the RadListView:
multipleSelection="false" selectionBehavior="Press" (itemSelected)="itemSelected($event)"
That resolved the issue with swiping, however it introduced a new issue where it would only select an item every two taps instead of every swipe.
What is the proper way to select an item from a RadListView?
Upgrading from #nativescript/ios 7.1.1 to 7.2.0 resolved this bug.

Nativescript ScrollView not showing on ios

I have AbsoluteLayout in ScrollView with pager and custom components inside Pager. The code is working on Android, but on iOS is nothing shown. Does anyone have some solution?
<ScrollView>
<AbsoluteLayout>
<Pager row="1" #pager [selectedIndex]="currentPagerIndex" width="100%">
<ns-dashboard-profile height="100" *pagerItem></ns-dashboard-profile>
<ns-dashboard-home *pagerItem></ns-dashboard-home>
<ns-dashboard-devices *pagerItem></ns-dashboard-devices>
</Pager>
<FlexboxLayout class="navigation-wrapper" top="230">
<Label text="Profil" (tap)="goToPage('profile')" class="profile-tab"></Label>
<Label text="Početna" (tap)="goToPage('home')" class="home-tab"></Label>
<Label text="Moji uređaji" (tap)="goToPage('devices')" class="my-device-tab"></Label>
</FlexboxLayout>
</AbsoluteLayout>
ScrollView closing tag is not shown in the code snippet.

iOS buttons become unclickable after making a floating layout

I'm creating a custom action bar and my idea is that the actionbar must be transparent (thats why I can't/don't want to use the native one) and behind the action bar there must be content (an image in this case).
I tried multiple ways and all of them with the same result, the iOS button become unclickable for no reason.
Ok, so I have an AbsoluteLayout inside I have GridLayout fixed on top as the custom actionbar and then a ScrollView with 100% width and height, inside the scrollview there's some content. The problem is as soon as I put a button inside the GridLayout this become unclickable only on iOS because in Android works just fine.
Let me show you my example with some code:
<Page actionBarHidden="true">
<AbsoluteLayout>
<GridLayout rows="50, *" backgroundColor="red" top="0" left="0" height="50" id="bar">
<Button text="click" #tap="goToDetailPage" id="buttondelsous"></Button>
</GridLayout>
<ScrollView backgroundColor="blue" width="100%" height="100%" top="0" id="content">
<WrapLayout>
<StackLayout>
<Label text="this is behind"></Label>
</StackLayout>
</WrapLayout>
</ScrollView>
</AbsoluteLayout>
</Page>
As for the styles forcing the custom actionbar being in front of the scrollview I have:
#bar {
z-index: 5;
width: 100%;
}
#content {
z-index: 2;
}
This looks like this on Android:
Same way on iOS but the button "Click" is not working, like if it was behind something..
Any idea on how to fix this or any other approach to get what I need? Remember behind the action I must be able to place content (like a background image that I don't want to place in the Page tag itself but in another layout)
Thanks!
A wise man once told me that Nativescript stacks elements in the order you list them. Try flipping around the order so the button is listed last in the template. I believe you won't even need the z-index line if you flip the order around.
should look like
<Page actionBarHidden="true">
<AbsoluteLayout>
<ScrollView backgroundColor="blue" width="100%" height="100%" top="0" id="content">
<WrapLayout>
<StackLayout>
<Label text="this is behind"></Label>
</StackLayout>
</WrapLayout>
</ScrollView>
<!-- I'm listed second so I will be on top even though I have row="0" -->
<GridLayout rows="50, *" backgroundColor="red" top="0" left="0" height="50" id="bar">
<Button text="click" #tap="goToDetailPage" id="buttondelsous"/>
</GridLayout>
</AbsoluteLayout>
</Page>

Nativescript Tabview is not rendered at all but there is no exception/error either

In my HTML file I have this markup: While the ActionBar shows the title , the tabviews in the stacklayout are not visible at all and I get no errors, but I do not understand why??? I am new to nativescript... ;-)
Anyone can see what I do wrong?
<ActionBar title="Working days planner" class="action-bar">
</ActionBar>
<StackLayout class="page">
<TabView id="tabViewContainer">
<TabViewItem title="First Tab">
<StackLayout>
<Label text="Working days" class="action-label m-15"></Label>
<ListView [items]="items" class="list-group">
<ng-template let-item="item">
<Label [nsRouterLink]="['/item', item.id]" [text]="item.name" class="list-group-item"></Label>
</ng-template>
</ListView>
</StackLayout>
</TabViewItem>
<TabViewItem title="Second Tab">
<StackLayout>
<Label text="Second Tab" textWrap="true" class="m-15 h2 text-left" color="blue"></Label>
</StackLayout>
</TabViewItem>
</TabView>
</StackLayout>
The StackLayout code in the first TabViewItem does work when its put under the ActionBar, but the TabView component somehow screws everything.
I haven't seen that syntax with the TabViewItem element. Try starting from a simpler example from the documentation page:
NativeScript TabView for Angular
Once you get a basic example working take incremental steps to change the content over to yours. Also, this is a basic feature so you can set up a Playground example and share that if you have specific problems.
Try removing the StackLayout above, you really don't need it.

Resources