Nativescript - swipe gestures not working reliably - nativescript

I've got a listview and would like to get notification of swipe-down events.
In the loaded event, I have:
`
let listview = page.getViewById("listView");
listview.on(gestures.GestureTypes.swipe, (args: gestures.SwipeGestureEventData) =>
{
console.log("Swipe dir=" + args.direction );
});
`
I do get swipe notifications - but I have to swipe more than a few times.
Swipe up seems to work better than swipe down.
This behavior is the same on emulator and Android device.
I changed it to
<ListView id="listView" swipe="onItemSwipe">..</ListView>
Same behavior...initially difficult to get both swipe UP and DOWN to work. After some time UP starts to work and then DOWN...but intermittent initially and then more reliably...but not 100%

Related

Xamarin Forms Scrollview and using Drag and Drop Gesture Recognizer

I have a scrollview that has a bindable stacklayout inside it with a Item template that is using the drag and drop gesture recognizer. This works no problem but on android the drag gesture recognizer fires off immediately as soon as you start scrolling the screen. I'm curious if anyone has any ideas on how to handle keeping the gesture recognizer but also allow for the user to scroll the screen without dragging around an item in the list.

Using infinite scrolling UICollectionView with iOS 13 pullable modals

I have a modal window, which is perfect for iOS 13's drag to dismiss gesture, because this way the user remains in the context, so I don't want to use full screen. The controller contains a UICollectionView which displays a month calendar, which is scrollable vertically.
The problem is, that when the user wants to scroll upwards in the collection view, the dismiss gesture is triggered instead. If I scroll down first, then can I only scroll up.
I've tried to disable the internal UIPanGestureRecognizer (it seems somehow there is no presentedView, so it didn't work), tried to set the UICollectionView's pan gesture recognizer delegate to prevent the system recognizer to fire (it turned out you can't do that), and tried to scroll the collection view on appearing a bit (ugly).
How can I elegantly convince the the modal presentation, that my scrollview isn't scrolled to the top?

Place a timer in a Xamarin Carousel page

I would like to place a timer in a Xamarin Forms carousel page, to make the 'swipe' happen automatically if the user does nothing.
Being new to Xamarin I'm not entirely sure if I can do this as I would outwith Xamarin, by creating a System.Timer in code-behind.
The auto swipe should happen after 3 seconds, and swipe through the carousel at 3 second intervals.
Can anyone tell me if this is a viable approach?
Solved it by using:
Device.StartTimer(TimeSpan.FromSeconds(3), () =>
{
// run swipe code
Task.WaitAll(_scvm.MoveNext());
return true;
});
After the InitialzeComponent() line

Why would dragging a Xamarin scrollview not work when the mouse does work

I have a very simple Xamarin forms app which contains a scrollview, and inside is a stacklayout.
When deployed on Windows, the mouse works correctly to scroll the scrollview with a scrollbar. However, touch/drag does not work at all to scroll the same control. Do I have to do something special to enable touch/drag to scroll? I figured this would just work.
I'm not sure even where to start troubleshooting.
I am targeting Windows 10. Other platforms optional at this point.
The structure of UI classes I have is this:
ContentPage.Content = StackLayout1
StackLayout1.Children = { StackLayout2, Scrollview }
StackLayout2 contains an entry field and two buttons
ScrollView, which is the problem, contains another StackLayout
Inside that I have some labels and some grids
Following is a simplified repro. Running in the android emulator on my (touch capable) dev machine scrolling with touch works, running in the Windows 8.1 emulator, scrolling only works with a mouse, not with touch.
public App() {
StackLayout sl = new StackLayout();
for (int i = 1; i < 20; i++) {
sl.Children.Add( new Label { Text = "Label1", FontSize = 50, HeightRequest = 100 } );
}
ScrollView sv = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand };
sv.Content = sl;
ContentPage cp = new ContentPage();
cp.Content = sv;
MainPage = cp;
}
Does Xamarin not handle Windows devices with touch, like Surface or other windows tablets? Or?
There is an overriden method from Activity which is: public boolean onTouchEvent(MotionEvent event)
This is the general method that interprets all the touch events from the whole screen.
As you know every View has its own onTouchEvent() method that you could implement in order to add some custom implementation.It appears that these touch events go from the "inside" elements to the "outside" elements. I mean parent-child relations.
So in our case, the ScrollView returns true when the touch events are a horizontal. The activity's touch event will be handled only if the ScrollView touch event is not handled by itself then you are fine. Otherwise you have to override and implement the on touch event of scroll view and in some cases you have to return false so as for the whole layout to implement it.
The solution is to update Xamarin v2.0.0.6482, which came with my VS 2015 template, to v2.1.0.6529. Updating is a bit of a pain because of this problem https://bugzilla.xamarin.com/show_bug.cgi?id=39721. Once I got that installed scrolling started working with no other changes.
Scrolling is broken in the older version, on Windows, verified by a dev on the Xamarin forums.

Android Wear Horizontal ListView

I'm trying to realize this layout in android wear: Timer Custom App. I think this is like a listview with horizontal orientation, but WearableListView doesn't have this attribute.
Try using a GridViewPager and setting negative page margins :
pager = (GridViewPager) stub.findViewById(R.id.fragment_container);
pager.setPageMargins(0, -30);
You can then implement onClick listeners on the fragments to change the current page by just clicking at the right or left of the page like the native alarm app.

Resources