Add page indicator (#20)
authorLukasz Stanislawski/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <l.stanislaws@samsung.com>
Fri, 27 Mar 2020 10:01:14 +0000 (11:01 +0100)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 27 Mar 2020 10:01:14 +0000 (11:01 +0100)
* add page indicator to MainView
* extract WelcomeStep from proces steps
* add extra method to IProcessNavigation to finish process

Oobe/Oobe.Welcome/WelcomeStep.cs
Oobe/Oobe/Managers/ProcessManager.cs
Oobe/Oobe/Views/MainView.cs
Oobe/Oobe/res/1.png [new file with mode: 0644]
Oobe/Oobe/res/2.png [new file with mode: 0644]
Oobe/OobeCommon/Interfaces/IProcessNavigation.cs

index 0c65764599bc39572795afadb68fa3df2e018c93..aedf246241ddf89c1720c6138df58eb47ca35f49 100644 (file)
@@ -35,7 +35,7 @@ namespace Oobe.Welcome
             next.Position2D = new Position2D(472, 512);\r
             next.Text = "GET STARTED";\r
             next.ClickEvent += (obj, args) => {\r
-                nav.Next();\r
+                nav.Finish();\r
             };\r
 \r
             container.Add(title);\r
index 6cc8f6026165c9e2bd36d3ca4e6596c48bcf458e..ba54cb331a2751b2bbcab9dc658a59c1a3dd1ba1 100644 (file)
@@ -17,6 +17,7 @@ namespace Oobe
         private MainView ui;
         private LinkedList<Lazy<ProcessStep>> steps;
         private LinkedListNode<Lazy<ProcessStep>> current;
+        private Lazy<ProcessStep> welcome;
 
         static private string doneFile = Tizen.Applications.CoreUIApplication.Current.DirectoryInfo.Data + "oobe_done";
 
@@ -27,16 +28,20 @@ namespace Oobe
                 new Lazy<ProcessStep>(() => new LanguageStep()),
                 new Lazy<ProcessStep>(() => new RegionStep()),
                 new Lazy<ProcessStep>(() => new TermsStep()),
-                new Lazy<ProcessStep>(() => new WelcomeStep()),
                 }
             );
             //only for review
-            steps.AddFirst(new Lazy<ProcessStep>(() => new WifiStep()));
+            steps.AddFirst(
+                new Lazy<ProcessStep>(() => new WifiStep())
+            );
+            welcome = new Lazy<ProcessStep>(() => new WelcomeStep());
         }
 
         public void Start()
         {
             ui = new MainView(Window.Instance);
+            ui.PaginationVisible = true;
+            ui.PagesCount = steps.Count;
 
             current = steps.First;
             current.Value.Value.Initialize();
@@ -52,7 +57,7 @@ namespace Oobe
             // end process if all steps are done
             if (current.Next == null)
             {
-                Exit();
+                ShowWelcomeScreen();
                 return;
             }
 
@@ -61,10 +66,16 @@ namespace Oobe
             current.Next?.Value.Value.Initialize();
         }
 
+        private void ShowWelcomeScreen()
+        {
+            ui.PaginationVisible = false;
+            ui.Push(welcome.Value.CreateView(this));
+        }
+
         /// <summary>
         /// Finishes process and exits application
         /// </summary>
-        public void Exit()
+        public void Finish()
         {
             foreach (Lazy<ProcessStep> step in steps)
             {
index 70e6f4841a0b245060dd6d6fd824340c33aab0b0..4e45206b0eaba6898b48477ecb99dc40d6f39b05 100644 (file)
@@ -1,6 +1,7 @@
 using Tizen.NUI.BaseComponents;
 using Tizen.NUI;
 using Oobe.Controls;
+using Tizen.NUI.Components;
 
 namespace Oobe.Views
 {
@@ -11,6 +12,7 @@ namespace Oobe.Views
     {
         private ViewStack stack;
         private Animation dimEffectAnimation;
+        private Pagination pagination;
         private const int TransitionTime = 750;
 
         public MainView(Window win)
@@ -29,8 +31,36 @@ namespace Oobe.Views
             stack.ClippingMode = ClippingModeType.Disabled;
             dimEffectAnimation = new Animation(TransitionTime);
 
+            pagination = new Pagination();
+            pagination.Position2D = new Position2D(598, 686);
+            pagination.Size2D = new Size2D(88, 20);
+            pagination.IndicatorSize = new Size(26, 26);
+            pagination.IndicatorImageURL = new Selector<string>()
+            {
+                Normal = Tizen.NUI.NUIApplication.Current.DirectoryInfo.Resource + "1.png",
+                Selected = Tizen.NUI.NUIApplication.Current.DirectoryInfo.Resource + "2.png",
+            };
+            pagination.IndicatorSpacing = 8;
+
             win.GetDefaultLayer().Add(backImage);
             win.GetDefaultLayer().Add(stack);
+            win.GetDefaultLayer().Add(pagination);
+        }
+
+        public int PagesCount
+        {
+            get => pagination.IndicatorCount;
+            set => pagination.IndicatorCount = value;
+        }
+
+        public bool PaginationVisible
+        {
+            get => pagination.Visibility;
+            set
+            {
+                if (value) pagination.Show();
+                else pagination.Hide();
+            }
         }
 
         public void Push(View view)
@@ -48,6 +78,7 @@ namespace Oobe.Views
                 StartDimAnimation(overlayedView);
             }
 
+            pagination.SelectedIndex = pagination.SelectedIndex + 1;
             stack.Push(newView);
         }
 
@@ -62,6 +93,7 @@ namespace Oobe.Views
             {
                 StartDimAnimation(current);
             }
+            pagination.SelectedIndex = pagination.SelectedIndex - 1;
             stack.Pop();
         }
 
diff --git a/Oobe/Oobe/res/1.png b/Oobe/Oobe/res/1.png
new file mode 100644 (file)
index 0000000..931f787
Binary files /dev/null and b/Oobe/Oobe/res/1.png differ
diff --git a/Oobe/Oobe/res/2.png b/Oobe/Oobe/res/2.png
new file mode 100644 (file)
index 0000000..44a380d
Binary files /dev/null and b/Oobe/Oobe/res/2.png differ
index 6ebe9461b936be1db6eae8ebd399c50544ccfe0f..3fb59b71c7d7bce9491df990fffd812eeb58d9fc 100644 (file)
@@ -13,5 +13,10 @@ namespace Oobe.Common.Interfaces
         /// Goto previous process step.
         /// </summary>
         void Previous();
+
+        /// <summary>
+        /// Finishes process.
+        /// </summary>
+        void Finish();
     }
-}
\ No newline at end of file
+}