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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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