refactor: remove Page class 76/244676/1
authorLukasz Stanislawski <lukasz.stanislawski@gmail.com>
Tue, 22 Sep 2020 12:31:42 +0000 (14:31 +0200)
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>
Wed, 23 Sep 2020 06:35:47 +0000 (08:35 +0200)
The Page class was introduced to handle dim effects. However
beacouse dim effect has been removed from guide some time ago,
currently this class does too few things to make it separate entity.

Change-Id: I6456f03d12f48d7bb8d663f222b1f8168b59a671

Oobe/Oobe.Common/Layouts/BasePageLayout.cs
Oobe/Oobe.Common/res/page/0_BG_WHITEsmall.png [new file with mode: 0644]
Oobe/Oobe/Views/MainView.cs
Oobe/Oobe/Views/Page.cs [deleted file]
Oobe/Oobe/res/0_BG_WHITEsmall.png [deleted file]

index 1bbda5f2fc711839a2f7138406d7d18611565310..a93d8f5972a8f88a2aa85dfb0d724948ff1c0d12 100644 (file)
@@ -27,6 +27,7 @@ namespace Oobe.Common.Layouts
     public class BasePageLayout : View
     {
         private View content;
+        private View dimView;
 
         /// <summary>
         /// Constructs new BasePageLayout object
@@ -34,7 +35,13 @@ namespace Oobe.Common.Layouts
         public BasePageLayout()
             : base()
         {
-            Layout = new AbsoluteLayout();
+            dimView = new View()
+            {
+                HeightResizePolicy = ResizePolicyType.FillToParent,
+                WidthResizePolicy = ResizePolicyType.FillToParent,
+            };
+
+            dimView.Layout = new AbsoluteLayout();
             Title = new TextLabel
             {
                 PositionUsesPivotPoint = true,
@@ -49,7 +56,9 @@ namespace Oobe.Common.Layouts
                 FontFamily = "BreezeSans",
                 FontStyle = new PropertyMap().AddLightFontStyle(),
             };
-            Add(Title);
+            dimView.Add(Title);
+            BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + "page/0_BG_WHITEsmall.png";
+            Add(dimView);
         }
 
         /// <summary>
@@ -70,7 +79,7 @@ namespace Oobe.Common.Layouts
                 {
                     if (content != null)
                     {
-                        Remove(content);
+                        dimView.Remove(content);
                     }
 
                     content?.Dispose();
@@ -83,7 +92,7 @@ namespace Oobe.Common.Layouts
                     content.PositionUsesPivotPoint = true;
                     content.PivotPoint = new Position(0.5f, 0.5f);
                     content.ParentOrigin = new Position(0.5f, 0.5f);
-                    Add(content);
+                    dimView.Add(content);
                 }
             }
         }
diff --git a/Oobe/Oobe.Common/res/page/0_BG_WHITEsmall.png b/Oobe/Oobe.Common/res/page/0_BG_WHITEsmall.png
new file mode 100644 (file)
index 0000000..4e6dfdf
Binary files /dev/null and b/Oobe/Oobe.Common/res/page/0_BG_WHITEsmall.png differ
index 6f942fc7e1a47e1de9acb69820845e68718b108f..faf13a068841f2abb43def2ed7ce1e8a3e47edec 100644 (file)
@@ -108,24 +108,22 @@ namespace Oobe.Views
         {
             FinishDimAnimation();
 
-            var newView = new Views.Page();
-            newView.HeightResizePolicy = ResizePolicyType.FillToParent;
-            newView.WidthResizePolicy = ResizePolicyType.FillToParent;
-            newView.Content = view;
+            view.HeightResizePolicy = ResizePolicyType.FillToParent;
+            view.WidthResizePolicy = ResizePolicyType.FillToParent;
 
-            if (stack.Current is Views.Page overlayedView)
+            if (stack.Current is View overlayedView)
             {
                 StartDimAnimation(overlayedView);
             }
 
             pagination.SelectedIndex = pagination.SelectedIndex + 1;
-            stack.Push(newView);
+            stack.Push(view);
         }
 
         public void Pop()
         {
             FinishDimAnimation();
-            if (stack.Previous is Views.Page previous)
+            if (stack.Previous is View previous)
             {
                 StartUndimAnimation(previous);
             }
@@ -141,14 +139,14 @@ namespace Oobe.Views
             pagination.Dispose();
         }
 
-        private void StartDimAnimation(Views.Page view)
+        private void StartDimAnimation(View view)
         {
             view.Opacity = 1.0f;
             dimEffectAnimation.AnimateTo(view, "Opacity", 0.0f);
             dimEffectAnimation.Play();
         }
 
-        private void StartUndimAnimation(Views.Page view)
+        private void StartUndimAnimation(View view)
         {
             view.Opacity = 0.0f;
             dimEffectAnimation.AnimateTo(view, "Opacity", 1.0f);
diff --git a/Oobe/Oobe/Views/Page.cs b/Oobe/Oobe/Views/Page.cs
deleted file mode 100644 (file)
index 5152085..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Tizen.NUI;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Components;
-
-namespace Oobe.Views
-{
-    /// <summary>
-    /// Implementation of OOBE GUI guideline for Tizen IoT headed
-    /// </summary>
-    public class Page : View
-    {
-        private View content;
-
-        public Page()
-        {
-            BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + "0_BG_WHITEsmall.png";
-        }
-
-        public View Content
-        {
-            get
-            {
-                return content;
-            }
-
-            set
-            {
-                if (value == content)
-                {
-                    return;
-                }
-
-                if (value)
-                {
-                    Remove(content);
-                    value.HeightResizePolicy = ResizePolicyType.FillToParent;
-                    value.WidthResizePolicy = ResizePolicyType.FillToParent;
-                    Add(value);
-                    content = value;
-                }
-            }
-        }
-    }
-}
diff --git a/Oobe/Oobe/res/0_BG_WHITEsmall.png b/Oobe/Oobe/res/0_BG_WHITEsmall.png
deleted file mode 100644 (file)
index 4e6dfdf..0000000
Binary files a/Oobe/Oobe/res/0_BG_WHITEsmall.png and /dev/null differ