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

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

Closed
wants to merge 5 commits into from

Conversation

cpraehaus
Copy link
Contributor

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

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)

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. It looks nice but being a change that could have an impact in several cases, could you include a test?.

@cpraehaus
Copy link
Contributor Author

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

@thisisthekap
Copy link
Contributor

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

@jfversluis
Copy link
Member

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 jfversluis closed this Apr 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] Resize on "BackSwipe" stays when going back is cancelled
4 participants