From: Jaehyun Cho Date: Mon, 5 Dec 2022 08:16:09 +0000 (+0900) Subject: [NUI] Fix Navigator to enable multiple Pop() X-Git-Tag: submit/tizen_7.0/20230310.150933~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c38e3f188e969b07916f2ed648db4320b780bcb;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix Navigator to enable multiple Pop() A popped page is removed in the Pop() animation's Finished callback. Previously, Navigator could not support multiple Pop(). Because Pop() simply stopped the previous Pop() animation without calling the animation's Finished callback. Now, Pop() stops the previous Pop() animation with calling the animation's Finished callback by emitting FinishedSignal(). Consequently, Navigator can support multiple Pop() now. --- diff --git a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs index 365c56d..a2bc20d 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs @@ -403,6 +403,9 @@ namespace Tizen.NUI.Components //Duplicate page is not pushed. if (navigationPages.Contains(page)) return; + //TODO: The following transition codes will be replaced with view transition. + InitializeAnimation(); + var curTop = Peek(); if (!curTop) @@ -421,9 +424,6 @@ namespace Tizen.NUI.Components curTop.SaveKeyFocus(); - //TODO: The following transition codes will be replaced with view transition. - InitializeAnimation(); - if (page is DialogPage == false) { curAnimation = new Animation(DefaultTransitionDuration); @@ -485,6 +485,9 @@ namespace Tizen.NUI.Components throw new InvalidOperationException("There is no page in Navigator."); } + //TODO: The following transition codes will be replaced with view transition. + InitializeAnimation(); + var curTop = Peek(); if (navigationPages.Count == 1) @@ -504,9 +507,6 @@ namespace Tizen.NUI.Components curTop.InvokeDisappearing(); curTop.SaveKeyFocus(); - //TODO: The following transition codes will be replaced with view transition. - InitializeAnimation(); - if (curTop is DialogPage == false) { curAnimation = new Animation(DefaultTransitionDuration); @@ -1081,17 +1081,50 @@ namespace Tizen.NUI.Components //TODO: The following transition codes will be replaced with view transition. private void InitializeAnimation() { + bool isCurAnimPlaying = false; + bool isNewAnimPlaying = false; + if (curAnimation != null) { - curAnimation.Stop(); + if (curAnimation.State == Animation.States.Playing) + { + isCurAnimPlaying = true; + curAnimation.Stop(); + } + } + + if (newAnimation != null) + { + if (newAnimation.State == Animation.States.Playing) + { + isNewAnimPlaying = true; + newAnimation.Stop(); + } + } + + if (isCurAnimPlaying) + { + // To enable multiple Pop(), animation's Finished callback is required. + // To call animation's Finished callback, FinishedSignal is emitted. + curAnimation.FinishedSignal().Emit(curAnimation); curAnimation.Clear(); + + // InitializeAnimation() can be called by FinishedSignal().Emit(). + // Not to cause null pointer dereference by calling InitializeAnimation() in InitializeAnimation(), + // animation handle is assigned to be null only if the animation is playing. curAnimation = null; } - if (newAnimation != null) + if (isNewAnimPlaying) { - newAnimation.Stop(); + // To enable multiple Pop(), animation's Finished callback is required. + // To call animation's Finished callback, FinishedSignal is emitted. + newAnimation.FinishedSignal().Emit(newAnimation); newAnimation.Clear(); + + // InitializeAnimation() can be called by FinishedSignal().Emit(). + // Not to cause null pointer dereference by calling InitializeAnimation() in InitializeAnimation(), + // animation handle is assigned to be null only if the animation is playing. newAnimation = null; } }