Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] SlideFlyoutTransition is not working after the xamarin forms update to xamarin forms 5 #13390

Closed
Srikanth540-L opened this issue Jan 13, 2021 · 0 comments · Fixed by #13494 · May be fixed by aleks-ivanov/maui#9
Closed
Labels
a/rtl s/unverified New report that has yet to be verified t/bug 🐛
Milestone

Comments

@Srikanth540-L
Copy link

Srikanth540-L commented Jan 13, 2021

SlideFlyoutTransition is not working after the xamarin forms update to xamarin forms 5

Description

We have requirement where the hamburger icon is in the right side of the screen and the flyout should move from RTL but the bottom tabs follow LTR to accomplish this we have gone for CustomShellRenderer where for iOS we are handling the transition.

at Xamarin.Forms.Platform.iOS.ShellFlyoutRenderer.Xamarin.Forms.IAppearanceObserver.OnAppearanceChanged (Xamarin.Forms.ShellAppearance appearance) [0x00022] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellFlyoutRenderer.cs:25
at Xamarin.Forms.Shell.Xamarin.Forms.IShellController.AddAppearanceObserver (Xamarin.Forms.IAppearanceObserver observer, Xamarin.Forms.Element pivot) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\Shell\Shell.cs:311
at Xamarin.Forms.Platform.iOS.ShellFlyoutRenderer.Xamarin.Forms.Platform.iOS.IShellFlyoutRenderer.AttachFlyout (Xamarin.Forms.Platform.iOS.IShellContext context, UIKit.UIViewController content) [0x000b5] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellFlyoutRenderer.cs:83
at Xamarin.Forms.Platform.iOS.ShellRenderer.get_FlyoutRenderer () [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellRenderer.cs:76
at Xamarin.Forms.Platform.iOS.ShellRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellRenderer.cs:86
at Xamarin.Forms.Platform.iOS.Platform.AddChild (Xamarin.Forms.VisualElement view) [0x00035] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:356
at Xamarin.Forms.Platform.iOS.Platform.WillAppear () [0x0003c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:339
at Xamarin.Forms.Platform.iOS.PlatformRenderer.ViewWillAppear (System.Boolean animated) [0x00018] in D:\a\1\s\Xamarin.Forms.Platform.iOS\PlatformRenderer.cs:95
at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(intptr,intptr,intptr)
at UIKit.UIWindow.set_RootViewController (UIKit.UIViewController value) [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.6.0.15/src/Xamarin.iOS/UIKit/UIWindow.g.cs:399
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.UpdateMainPage () [0x0002d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:202
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.ApplicationOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00012] in D:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:152
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362
at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page value) [0x0008b] in D:\a\1\s\Xamarin.Forms.Core\Application.cs:93
at AspenConnect.Services.NavigationService.GoToHome () [0x00008] in /Users/733728/Documents/GitHub/AspenConnect/AspenConnect/AspenConnect/Services/NavigationService.cs:217
at AspenConnect.ViewModels.LogInPageViewModel.OpenSettings (System.Boolean isFromLogin) [0x00231] in /Users/733728/Documents/GitHub/AspenConnect/AspenConnect/AspenConnect/ViewModels/LogInPageViewModel.cs:360

Steps to Reproduce

  1. Update the xamarin forms version to 5
  2. Add the above code to make your flyout transition from RTL
  3. Deploy the app in iOS device or simulator

Expected Behavior

Should work as it worked for prior stable version 4.8.

Actual Behavior

Not working is xamarin forms 5

Basic Information

  • Version with issue:

  • Last known good version:

  • Platform Target Frameworks:

    • iOS:
  • NuGet Packages: xamarin forms 5

  • Affected Devices: All iOS devices

Environment

LayoutViews will get for every click on hamburger icon but when we update the forms version to 5 it's not working and failing with above stack trace:

Show/Hide Visual Studio info
public class CustomShellRenderer : ShellRenderer
    {
      
        protected override IShellFlyoutRenderer CreateFlyoutRenderer()
        {
            return new ShellFlyoutRenderer()
            {
                FlyoutTransition = new SlideFlyoutTransition()
            };
        }
    }

public class SlideFlyoutTransition : IShellFlyoutTransition
    {
        public void LayoutViews(CGRect bounds, nfloat openPercent, UIView flyout, UIView shell, FlyoutBehavior behavior)
        {
           
            nfloat flyoutWidth = (nfloat)(Math.Min(bounds.Width, bounds.Height) * 0.9);
            nfloat openLimit = flyoutWidth;
            nfloat openPixels = openLimit * openPercent;

            if (behavior == FlyoutBehavior.Locked)
                shell.Frame = new CGRect(bounds.X + flyoutWidth, bounds.Y, bounds.Width - flyoutWidth, bounds.Height);
            else
                shell.Frame = bounds;

            var shellWidth = shell.Frame.Width;

            var positionY = shellWidth - openPixels;

            flyout.Frame = new CGRect(positionY, 0, flyoutWidth, bounds.Height);
        }
    }

Build Logs

Screenshots

Reproduction Link

Workaround

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/rtl s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
3 participants