xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[iOS] V3.0 Unexpected left margin inside the ListView control, after the control is moved outside of the screen boundaries and back (iPhone X devices in Portrait mode only) #4599

Open skolesni opened 5 years ago

skolesni commented 5 years ago

Description

The Xamarin.Forms.ListView control on iOS introduces unexpected left margin after being shifted outside of the screen boundary and back using the TransformX function. This only happens on iPhone X devices in Landscape mode.

In this scenario, I create a slide in menu, which uses ListView control to display Menu Items. When the user taps on the "Menu" button (see screenshots in the sample solution below), the menu slides in from the left. When the user dismisses the menu, it slides out back to the left. Once the menu panel control is created, it stays hidden outside the boundaries of the view. The menu panel control is created dynamically, placed outside of the view and attached to the parent control, then its position is manipulated using TransformX with animation.

Here is the sample solution which demonstrates the issue: https://github.com/skolesni/Issues.ListViewTranslate.Forms

This code has been working in a number of production apps since 2016. Since the introduction of the iPhone X devices (with the notch) the issue started to appear only on iPhone X devices. The code works fine on any pre-iPhone X devices, e.g. iPhone 8, iPhone 8 Plus, etc., on Android and UWP.

I have tried different approaches to create a sliding effect of the menu, but never get satisfying results with the ListView in the scope of affected devices. If I use other controls, such as StackLayout of items, the solution works as expected.

Once the sample solution is downloaded, please have a look at the screenshots in the "Screenshots" folder.

Steps to Reproduce

  1. Download the solution from GitHub repo given above.
  2. Start the app on iOS X device or iOS X simulator in portrait (normal) mode.
  3. Tap the "Menu" button - note that the menu slides in from the left, and the remaining screen is dimmed.
  4. Observe that the "Home", "Messages", "Settings" and "About" menu items have a correct 16px margin on the left
  5. Tap on "Messages" item, this will highlight the item. This proves that the ListView is working as expected
  6. Tap anywhere outside the menu panel to close it
  7. Repeat step 2 again and observe that the menu appears as expected
  8. Close the menu
  9. Rotate device Counter-Clockwise to turn the device to the Landscape mode
  10. Tap the "Menu" button - note that the menu slides in from the left
  11. Observe that this time the "Home", "Messages", "Settings" and "About" menu items are shifted significantly to the right (see screenshot file "Simulator Screen Shot - iPhone XR - Landscape.png")
  12. Close the menu item
  13. Rotate device Clockwise to turn the device to the Portrait mode again
  14. Observe that the menu appears as expected

Expected Behavior

There is no unexpected margin on the left in the menu panel

Actual Behavior

There is an unexpected margin of approximately 75px on the left in the menu panel

Basic Information

For a brief description of the solution, please refer to the "readme.md" file in the https://github.com/skolesni/Issues.ListViewTranslate.Forms repository

Screenshots

Screenshots are provided in the "Screenshots" folder of the https://github.com/skolesni/Issues.ListViewTranslate.Forms repository

skolesni commented 5 years ago

Hi guys, just wnted to check roughly when someone can look into this. Thanks.

kingces95 commented 5 years ago

Yep. Repro works. On iPhone X the left margin is greater than on, say, iPhone 8 Plus.

skolesni commented 5 years ago

Hi guys, just decied to check the status of the bug on New Year Eve ;) Wish you all a great new year, and looking forward to see this bug and others disappear. All the best!

pauldipietro commented 5 years ago

Hi @skolesni, many people are still on holidays for Christmas and New Year's Day. This issue appears to have been triaged, and should be added to a sprint project (visible on the projects tab) when the work is scheduled. We also welcome contributions from the community for any open issues, as usual.

skolesni commented 5 years ago

Good day guys, just wanted to check what is the priority to resolve this issue? @kingces95 or @pauldipietro could you please provide an update?

skolesni commented 5 years ago

Hi all. Not sure whether will have some luck, but if anyone could comment on whether this issue is being addressed, or has a reasonable workaround? @kingces95 or @pauldipietro could you please provide an update? Thank you.

skolesni commented 5 years ago

Hi guys, I have retested this issue on Xamarin.Forms 3.6 and it is still there. What's your proposed workaround?