[NUI] Add AppBarStyle class with the latest AppBar UX (#2718)
[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 = "Page 2",
23             };
24             firstActionButton.Clicked += (object sender, ClickedEventArgs e) =>
25             {
26                 CreateSecondPage();
27             };
28
29             firstAppBar = new AppBar()
30             {
31                 AutoNavigationContent = false
32             };
33             firstAppBar.SetTitle("First Page");
34             firstAppBar.AddActions(firstActionButton);
35
36             firstButton = new Button()
37             {
38                 Text = "Click to next",
39                 WidthSpecification = LayoutParamPolicies.MatchParent,
40                 HeightSpecification = LayoutParamPolicies.MatchParent,
41             };
42             firstButton.Clicked += (object sender, ClickedEventArgs e) =>
43             {
44                 CreateSecondPage();
45             };
46
47             firstPage = new Page(firstAppBar, firstButton);
48
49             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(firstPage);
50         }
51
52         private void CreateSecondPage()
53         {
54             secondActionButton = new Button()
55             {
56                 Text = "Page 1",
57             };
58             secondActionButton.Clicked += (object sender, ClickedEventArgs e) =>
59             {
60                 NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
61             };
62
63             secondAppBar = new AppBar();
64             secondAppBar.SetTitle("Second Page");
65             secondAppBar.AddActions(secondActionButton);
66
67             secondButton = new Button()
68             {
69                 Text = "Click to prev",
70                 WidthSpecification = LayoutParamPolicies.MatchParent,
71                 HeightSpecification = LayoutParamPolicies.MatchParent,
72             };
73             secondButton.Clicked += (object sender, ClickedEventArgs e) =>
74             {
75                 NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
76             };
77
78             secondPage = new Page(secondAppBar, secondButton);
79
80             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(secondPage);
81         }
82
83         public void Deactivate()
84         {
85             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Remove(secondPage);
86
87             secondPage = null;
88             secondAppBar = null;
89             secondActionButton = null;
90             secondButton = null;
91
92             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Remove(firstPage);
93
94             firstPage = null;
95             firstAppBar = null;
96             firstActionButton = null;
97             firstButton = null;
98         }
99     }
100 }