Adding possiblity to stack popups
authork.stepaniuk <k.stepaniuk@samsung.com>
Thu, 2 Apr 2020 10:42:42 +0000 (12:42 +0200)
committerk.stepaniuk <k.stepaniuk@samsung.com>
Thu, 2 Apr 2020 10:42:42 +0000 (12:42 +0200)
Side effect: background gray layer intensifies with more popups displayed

Signed-off-by: k.stepaniuk <k.stepaniuk@samsung.com>
Oobe/Oobe/Managers/ProcessManager.cs
Oobe/OobeCommon/Utils/Popup.cs
Oobe/OobeWifi/Controls/Wifi/WifiPasswordPopup.cs
Oobe/OobeWifi/Controls/Wifi/WifiView.cs

index e17021d..bb0ae08 100644 (file)
@@ -60,10 +60,11 @@ namespace Oobe
         {
             //TODO consider loading this from xaml, xml or something...
             steps = new LinkedList<Lazy<ProcessStep>>(new []{
+                new Lazy<ProcessStep>(() => new WifiStep()),
                 new Lazy<ProcessStep>(() => new LanguageStep()),
                 new Lazy<ProcessStep>(() => new RegionStep()),
                 new Lazy<ProcessStep>(() => new TermsStep()),
-                new Lazy<ProcessStep>(() => new WifiStep()),
+                
                 new Lazy<ProcessStep>(() => new WelcomeStep()),
                 }
             );
index 45c278f..4189ee3 100644 (file)
@@ -2,21 +2,55 @@
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
 
-namespace OobeCommon.Utils
+namespace Oobe.Common.Utils
 {
-    public static class Popup
+    public class Popup
     {
-        private static Layer layer = null;
+        private View view;
+        private Layer layer = null;
 
-        public static void ShowCentered(View view)
+        public Popup(View view, bool centered = false)
         {
-            view.PositionUsesPivotPoint = true;
-            view.PivotPoint = new Position(0.5f, 0.5f);
-            view.ParentOrigin = new Position(0.5f, 0.5f);
-            Show(view);
+            this.view = view;
+            if (centered)
+            {
+                view.PositionUsesPivotPoint = true;
+                view.PivotPoint = new Position(0.5f, 0.5f);
+                view.ParentOrigin = new Position(0.5f, 0.5f);
+            }
+        }
+
+        public void Show()
+        {
+            if (layer != null)
+            {
+                layer.Visibility = true;
+            }
+            else
+            {
+                ShowCore();
+            }
+        }
+
+        public void Hide()
+        {
+            if (layer != null)
+            {
+                layer.Visibility = false;
+            }
+        }
+
+        public void Dismiss()
+        {
+            if (layer != null)
+            {
+                Window.Instance.RemoveLayer(layer);
+                layer.Dispose();
+                layer = null;
+            }
         }
 
-        public static void Show(View view)
+        private void ShowCore()
         {
             Dismiss();
             layer = new Layer();
@@ -40,15 +74,5 @@ namespace OobeCommon.Utils
             layer.Add(view);
             Window.Instance.AddLayer(layer);
         }
-
-        public static void Dismiss()
-        {
-            if (layer != null)
-            {
-                Window.Instance.RemoveLayer(layer);
-                layer.Dispose();
-                layer = null;
-            }
-        }
     }
 }
index 3801bd6..76115fc 100644 (file)
@@ -10,6 +10,7 @@ namespace Oobe.Wifi.Controls.Wifi
 {
     class WifiPasswordPopup : View
     {
+        public event Action OnDismiss;
         private PasswordEntry passwordEntry = null;
         private Button okButton;
         private Button cancelButton;
@@ -110,7 +111,7 @@ namespace Oobe.Wifi.Controls.Wifi
             };
             cancelButton.ClickEvent += (s, e) =>
             {
-                OobeCommon.Utils.Popup.Dismiss();
+                OnDismiss.Invoke();
             };
             this.Add(cancelButton);
 
@@ -141,7 +142,7 @@ namespace Oobe.Wifi.Controls.Wifi
                     UpdateOKButton();
                     if (success == true)
                     {
-                        OobeCommon.Utils.Popup.Dismiss();
+                        OnDismiss.Invoke();
                     }
                     else
                     {
index 87e2844..a63092f 100644 (file)
@@ -74,10 +74,21 @@ namespace Oobe.Wifi.Controls.Wifi
             return manualWifi;
         }
 
-        private static View CreatePasswordPopup(Tizen.Network.WiFi.WiFiAP wifiAp)
+        private static async void ShowPasswordPopup(Tizen.Network.WiFi.WiFiAP wifiAp)
         {
-            var popup = new WifiPasswordPopup(wifiAp);
-            return popup;
+            var view = new WifiPasswordPopup(wifiAp);
+            var popup = new Common.Utils.Popup(view);
+            view.OnDismiss += popup.Dismiss;
+            popup.Show();
+
+            //for verify
+            await System.Threading.Tasks.Task.Delay(1_000);
+            new Common.Utils.Popup(new View
+            {
+                BackgroundColor = Color.Red,
+                Size = new Size(100, 100)
+            }, centered: true)
+            .Show();
         }
 
         private static void OnApTapped(Tizen.Network.WiFi.WiFiAP wifiAp)
@@ -87,9 +98,7 @@ namespace Oobe.Wifi.Controls.Wifi
                 Tizen.Log.Debug("oobe", $"Already connected to {wifiAp.NetworkInformation.Essid}");
                 return;
             }
-            //show center requires correction
-            //OobeCommon.Utils.Popup.ShowCentered(CreatePasswordPopup());
-            OobeCommon.Utils.Popup.Show(CreatePasswordPopup(wifiAp));
+            ShowPasswordPopup(wifiAp);
         }
 
         private View CreateHeader(int width, int height)