[NUI][TEST] Add ContentPage, DialogPage, Navigator and TabView examples in StyleGuide
authordongsug.song <dongsug.song@samsung.com>
Tue, 5 Apr 2022 08:03:53 +0000 (17:03 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 20 Apr 2022 08:38:08 +0000 (17:38 +0900)
test/Tizen.NUI.StyleGuide/.vscode/launch.json
test/Tizen.NUI.StyleGuide/Examples/ContentPageExample.cs [new file with mode: 0644]
test/Tizen.NUI.StyleGuide/Examples/DialogAndAlertDialogExample.cs [moved from test/Tizen.NUI.StyleGuide/Examples/AlertDialogExample.cs with 96% similarity]
test/Tizen.NUI.StyleGuide/Examples/NavigatorExample.cs [new file with mode: 0644]
test/Tizen.NUI.StyleGuide/Examples/TabViewExample.cs [new file with mode: 0644]

index 807ff68..2f78a39 100644 (file)
@@ -19,7 +19,7 @@
                 "PKG_CONFIG_PATH":"${env:HOME}/dali-env/opt/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig",
                 "DOTNET_CLI_TELEMETRY_OPTOUT":"1",
                 "DALI_WINDOW_WIDTH":"720",
-                "DALI_WINDOW_HEIGHT":"1080",
+                "DALI_WINDOW_HEIGHT":"800",
             },
             "cwd": "${workspaceFolder}",
             "console": "internalConsole",
diff --git a/test/Tizen.NUI.StyleGuide/Examples/ContentPageExample.cs b/test/Tizen.NUI.StyleGuide/Examples/ContentPageExample.cs
new file mode 100644 (file)
index 0000000..1fa1726
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright(c) 2022 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 System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+    // IExample inehrited class will be automatically added in the main examples list.
+    internal class ContentPageExample : ContentPage, IExample
+    {
+        private Window window;
+        private Navigator navigator;
+        private ContentPage contentPage1, contentPage2;
+        private int pageCount = 0;
+
+        public void Activate()
+        {
+        }
+        public void Deactivate()
+        {
+        }
+
+        /// Modify this method for adding other examples.
+        public ContentPageExample() : base()
+        {
+            window = NUIApplication.GetDefaultWindow();
+
+            WidthSpecification = LayoutParamPolicies.MatchParent;
+            HeightSpecification = LayoutParamPolicies.MatchParent;
+
+            // Navigator bar title is added here.
+            AppBar = new AppBar()
+            {
+                Title = "ContentPage Default Style",
+            };
+
+            navigator = window.GetDefaultNavigator();
+            pageCount = navigator.PageCount;
+
+            contentPage1 = new ContentPage()
+            {
+                AppBar = new AppBar()
+                {
+                    Title = "ContentPageTestPage1",
+                },
+            };
+            var buttonOne = new Button()
+            {
+                Text = "ONE",
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.MatchParent,
+            };
+            buttonOne.Clicked += (s, e) =>
+            {
+                navigator?.Push(contentPage2);
+            };
+
+            contentPage1.Content = buttonOne;
+
+            contentPage2 = new ContentPage()
+            {
+                AppBar = new AppBar()
+                {
+                    Title = "ContentPageTestPage2",
+                },
+            };
+            var buttonTwo = new Button()
+            {
+                Text = "TWO",
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.MatchParent,
+            };
+            buttonTwo.Clicked += (s, e) =>
+            {
+                navigator?.Pop();
+            };
+            contentPage2.Content = buttonTwo;
+
+            Content = contentPage1;
+        }
+    }
+}
@@ -23,7 +23,7 @@ using Tizen.NUI.Components;
 namespace Tizen.NUI.StyleGuide
 {
     // IExample inehrited class will be automatically added in the main examples list.
-    internal class AlertDialogExample : ContentPage, IExample
+    internal class DialogAndAlertDialogExample : ContentPage, IExample
     {
         private View rootContent;
         private Button buttonOneAction, buttonTwoAction, buttonNoTitle, buttonNoMessage;
@@ -36,7 +36,7 @@ namespace Tizen.NUI.StyleGuide
         }
 
         /// Modify this method for adding other examples.
-        public AlertDialogExample() : base()
+        public DialogAndAlertDialogExample() : base()
         {
             WidthSpecification = LayoutParamPolicies.MatchParent;
             HeightSpecification = LayoutParamPolicies.MatchParent;
@@ -44,7 +44,7 @@ namespace Tizen.NUI.StyleGuide
             // Navigator bar title is added here.
             AppBar = new AppBar()
             {
-                Title = "AlertDialog Default Style",
+                Title = "Dialog AlertDialog Default Style",
             };
 
             // Example root content view.
diff --git a/test/Tizen.NUI.StyleGuide/Examples/NavigatorExample.cs b/test/Tizen.NUI.StyleGuide/Examples/NavigatorExample.cs
new file mode 100644 (file)
index 0000000..716d4f0
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright(c) 2022 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 System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+    // IExample inehrited class will be automatically added in the main examples list.
+    internal class NavigatorExample : ContentPage, IExample
+    {
+        private const int numberOfDifferentColor = 4;
+        private const int colorOne = 0, colorTwo = 1, colorThree = 2;
+        private Navigator navigator;
+
+        public void Activate()
+        {
+        }
+        public void Deactivate()
+        {
+        }
+
+        /// Modify this method for adding other examples.
+        public NavigatorExample() : base()
+        {
+            WidthSpecification = LayoutParamPolicies.MatchParent;
+            HeightSpecification = LayoutParamPolicies.MatchParent;
+
+            // Navigator bar title is added here.
+            AppBar = new AppBar()
+            {
+                Title = "Navigator Default Style",
+            };
+
+            navigator = NUIApplication.GetDefaultWindow().GetDefaultNavigator();
+            Content = generatePage();
+        }
+
+        private ContentPage generatePage()
+        {
+            var page = new ContentPage();
+            page.AppBar = new AppBar()
+            {
+                Title = "NavigatorTestPage",
+            };
+
+            var contentView = new View()
+            {
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Vertical,
+                    CellPadding = new Size2D(0, 10),
+                },
+            };
+            page.Content = contentView;
+
+            var buttonPush = new Button()
+            {
+                Text = "Push",
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.MatchParent,
+            };
+            buttonPush.Clicked += (s, e) =>
+            {
+                if (navigator == null)
+                {
+                    Tizen.Log.Error("NUITEST", "The page should be pushed to a Navigator");
+                    return;
+                }
+                var newPage = generatePage();
+                newPage.AppBar.Title = "NavigatorTestPage" + navigator.PageCount.ToString();
+                navigator.Push(newPage);
+            };
+            contentView.Add(buttonPush);
+
+            var buttonPop = new Button()
+            {
+                Text = "Pop",
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.MatchParent,
+            };
+            buttonPop.Clicked += (s, e) =>
+            {
+                if (navigator == null)
+                {
+                    Tizen.Log.Error("NUITEST", "The page should be pushed to a Navigator");
+                    return;
+                }
+                navigator.Pop();
+            };
+            contentView.Add(buttonPop);
+
+            Color backgroundColor;
+            switch (navigator.PageCount % numberOfDifferentColor)
+            {
+                case colorOne:
+                    backgroundColor = Color.DarkGreen;
+                    break;
+                case colorTwo:
+                    backgroundColor = Color.DarkRed;
+                    break;
+                case colorThree:
+                    backgroundColor = Color.DarkBlue;
+                    break;
+                default:
+                    backgroundColor = Color.SaddleBrown;
+                    break;
+            };
+            buttonPush.BackgroundColor = backgroundColor;
+            buttonPop.BackgroundColor = backgroundColor;
+            return page;
+        }
+    }
+}
diff --git a/test/Tizen.NUI.StyleGuide/Examples/TabViewExample.cs b/test/Tizen.NUI.StyleGuide/Examples/TabViewExample.cs
new file mode 100644 (file)
index 0000000..d5d73a3
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright(c) 2022 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 System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+    // IExample inehrited class will be automatically added in the main examples list.
+    internal class TabViewExample : ContentPage, IExample
+    {
+        private const int maxTabCount = 4;
+        private const int colorOne = 0, colorTwo = 1, colorThree = 2;
+        private int tabCount = 0;
+        private TabView tabView;
+
+        public void Activate()
+        {
+        }
+        public void Deactivate()
+        {
+        }
+
+        /// Modify this method for adding other examples.
+        public TabViewExample() : base()
+        {
+            WidthSpecification = LayoutParamPolicies.MatchParent;
+            HeightSpecification = LayoutParamPolicies.MatchParent;
+
+            // Navigator bar title is added here.
+            AppBar = new AppBar()
+            {
+                Title = "TabView Default Style",
+            };
+
+            tabView = new TabView()
+            {
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+            };
+            Content = tabView;
+
+            tabView.AddTab(CreateTabButton(), CreateView());
+            tabCount++;
+
+            tabView.AddTab(CreateTabButton(), CreateView());
+            tabCount++;
+        }
+
+        private TabButton CreateTabButton()
+        {
+            return new TabButton()
+            {
+                Text = "Tab" + (tabCount + 1),
+            };
+        }
+
+        private View CreateView()
+        {
+            Color backgroundColor;
+            Color buttonBackgroundColor;
+
+            if ((tabCount + 1) % maxTabCount == colorOne)
+            {
+                backgroundColor = Color.DarkGreen;
+                buttonBackgroundColor = Color.Green;
+            }
+            else if ((tabCount + 1) % maxTabCount == colorTwo)
+            {
+                backgroundColor = Color.DarkRed;
+                buttonBackgroundColor = Color.Red;
+            }
+            else if ((tabCount + 1) % maxTabCount == colorThree)
+            {
+                backgroundColor = Color.DarkBlue;
+                buttonBackgroundColor = Color.Blue;
+            }
+            else
+            {
+                backgroundColor = Color.SaddleBrown;
+                buttonBackgroundColor = Color.Orange;
+            }
+
+            var container = new View()
+            {
+                Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Vertical,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    CellPadding = new Size2D(0, 20),
+                },
+                BackgroundColor = backgroundColor,
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.MatchParent,
+            };
+
+            var buttonAddTab = new Button()
+            {
+                Text = "Add Tab",
+                BackgroundColor = buttonBackgroundColor,
+            };
+            buttonAddTab.Clicked += (object sender, ClickedEventArgs args) =>
+            {
+                if (tabCount < maxTabCount)
+                {
+                    tabView.AddTab(CreateTabButton(), CreateView());
+                    tabCount++;
+                }
+            };
+            container.Add(buttonAddTab);
+
+            var buttonRemoveTab = new Button()
+            {
+                Text = "Remove Tab",
+                BackgroundColor = buttonBackgroundColor,
+            };
+            buttonRemoveTab.Clicked += (object sender, ClickedEventArgs args) =>
+            {
+                if (tabCount > 1)
+                {
+                    tabView.RemoveTab(tabCount - 1);
+                    tabCount--;
+                }
+            };
+            container.Add(buttonRemoveTab);
+
+            return container;
+        }
+
+    }
+}