Forum Xamarin Xamarin.Forms

Open FlyLayout only using Hamburger icon and disable swipe behavior to open FlyLayout view of shell

JoannaGJoannaG Member ✭✭

Summary
In my application, I need to show FlyoutItems only when I tap HamburgerIcon but not through swiping left to right. Do you have any solution for this for Android & iOS? Can you enable this option using any bool property?

API Changes
Here, FlyoutLayout behaves differently for iPad & iPhone.
In iPhone - FlyLayout opens only on swiping from left dead of the screen but not on swiping middle or right of the screen.
In iPad - FlyLayout opens on swiping anywhere in the shell page middle, left.
I can't use FlyLayoutBehavior as Locked in my MapViewScreen.
It will be helpful if you expose 2 different properties or additional property in FlyLayout behavior to disable swipe open the FlyLayout.

or kindly provide me any code solution to achieve this requirement using the renderer of the Android & iOS platform to overcome this behavior.
It will be really helpful. Thanks in advance...

Best Answer

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Xamarin shell does not provide the api to disable swipe gesture, even in custom renderer i didn't find any possible workaround , consider raising this feature request here: https://github.com/xamarin/Xamarin.Forms/issues .

  • JoannaGJoannaG Member ✭✭

    I have already logged as a feature request.
    FYI, https://github.com/xamarin/Xamarin.Forms/issues/9896

  • ColeXColeX Member, Xamarin Team Xamurai

    Good , let's wait for response .

  • JoannaGJoannaG Member ✭✭

    @ColeX ,
    https://github.com/xamarin/Xamarin.Forms/issues/9896#issuecomment-598202607

    It seems that they have closed the report. Still, I added my comment. Any suggestions from your side?

  • JoannaGJoannaG Member ✭✭
    edited March 19

    @ColeX ,

    Your solution works great for me as expected in iPhone, i could able to avoid swipe by disabling panGesture but

    in iPad it crash as Null reference exception.

    Property is displaying Null. Do you use different property for iPad.

    FYI. My app have been implemented to 80% using Shell features. So changing to MasterDetailPage will become tragic. Will try to use above work around for iPad also once you provide further details.

  • ColeXColeX Member, Xamarin Team Xamurai

    Solution for android

        [assembly: ExportRenderer(typeof(AppShell), typeof(AndroidShellRenderer))]
        namespace TestMenuSwipe.Droid
        {
                        public class AndroidShellRenderer : ShellRenderer
                        {
    
                                        public AndroidShellRenderer(Context context) : base(context)
                                        {                                              
                                        }
    
                                        protected override IShellFlyoutRenderer CreateShellFlyoutRenderer()
                                        {
                                                        var flyoutRenderer = base.CreateShellFlyoutRenderer();
                                                        flyoutRenderer.AndroidView.Touch += AndroidView_Touch;                                        
                                                        return flyoutRenderer;
                                        }
    
                                        private void AndroidView_Touch(object sender, Android.Views.View.TouchEventArgs e)
                                        {
                                                        if (e.Event.Action == MotionEventActions.Move)
                                                                        e.Handled = true;
                                                        else
                                                                        e.Handled = false;
                                        }
                        }
        }
    

    I will research the issue in ipad , if i make it i will update here .

  • JoannaGJoannaG Member ✭✭

    Okay.
    Thanks for your valuable response.

    The issue is very apparent in the iPad when but not most on the iPhone or Android devices. That's what we are trying to overcome. We are waiting for your solution in the iPad.

  • JoannaGJoannaG Member ✭✭
    @ColeX ,

    Did you find any possible solution in iPad !!! :(
  • JoannaGJoannaG Member ✭✭

    @ColeX ,

    Any luck with that issue in iPad?...

  • JoannaGJoannaG Member ✭✭
    edited March 21

    @ColeX ,
    You can see in iPad when you swipe from middle, FlyLayout opens casually.
    but in iPhone it opens only when you swipe from left end.

Sign In or Register to comment.