[NUI] propose Slider's key navigation and edit mode, Add more samples in StyleGuilde
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.StyleGuide / Examples / AlertDialogExample.cs
1 /*
2  * Copyright(c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using Tizen.NUI;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Components;
22
23 namespace Tizen.NUI.StyleGuide
24 {
25     // IExample inehrited class will be automatically added in the main examples list.
26     internal class AlertDialogExample : ContentPage, IExample
27     {
28         private View rootContent;
29         private Button buttonOneAction, buttonTwoAction, buttonNoTitle, buttonNoMessage;
30
31         public void Activate()
32         {
33         }
34         public void Deactivate()
35         {
36         }
37
38         /// Modify this method for adding other examples.
39         public AlertDialogExample() : base()
40         {
41             WidthSpecification = LayoutParamPolicies.MatchParent;
42             HeightSpecification = LayoutParamPolicies.MatchParent;
43
44             // Navigator bar title is added here.
45             AppBar = new AppBar()
46             {
47                 Title = "AlertDialog Default Style",
48             };
49
50             // Example root content view.
51             // you can decorate, add children on this view.
52             rootContent = new View()
53             {
54                 WidthSpecification = LayoutParamPolicies.MatchParent,
55                 HeightSpecification = LayoutParamPolicies.MatchParent,
56
57                 Layout = new LinearLayout()
58                 {
59                     LinearOrientation = LinearLayout.Orientation.Vertical,
60                     HorizontalAlignment = HorizontalAlignment.Center,
61                     VerticalAlignment = VerticalAlignment.Center,
62                     CellPadding = new Size2D(10, 20),
63                 },
64             };
65
66             buttonOneAction = new Button
67             {
68                 Name = "buttonOneAction",
69                 Text = "Show AlertDialog with one button",
70                 WidthSpecification = LayoutParamPolicies.MatchParent,
71             };
72             rootContent.Add(buttonOneAction);
73
74             buttonOneAction.Clicked += (s, e) =>
75             {
76                 var button = new Button()
77                 {
78                     Text = "OK",
79                 };
80
81                 button.Clicked += (object s, ClickedEventArgs a) =>
82                 {
83                     Navigator?.Pop();
84                 };
85
86                 DialogPage.ShowAlertDialog("Title", "Message", button);
87             };
88
89             buttonTwoAction = new Button
90             {
91                 Name = "buttonTwoAction",
92                 Text = "Show AlertDialog with two buttons",
93                 WidthSpecification = LayoutParamPolicies.MatchParent,
94             };
95             rootContent.Add(buttonTwoAction);
96
97             buttonTwoAction.Clicked += (s, e) =>
98             {
99                 var button = new Button()
100                 {
101                     Text = "Cancel",
102                 };
103
104                 button.Clicked += (object s, ClickedEventArgs a) =>
105                 {
106                     Navigator?.Pop();
107                 };
108
109                 var button2 = new Button()
110                 {
111                     Text = "OK",
112                 };
113
114                 button2.Clicked += (object s, ClickedEventArgs a) =>
115                 {
116                     Navigator?.Pop();
117                 };
118
119                 DialogPage.ShowAlertDialog("Title", "Message", button, button2);
120             };
121
122             buttonNoTitle = new Button
123             {
124                 Name = "buttonNoTitle",
125                 Text = "Show AlertDialog without title",
126                 WidthSpecification = LayoutParamPolicies.MatchParent,
127             };
128             rootContent.Add(buttonNoTitle);
129
130             buttonNoTitle.Clicked += (s, e) =>
131             {
132                 var button = new Button()
133                 {
134                     Text = "Cancel",
135                 };
136
137                 button.Clicked += (object s, ClickedEventArgs a) =>
138                 {
139                     Navigator?.Pop();
140                 };
141
142                 var button2 = new Button()
143                 {
144                     Text = "OK",
145                 };
146
147                 button2.Clicked += (object s, ClickedEventArgs a) =>
148                 {
149                     Navigator?.Pop();
150                 };
151
152                 DialogPage.ShowAlertDialog(null, "Message", button, button2);
153             };
154
155             buttonNoMessage = new Button
156             {
157                 Name = "buttonNoMessage",
158                 Text = "Show AlertDialog without message",
159                 WidthSpecification = LayoutParamPolicies.MatchParent,
160             };
161             rootContent.Add(buttonNoMessage);
162
163             buttonNoMessage.Clicked += (s, e) =>
164             {
165                 var button = new Button()
166                 {
167                     Text = "Cancel",
168                 };
169
170                 button.Clicked += (object s, ClickedEventArgs a) =>
171                 {
172                     Navigator?.Pop();
173                 };
174
175                 var button2 = new Button()
176                 {
177                     Text = "OK",
178                 };
179
180                 button2.Clicked += (object s, ClickedEventArgs a) =>
181                 {
182                     Navigator?.Pop();
183                 };
184
185                 DialogPage.ShowAlertDialog("Title", null, button, button2);
186             };
187
188             Content = rootContent;
189         }
190     }
191 }