[NUI] Rebase DevelNUI (#2507)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / AppBarSample.cs
1 using Tizen.NUI.BaseComponents;
2 using Tizen.NUI.Components;
3
4 namespace Tizen.NUI.Samples
5 {
6     public class AppBarSample : IExample
7     {
8         private Page firstPage, secondPage;
9         private AppBar firstAppBar, secondAppBar;
10         private Button firstActionButton, secondActionButton;
11         private Button firstButton, secondButton;
12
13         public void Activate()
14         {
15             CreateFirstPage();
16         }
17
18         private void CreateFirstPage()
19         {
20             firstActionButton = new Button()
21             {
22                 Text = "2",
23                 Size = new Size(72.0f, 72.0f)
24             };
25             firstActionButton.Clicked += (object sender, ClickedEventArgs e) =>
26             {
27                 CreateSecondPage();
28             };
29
30             firstAppBar = new AppBar("First Page", firstActionButton)
31             {
32                 AutoNavigationContent = false
33             };
34
35             firstButton = new Button()
36             {
37                 Text = "Click to next",
38                 WidthSpecification = LayoutParamPolicies.MatchParent,
39                 HeightSpecification = LayoutParamPolicies.MatchParent,
40             };
41             firstButton.Clicked += (object sender, ClickedEventArgs e) =>
42             {
43                 CreateSecondPage();
44             };
45
46             firstPage = new Page(firstAppBar, firstButton);
47
48             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(firstPage);
49         }
50
51         private void CreateSecondPage()
52         {
53             secondActionButton = new Button()
54             {
55                 Text = "1",
56                 Size = new Size(72.0f, 72.0f)
57             };
58             secondActionButton.Clicked += (object sender, ClickedEventArgs e) =>
59             {
60                 NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
61             };
62
63             secondAppBar = new AppBar("Second Page", secondActionButton);
64
65             secondButton = new Button()
66             {
67                 Text = "Click to prev",
68                 WidthSpecification = LayoutParamPolicies.MatchParent,
69                 HeightSpecification = LayoutParamPolicies.MatchParent,
70             };
71             secondButton.Clicked += (object sender, ClickedEventArgs e) =>
72             {
73                 NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
74             };
75
76             secondPage = new Page(secondAppBar, secondButton);
77
78             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(secondPage);
79         }
80
81         public void Deactivate()
82         {
83             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Remove(secondPage);
84
85             secondPage = null;
86             secondAppBar = null;
87             secondActionButton = null;
88             secondButton = null;
89
90             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Remove(firstPage);
91
92             firstPage = null;
93             firstAppBar = null;
94             firstActionButton = null;
95             firstButton = null;
96         }
97     }
98 }