2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using Tizen.NUI.Components;
20 namespace NUITizenGallery
22 public partial class NavigatorTest1Page : ContentPage
24 public NavigatorTest1Page()
26 InitializeComponent();
29 private void SetButtonColor(NavigatorTest1Page page, int type)
31 Color backgroundColor;
35 backgroundColor = Color.DarkGreen;
39 backgroundColor = Color.DarkRed;
43 backgroundColor = Color.DarkBlue;
47 backgroundColor = Color.SaddleBrown;
50 page.buttonPush.BackgroundColor = backgroundColor;
51 page.buttonPop.BackgroundColor = backgroundColor;
52 page.buttonInsert.BackgroundColor = backgroundColor;
53 page.buttonInsertBefore.BackgroundColor = backgroundColor;
54 page.buttonRemove.BackgroundColor = backgroundColor;
55 page.buttonRemoveAt.BackgroundColor = backgroundColor;
58 private void ButtonPushClicked(object sender, ClickedEventArgs args)
60 if (Navigator == null)
62 Tizen.Log.Error("NUI", "The page should be pushed to a Navigator.\n");
66 var newPage = new NavigatorTest1Page();
67 SetButtonColor(newPage, Navigator.PageCount % 4);
68 newPage.AppBar.Title = "NavigatorTest1Page" + Navigator.PageCount.ToString();
69 Navigator.Push(newPage);
70 Tizen.Log.Info("NUI", newPage.AppBar.Title + " has been pushed.\n");
73 private void ButtonPopClicked(object sender, ClickedEventArgs args)
75 if (Navigator == null)
77 Tizen.Log.Error("NUI", "The page should be pushed to a Navigator.\n");
81 var poppedPage = Navigator.Pop() as NavigatorTest1Page;
82 Tizen.Log.Info("NUI", poppedPage.AppBar.Title + " has been popped.\n");
85 private void ButtonInsertClicked(object sender, ClickedEventArgs args)
87 if (Navigator == null)
89 Tizen.Log.Error("NUI", "The page should be pushed to a Navigator.\n");
93 var newPage = new NavigatorTest1Page();
94 SetButtonColor(newPage, Navigator.PageCount % 4);
95 newPage.AppBar.Title = "NavigatorTest1Page" + Navigator.PageCount.ToString();
96 Navigator.Insert(Navigator.PageCount, newPage);
97 Tizen.Log.Info("NUI", newPage.AppBar.Title + " has been inserted.\n");
100 private void ButtonInsertBeforeClicked(object sender, ClickedEventArgs args)
102 if (Navigator == null)
104 Tizen.Log.Error("NUI", "The page should be pushed to a Navigator.\n");
108 var newPage = new NavigatorTest1Page();
109 SetButtonColor(newPage, Navigator.PageCount % 4);
110 newPage.AppBar.Title = "NavigatorTest1Page" + Navigator.PageCount.ToString();
111 Navigator.InsertBefore(Navigator.Peek(), newPage);
112 Tizen.Log.Info("NUI", newPage.AppBar.Title + " has been inserted before the peek page.\n");
115 private void ButtonRemoveClicked(object sender, ClickedEventArgs args)
117 if (Navigator == null)
119 Tizen.Log.Error("NUI", "The page should be pushed to a Navigator.\n");
123 var removedPage = Navigator.Peek() as NavigatorTest1Page;
124 Navigator.Remove(removedPage);
125 Tizen.Log.Info("NUI", removedPage.AppBar.Title + " has been removed.\n");
128 private void ButtonRemoveAtClicked(object sender, ClickedEventArgs args)
130 if (Navigator == null)
132 Tizen.Log.Error("NUI", "This page should be pushed to a Navigator.\n");
136 if (Navigator.PageCount <= 2)
138 Tizen.Log.Info("NUI", "This test removes the previous page unless the previous page is the main page.\n");
142 int removedIndex = Navigator.PageCount - 2;
143 var removedPage = Navigator.GetPage(removedIndex) as NavigatorTest1Page;
144 Navigator.RemoveAt(removedIndex);
145 Tizen.Log.Info("NUI", removedPage.AppBar.Title + " has been removed.\n");