summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs37
1 files changed, 25 insertions, 12 deletions
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
index b2b9108a..61d0b322 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
@@ -41,6 +41,9 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
ToolbarTracker _toolbarTracker;
bool _toolbarVisible;
+ // The following is based on https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v4/java/android/support/v4/app/FragmentManager.java#849
+ const int TransitionDuration = 220;
+
public NavigationPageRenderer()
{
AutoPackage = false;
@@ -71,7 +74,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
}
}
- FragmentManager FragmentManager => _fragmentManager ?? (_fragmentManager = ((FormsAppCompatActivity)Context).SupportFragmentManager);
+ FragmentManager FragmentManager => _fragmentManager ?? (_fragmentManager = ((FormsAppCompatActivity)Context).SupportFragmentManager);
IPageController PageController => Element as IPageController;
@@ -132,14 +135,14 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
if (Element != null)
{
- foreach(Element element in PageController.InternalChildren)
+ foreach (Element element in PageController.InternalChildren)
{
var child = element as VisualElement;
if (child == null)
{
continue;
}
-
+
IVisualElementRenderer renderer = Android.Platform.GetRenderer(child);
renderer?.Dispose();
}
@@ -320,7 +323,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
else
transaction.SetTransition((int)FragmentTransit.FragmentClose);
}
-
+
internal int GetNavBarHeight()
{
if (!ToolbarVisible)
@@ -501,7 +504,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
ToolbarNavigationClickListener = new ClickListener(Element)
};
- if (_drawerListener != null)
+ if (_drawerListener != null)
{
_drawerLayout.RemoveDrawerListener(_drawerListener);
}
@@ -569,6 +572,12 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
var tcs = new TaskCompletionSource<bool>();
Fragment fragment = FragmentContainer.CreateInstance(view);
FragmentManager fm = FragmentManager;
+
+#if DEBUG
+ // Enables logging of moveToState operations to logcat
+ FragmentManager.EnableDebugLogging(true);
+#endif
+
List<Fragment> fragments = _fragmentStack;
Current = view;
@@ -599,7 +608,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
transaction.Remove(currentToRemove);
popPage = popToRoot;
}
-
+
Fragment toShow = fragments.Last();
// Execute pending transactions so that we can be sure the fragment list is accurate.
fm.ExecutePendingTransactions();
@@ -621,7 +630,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
// The fragment transitions don't really SUPPORT telling you when they end
// There are some hacks you can do, but they actually are worse than just doing this:
-
+
if (animated)
{
if (!removed)
@@ -633,12 +642,15 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
else if (_drawerToggle != null && ((INavigationPageController)Element).StackDepth == 2)
AnimateArrowOut();
- Device.StartTimer(TimeSpan.FromMilliseconds(200), () =>
+ Device.StartTimer(TimeSpan.FromMilliseconds(TransitionDuration), () =>
{
tcs.TrySetResult(true);
- fragment.UserVisibleHint = true;
+ fragment.UserVisibleHint = !removed;
if (removed)
+ {
UpdateToolbar();
+ }
+
return false;
});
}
@@ -647,8 +659,9 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
Device.StartTimer(TimeSpan.FromMilliseconds(1), () =>
{
tcs.TrySetResult(true);
- fragment.UserVisibleHint = true;
+ fragment.UserVisibleHint = !removed;
UpdateToolbar();
+
return false;
});
}
@@ -656,7 +669,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
Context.HideKeyboard(this);
((Platform)Element.Platform).NavAnimationInProgress = false;
- // 200ms is how long the animations are, and they are "reversible" in the sense that starting another one slightly before it's done is fine
+ // TransitionDuration is how long the built-in animations are, and they are "reversible" in the sense that starting another one slightly before it's done is fine
return tcs.Task;
}
@@ -821,4 +834,4 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
}
}
}
-} \ No newline at end of file
+}