[NUI] Add to call UnregisterDefaultLabel when Page is popped (#3798)
authorSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Tue, 4 Jan 2022 04:39:54 +0000 (13:39 +0900)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Wed, 12 Jan 2022 08:40:18 +0000 (17:40 +0900)
* [NUI] Add to call UnregisterDefaultLabel when Page is popped

 - Currently, Dialog and AlertDialog only call `RegisterDefaultLabel()` on init
time and do not call `UnregisterDefaultLabel()`.
 - So, move the code to call Add / Remove Popup methods when Page is
pushed and popped to Navigator.

 - In AT-SPI side, when Navigator pops a page (like `Button` clicked),
  the page is just removed from Navigator page list.
  That's why the page still has an accessibility highlight and cannot
see on the screen.

Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
* Update Navigator according to reviews

Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs

index 3193e2a..737cf27 100755 (executable)
@@ -231,6 +231,9 @@ namespace Tizen.NUI.Components
                    topPage.SetVisible(false);
                 }
 
+                // Need to update Content of the new page
+                ShowContentOfPage(page);
+
                 //Invoke Page events
                 page.InvokeAppeared();
                 topPage.InvokeDisappeared();
@@ -281,6 +284,9 @@ namespace Tizen.NUI.Components
                 Remove(topPage);
                 topPage.SetVisible(true);
 
+                // Need to update Content of the new page
+                ShowContentOfPage(newTopPage);
+
                 //Invoke Page events
                 newTopPage.InvokeAppeared();
                 topPage.InvokeDisappeared();
@@ -357,12 +363,19 @@ namespace Tizen.NUI.Components
                 newAnimation.EndAction = Animation.EndActions.StopFinal;
                 newAnimation.Finished += (object sender, EventArgs e) =>
                 {
+                    // Need to update Content of the new page
+                    ShowContentOfPage(page);
+
                     //Invoke Page events
                     page.InvokeAppeared();
                     NotifyAccessibilityStatesChangeOfPages(curTop, page);
                 };
                 newAnimation.Play();
             }
+            else
+            {
+                ShowContentOfPage(page);
+            }
         }
 
         /// <summary>
@@ -431,6 +444,9 @@ namespace Tizen.NUI.Components
                 newAnimation.EndAction = Animation.EndActions.StopFinal;
                 newAnimation.Finished += (object sender, EventArgs e) =>
                 {
+                    // Need to update Content of the new page
+                    ShowContentOfPage(newTop);
+
                     //Invoke Page events
                     newTop.InvokeAppeared();
                     NotifyAccessibilityStatesChangeOfPages(curTop, newTop);
@@ -520,6 +536,8 @@ namespace Tizen.NUI.Components
             //TODO: The following transition codes will be replaced with view transition.
             InitializeAnimation();
 
+            ShowContentOfPage(page);
+
             if (index == PageCount)
             {
                 page.Opacity = 1.0f;
@@ -586,6 +604,8 @@ namespace Tizen.NUI.Components
             //TODO: The following transition codes will be replaced with view transition.
             InitializeAnimation();
 
+            HideContentOfPage(page);
+
             if ((page == Peek()) && (PageCount >= 2))
             {
                 navigationPages[PageCount - 2].Opacity = 1.0f;
@@ -860,5 +880,25 @@ namespace Tizen.NUI.Components
                 newAnimation = null;
             }
         }
+
+        // Show and Register Content of Page to Accessibility bridge
+        private void ShowContentOfPage(Page page)
+        {
+            View content = (page is DialogPage) ? (page as DialogPage)?.Content : (page as ContentPage)?.Content;
+            if (content != null)
+            {
+                content.Show(); // Calls RegisterDefaultLabel()
+            }
+        }
+
+        // Hide and Remove Content of Page from Accessibility bridge
+        private void HideContentOfPage(Page page)
+        {
+            View content = (page is DialogPage) ? (page as DialogPage)?.Content : (page as ContentPage)?.Content;
+            if (content != null)
+            {
+                content.Hide(); // Calls UnregisterDefaultLabel()
+            }
+        }
     }
 }