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