Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

Fix layout size when iOS swipe-back gesture is aborted, fixes #14763

Open cpraehaus opened this issue 4 years ago • 2 comments

Description of Change

Consider two pages on nav stack: Home page without nav bar (HasNavigationBar = false) and SubPage with nav bar (HasNavigationBar = true). Currently SubPage is visible.

The user can navigate back to Home page using swipe-back gesture (see screen video). During swipe-back gesture, the next view (Home) starts to appear (ViewWillAppear called) but if the user aborts or reverts the swipe then transition to next view will be aborted (ViewDidAppear not called). In this case SubPage remains the current page.

In the transition phase caused by the active swipe-back gesture, NavigationController.NavigationBarHidden will already be set based on the next page HasNavigationBar property (false in our example). But if the user cancels the swipe the App remains on (or kind of returns to) the current page (SubPage) - which has the navigation bar enabled.

In the above scenario we we need to ensure that navigation bar state is correct and consistent with layout and dimensions of our current page. Otherwise SubPage assumes that it has full height available. This PR does this by calling NavigationRenderer.ValidateNavbarExists from (ParentViewController.UpdateNavigationBarVisibility). For this to work I had to adapt the semantics of _hasNavigationBar.

PR also contains a test to reproduce the issue and verify the fix (under test cases for controls).

Issues Resolved

  • fixes #14763

API Changes

None

Platforms Affected

  • iOS

Behavioral/Visual Changes

See screen videos.

Before/After Screenshots

BEFORE fix: https://user-images.githubusercontent.com/22767700/142003062-8af4d5ab-ae3b-4f19-a3a7-0dcd7205f90e.MP4

AFTER fix: https://user-images.githubusercontent.com/22767700/142003089-1a2a5e02-ed56-4537-b1e2-bcdc9801a7cd.MP4

Testing Procedure

Launch Xamarin.Forms.ControlGallery.Android, go to test cases and navigate to issue 14763. Go to next page and go back using swipe-back gesture. When aborting swipe-back gesture the back button at the bottom should correctly appear on the bottom.

PR Checklist

  • [] Targets the correct branch
  • [] Tests are passing (or failures are unrelated)

cpraehaus avatar Nov 16 '21 14:11 cpraehaus

@jsuarezruiz Integrated your feedback. Can you have another look at this PR, please?

cpraehaus avatar Dec 06 '21 07:12 cpraehaus

@jfversluis Any chance that this one is making it into a Xamarin.Forms service release?

thisisthekap avatar Jan 18 '24 10:01 thisisthekap

Now that we're so close to the sunsetting of Xamarin.Forms unfortunately we won't be able to take this in anymore, we're really sorry about that. Nevertheless, thank you so much for your time and effort that you have put into this PR.

Please have a look at the evolution of Xamarin.Forms, .NET MAUI. A lot of development has been going on there. Hopefully this issue was already fixed in that codebase. If not, feel free to port this over to there.

Again, thank you so much for being a contributor and Xamarin.Forms user!

jfversluis avatar Apr 25 '24 08:04 jfversluis