Add prototype of choose security popup
authorKrzysztof Wieclaw <k.wieclaw@samsung.com>
Wed, 8 Apr 2020 16:59:04 +0000 (18:59 +0200)
committerk.stepaniuk <k.stepaniuk@samsung.com>
Fri, 10 Apr 2020 08:27:48 +0000 (10:27 +0200)
Oobe/OobeWifi/Controls/Wifi/AddNewNetworkPupup.cs
Oobe/OobeWifi/Controls/Wifi/ChangeSecurityTypePopup.cs [new file with mode: 0644]
Oobe/OobeWifi/Controls/Wifi/SecurityTypeView.cs [new file with mode: 0644]

index 7e88136..b1dc71e 100644 (file)
@@ -8,6 +8,7 @@ using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Components;
 using Oobe.Common.Styles;
 using Tizen.Network.WiFi;
+using Oobe.Common.Utils;
 
 namespace Oobe.Wifi.Controls.Wifi
 {
@@ -245,25 +246,14 @@ namespace Oobe.Wifi.Controls.Wifi
 
         void OpenSecurityTypePopup()
         {
-            //Temporary solution for no popup stack
-            switch (currentSecurityType)
+            var view = new ChangeSecurityTypePopup(currentSecurityType);
+            var popup = new Oobe.Common.Utils.Popup(view);
+            view.OnDismiss += () =>
             {
-                case WifUISecurityType.None:
-                    ResetViewTo(WifUISecurityType.EAP);
-                    break;
-                case WifUISecurityType.EAP:
-                    ResetViewTo(WifUISecurityType.WEP);
-                    break;
-                case WifUISecurityType.WEP:
-                    ResetViewTo(WifUISecurityType.WPAPSK);
-                    break;
-                case WifUISecurityType.WPAPSK:
-                    ResetViewTo(WifUISecurityType.WPA2PSK);
-                    break;
-                case WifUISecurityType.WPA2PSK:
-                    ResetViewTo(WifUISecurityType.None);
-                    break;
-            }
+                ResetViewTo(view.WifiUISecurityType);
+                popup.Dismiss();
+            };
+            popup.Show();
         }
 
         void ResetViewToNoPassword()
diff --git a/Oobe/OobeWifi/Controls/Wifi/ChangeSecurityTypePopup.cs b/Oobe/OobeWifi/Controls/Wifi/ChangeSecurityTypePopup.cs
new file mode 100644 (file)
index 0000000..00933e5
--- /dev/null
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using Oobe.Common.Styles;
+using Tizen.Network.WiFi;
+
+namespace Oobe.Wifi.Controls.Wifi
+{
+    class ChangeSecurityTypePopup : View
+    {
+        public event Action OnDismiss;
+
+        public WifUISecurityType WifiUISecurityType { get; private set; }
+        private WifUISecurityType originalWifUISecurityType;
+        private ListView listView;
+        public ObservableCollection<View> choiceViews = new ObservableCollection<View>();
+        private RadioButtonGroup radioButtonGroup = new RadioButtonGroup();
+
+        public ChangeSecurityTypePopup(WifUISecurityType wifUISecurityType)
+        {
+            this.originalWifUISecurityType = wifUISecurityType;
+            this.WifiUISecurityType = wifUISecurityType;
+            this.Size = new Size(808, 440);
+            this.Position = new Position(236, 140);
+            this.BackgroundImage = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "08_popup_body.png");
+
+            InitializeStaticElements();
+            InitializeRadioButtons();
+        }
+
+        public void InitializeStaticElements()
+        {
+            var titleLabel = new TextLabel()
+            {
+                Position = new Position2D(80, 24),
+                Size = new Size(648, 34),
+                PixelSize = 26,
+                Text = "Choose security type",
+                FontFamily = "BreezeSans",
+                FontStyle = new PropertyMap().AddLightFontStyle(),
+                TextColor = new Color(0.0f, 0x14 / 255.0f, 0x47 / 255.0f, 1.0f),
+                HorizontalAlignment = HorizontalAlignment.Center,
+                VerticalAlignment = VerticalAlignment.Center
+            };
+            this.Add(titleLabel);
+
+            var cancelButton = new Button(ButtonStyles.Cancel)
+            {
+                Position = new Position(80, 344),
+                Size = new Size(240, 72)
+            };
+            cancelButton.ClickEvent += (s, e) =>
+            {
+                WifiUISecurityType = originalWifUISecurityType;
+                OnDismiss?.Invoke();
+            };
+            this.Add(cancelButton);
+
+            var addButton = new Button(ButtonStyles.OK)
+            {
+                Position = new Position(488, 344),
+                Size = new Size(240, 72),
+                Text = "OK"
+            };
+
+            addButton.ClickEvent += (s, e) =>
+            {
+                OnDismiss?.Invoke();
+            };
+            this.Add(addButton);
+        }
+
+        private void InitializeRadioButtons()
+        {
+            foreach (WifUISecurityType type in Enum.GetValues(WifiUISecurityType.GetType()))
+            {
+                var view = CreateOption(type);
+                choiceViews.Add(view);
+            }
+            listView = new ListView(768, 238)
+            {
+                Items = choiceViews
+            };
+            listView.View.Position = new Position(0, 82);
+            this.Add(listView.View);
+        }
+
+        private View CreateOption(WifUISecurityType wifiUISecurityType)
+        {
+            var view = new SecurityTypeView(wifiUISecurityType);
+            if (this.WifiUISecurityType == wifiUISecurityType)
+            {
+                view.Button.IsSelected = true;
+            }
+            radioButtonGroup.Add(view.Button);
+            view.Button.ClickEvent += (s, e) => this.WifiUISecurityType = view.WifiUISecurityType;
+            return view;
+        }
+    }
+}
diff --git a/Oobe/OobeWifi/Controls/Wifi/SecurityTypeView.cs b/Oobe/OobeWifi/Controls/Wifi/SecurityTypeView.cs
new file mode 100644 (file)
index 0000000..95a390b
--- /dev/null
@@ -0,0 +1,48 @@
+using System;
+using Tizen.Network.WiFi;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Oobe.Common.Styles;
+using Tizen.NUI.Components;
+
+namespace Oobe.Wifi.Controls.Wifi
+{
+    class SecurityTypeView : View
+    {
+        public event Action Tapped;
+        public RadioButton Button;
+        public readonly WifUISecurityType WifiUISecurityType;
+
+        private TextLabel descriptionTextLabel = null;
+        //detectors have to be kept separately because of GC, there is no link by ref between View and Detector
+        private TapGestureDetector detector;
+
+        public SecurityTypeView(WifUISecurityType wifiUISecurityType)
+        {
+            Size = new Size(768, 64);
+            Layout = new AbsoluteLayout();
+            this.WifiUISecurityType = wifiUISecurityType;
+
+            InitializeSubelements();
+        }
+
+        void InitializeSubelements()
+        {
+            Button = new RadioButton()
+            {
+                IsSelected = false,
+                Position = new Position(40, 20),
+                Size = new Size(24, 24)
+            };
+            this.Add(Button);
+
+            descriptionTextLabel = new TextLabel()
+            {
+                Position = new Position(92, 20),
+                Size = new Size(648, 24),
+                Text = WifiUISecurityType.GetUIName()
+            };
+            this.Add(descriptionTextLabel);
+        }
+    }
+}