Open Centurys opened 3 years ago
@Centurys
Unless I'm mistaken, you can determine the percentage swipe position by comparing the Offset value to the Threshold setting. Once the Offset value reaches 60% of the Threshold value it should be IsOpen... and when it goes back below IsOpen would be false again. You can get the Threshold value from the Sender parameter (which is the SwipeView itself). So adding the property to the SwipeChangingEventArgs isn't really needed.
[edit] It would seem that unless you specifically set the SwipeView.Threshold value, it is 0 (the default). In this case it attempts to use the total width of the SwipeItems collection if horizontal or the height of the SwipeItems if vertical.
@bakerhillpins yes you can code some workaround as I did (which works only on some cases), but universal code where this universal calculation happens is at: Xamarin.Forms.Platform.Android/Renderers/SwipeViewRenderer.cs So I think for simplicity reasons is better that calculation results are coming from there is simple result values, rather we do same calculation locally.
I like the idea of this, i have a screen i'd like to replicate the functionality found in the iOS Outlook app, where the swipe hits a threshold and the icon changes and haptics are triggered to let the user know it'll execute. The standard execute is a bit plain compared with this, and the reveal mode is okay but not as nice either.
Summary
Would be very good to control UI when
SwipeView
swipe gesture onMode=SwipeMode.Execute
would be executed. I would like to show to the user with visual change when swipe is executed, e.g. user would see visually if finger release would cause action to be invoked and when it would nothing happens, this is already calculated onSwipeEndedEventArgs
propertyIsOpen
.And to configure control custom percentage value when action is invoked, now is hardcoded here: https://github.com/xamarin/Xamarin.Forms/blob/b0ec43649c67165cacb3e7fa5e4842ed56405362/Xamarin.Forms.Platform.Android/Renderers/SwipeViewRenderer.cs#L27
API Changes
Add to
SwipeView
class propertyOpenSwipeThresholdPercentage
to control default percentage, could be min and max values required (e.g. 10-90%). Usage of this property could be similar like existing property Threshold.SwipeView
class hasSwipeChanging
event, this event is fired when user do swipe motion, returnsSwipeChangingEventArgs
class. Add to this class newbool
propertyIsOpen
. Implementation would be exactly same as inSwipeEnded
eventSwipeEndedEventArgs
classIsOpen
property.e.g.
Intended Use Case
More fine grained control on app visual appearance.