Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Android.Animation;
- using Android.Views;
- using System;
- using System.Threading.Tasks;
- private Task<bool> SwitchContentAsync (Page view, bool animated, bool removed = false)
- {
- NavigationRenderer.<>c__DisplayClass13_0 <>c__DisplayClass13_ = new NavigationRenderer.<>c__DisplayClass13_0 ();
- <>c__DisplayClass13_.<>4__this = this;
- base.Context.HideKeyboard (this);
- IVisualElementRenderer renderer = Platform.GetRenderer (view);
- bool flag = renderer != null;
- if (!flag) {
- Platform.SetRenderer (view, renderer = RendererFactory.GetRenderer (view));
- }
- <>c__DisplayClass13_.pageToRemove = this.current;
- NavigationRenderer.<>c__DisplayClass13_0 expr_43 = <>c__DisplayClass13_;
- expr_43.rendererToRemove = ((expr_43.pageToRemove == null) ? null : Platform.GetRenderer (<>c__DisplayClass13_.pageToRemove));
- NavigationRenderer.<>c__DisplayClass13_0 expr_5F = <>c__DisplayClass13_;
- expr_5F.containerToRemove = ((expr_5F.rendererToRemove == null) ? null : ((PageContainer)<>c__DisplayClass13_.rendererToRemove.ViewGroup.Parent));
- PageContainer pageContainer = ((PageContainer)renderer.ViewGroup.Parent) ?? new PageContainer (base.Context, renderer);
- pageContainer.SetWindowBackground ();
- this.current = view;
- ((Platform)base.Element.Platform).NavAnimationInProgress = true;
- <>c__DisplayClass13_.tcs = new TaskCompletionSource<bool> ();
- if (animated) {
- if (NavigationRenderer.currentAnimation != null) {
- NavigationRenderer.currentAnimation.Cancel ();
- }
- if (removed) {
- if (pageContainer.Parent != this) {
- this.AddView (pageContainer, base.Element.LogicalChildren.IndexOf (renderer.Element));
- }
- else {
- ((Page)renderer.Element).SendAppearing ();
- }
- pageContainer.Visibility = ViewStates.Visible;
- if (<>c__DisplayClass13_.containerToRemove != null) {
- Action<Animator> done = delegate (Animator a) {
- <>c__DisplayClass13_.containerToRemove.Visibility = ViewStates.Gone;
- <>c__DisplayClass13_.containerToRemove.set_Alpha (1);
- <>c__DisplayClass13_.containerToRemove.set_ScaleX (1);
- <>c__DisplayClass13_.containerToRemove.set_ScaleY (1);
- <>c__DisplayClass13_.<>4__this.RemoveView (<>c__DisplayClass13_.containerToRemove);
- <>c__DisplayClass13_.tcs.TrySetResult (true);
- ((Platform)<>c__DisplayClass13_.<>4__this.Element.Platform).NavAnimationInProgress = false;
- VisualElement element = <>c__DisplayClass13_.rendererToRemove.Element;
- <>c__DisplayClass13_.rendererToRemove.Dispose ();
- if (element != null) {
- Platform.SetRenderer (element, null);
- }
- };
- NavigationRenderer.currentAnimation = <>c__DisplayClass13_.containerToRemove.Animate ().Alpha (0).ScaleX (0.8).ScaleY (0.8).SetDuration (250).SetListener (new GenericAnimatorListener {
- OnEnd = delegate (Animator a) {
- NavigationRenderer.currentAnimation = null;
- done (a);
- },
- OnCancel = done
- });
- }
- }
- else {
- if (pageContainer.Parent != this) {
- this.AddView (pageContainer);
- }
- else {
- ((Page)renderer.Element).SendAppearing ();
- }
- if (flag) {
- base.Element.ForceLayout ();
- }
- pageContainer.set_Alpha (0);
- PageContainer expr_1FA = pageContainer;
- float scaleX;
- expr_1FA.set_ScaleY (scaleX = 0.8);
- expr_1FA.set_ScaleX (scaleX);
- pageContainer.Visibility = ViewStates.Visible;
- NavigationRenderer.currentAnimation = pageContainer.Animate ().Alpha (1).ScaleX (1).ScaleY (1).SetDuration (250).SetListener (new GenericAnimatorListener {
- OnEnd = delegate (Animator a) {
- if (<>c__DisplayClass13_.containerToRemove != null && <>c__DisplayClass13_.containerToRemove.Handle != IntPtr.Zero) {
- <>c__DisplayClass13_.containerToRemove.Visibility = ViewStates.Gone;
- if (<>c__DisplayClass13_.pageToRemove != null) {
- <>c__DisplayClass13_.pageToRemove.SendDisappearing ();
- }
- }
- NavigationRenderer.currentAnimation = null;
- <>c__DisplayClass13_.tcs.TrySetResult (true);
- ((Platform)<>c__DisplayClass13_.<>4__this.Element.Platform).NavAnimationInProgress = false;
- }
- });
- }
- }
- else {
- if (<>c__DisplayClass13_.containerToRemove != null) {
- if (removed) {
- this.RemoveView (<>c__DisplayClass13_.containerToRemove);
- }
- else {
- <>c__DisplayClass13_.containerToRemove.Visibility = ViewStates.Gone;
- }
- }
- if (pageContainer.Parent != this) {
- this.AddView (pageContainer);
- }
- else {
- ((Page)renderer.Element).SendAppearing ();
- }
- if (<>c__DisplayClass13_.containerToRemove != null && !removed) {
- <>c__DisplayClass13_.pageToRemove.SendDisappearing ();
- }
- if (flag) {
- base.Element.ForceLayout ();
- }
- pageContainer.Visibility = ViewStates.Visible;
- <>c__DisplayClass13_.tcs.SetResult (true);
- ((Platform)base.Element.Platform).NavAnimationInProgress = false;
- }
- return <>c__DisplayClass13_.tcs.get_Task ();
- }
Advertisement
Add Comment
Please, Sign In to add comment