Xamarin.forms: [Bug] Closed-Event for SwipeView

Created on 27 Apr 2020  路  9Comments  路  Source: xamarin/Xamarin.Forms

I am missing a Close-Event for the SwipeView if it is generally closing e.g. by tapping on the form.
There is only the event CloseRequested that only fires if I close the SwipeView programatically.
I want to use the SwipeView in a ListView-Scenario and would like to lock the ListView while the SwipeView is open.

swipeview bug

Most helpful comment

Can we get this reclassified as a bug since none of events correctly fire on Android? I am afraid that tit may not get the proper visibility due to it being labeled as an enhancement.

All 9 comments

Thanks for the suggested enhancement @HarryLobster. Actually, you can programmatically open the SwipeView using:
swipeView.Open(OpenSwipeItem.LeftItems);
And close it with:
swipeView.Close();

Related, recently the IsOpen property has also been added to SwipeEndedEventArgs. In this way, you can know if the SwipeView is open or closed when you stop swipping.

What would better cover this enhancement better, have a Closed event that is fired always when the SwipeView is closed?

As well as @HarryLobster I would really appreciate having some event to track changes of IsOpen property. The thing is that SwipeEnded event is only called when I am swiping to open the view, but when I am closing it (either by tap or by swipe) nothing is called. It allows to learn when swipe view state changes from Closed to Open, but not vice versa.

In my use case I need to change state of some elements inside the swipe view depending on whether it is open or closed (by the user). To achieve it right now I am adding a tap and a few swipe gesture recognizers and inside of them I am assuming that if the view _was open_ it's state is about to change to _closed_. It kind of works (though looks a bit hacky) but some cases of swipe view being closed are still not covered with this approach.

So it would be awesome if some sort of Closed or IsOpenChanged event was introduced that would fire every time when the state is actually changing.

Thanks for the suggested enhancement @HarryLobster. Actually, you can programmatically open the SwipeView using:
swipeView.Open(OpenSwipeItem.LeftItems);
And close it with:
swipeView.Close();

Related, recently the IsOpen property has also been added to SwipeEndedEventArgs. In this way, you can know if the SwipeView is open or closed when you stop swipping.

What would better cover this enhancement better, have a Closed event that is fired always when the SwipeView is closed?

Yes, that would solve my problem and it is logical for me that this should be implemented anyways !?

As well as @HarryLobster I would really appreciate having some event to track changes of IsOpen property. The thing is that SwipeEnded event is only called when I am swiping to open the view, but when I am closing it (either by tap or by swipe) nothing is called. It allows to learn when swipe view state changes from Closed to Open, but not vice versa.

In my use case I need to change state of some elements inside the swipe view depending on whether it is open or closed (by the user). To achieve it right now I am adding a tap and a few swipe gesture recognizers and inside of them I am assuming that if the view _was open_ it's state is about to change to _closed_. It kind of works (though looks a bit hacky) but some cases of swipe view being closed are still not covered with this approach.

So it would be awesome if some sort of Closed or IsOpenChanged event was introduced that would fire every time when the state is actually changing.

I'm using Xamarin.Forms 4.8.0.1364 and SwipeEnded event is NOT firing when SwipeView is closed on Android. Only when its opened (obviously isOpen is always true).
SwipeStarted is also fired only during opening.

@hairatic @jsuarezruiz I am using xam forms 5.0 pre-1, and I can confirm the same behaviour on Android - swipe ended only fires when opening the swipe view, not closing it. So I am unable to reliably know the open/closed state of the swipe view at any point in time. In fact there appear to be various problems with all of the exposed swipe events, as follows.

CloseRequested - never fires when swiping
OpenRequested - never fires when swiping
SwipeChanging - only fires on swiping to open, not swiping to close
SwipeEnded - only fires on swiping to open, not swiping to close
SwipeStarted -only fires on swiping to open, not swiping to close

My swipe view is inside a collectionview, running on an android physical device, samsung galaxy A30, android 10.

Although working versions of these events would be useful for me, what I am really looking for is an INotifyPropertyChanged boolean "IsOpen" on the swipe view itself, that I could check and bind UI bindable properties against.

@hairatic @jsuarezruiz I am using xam forms 5.0 pre-1, and I can confirm the same behaviour on Android - swipe ended only fires when opening the swipe view, not closing it. So I am unable to reliably know the open/closed state of the swipe view at any point in time. In fact there appear to be various problems with all of the exposed swipe events, as follows.

CloseRequested - never fires when swiping
OpenRequested - never fires when swiping
SwipeChanging - only fires on swiping to open, not swiping to close
SwipeEnded - only fires on swiping to open, not swiping to close
SwipeStarted -only fires on swiping to open, not swiping to close

My swipe view is inside a collectionview, running on an android physical device, samsung galaxy A30, android 10.

Although working versions of these events would be useful for me, what I am really looking for is an INotifyPropertyChanged boolean "IsOpen" on the swipe view itself, that I could check and bind UI bindable properties against.

It seems that 5.0.0.1558-pre3 has the same problems...

Can we get this reclassified as a bug since none of events correctly fire on Android? I am afraid that tit may not get the proper visibility due to it being labeled as an enhancement.

I have done some tests using Xamarin.Forms 5.0 in a Device using Android 10:

issue10466

The results:

  • CloseRequested - Never fires when swiping. That is correct, this only fire using the Close method.
  • OpenRequested - Never fires when swiping. That is correct, this only fires now using the Open method.
  • SwipeChanging - Fires while swiping.
  • SwipeEnded - Fires when swipe ended.
  • SwipeStarted -Fires when swipe started.

Is that your expected behavior?

Thanks @jsuarezruiz . I have upgraded to 5 pre3 and I get the same behaviour now. However SwipeChanging, SwipeEnded and SwipeStarted only seem to fire when opening the item. Once the item is open, upon swiping to close, none of the events fire. Is this expected behaviour?

Was this page helpful?
0 / 5 - 0 ratings