1
+ using System . Collections . Generic ;
2
+ using Unity . UIWidgets . cupertino ;
3
+ using Unity . UIWidgets . foundation ;
4
+ using Unity . UIWidgets . painting ;
5
+ using Unity . UIWidgets . widgets ;
6
+
7
+ namespace UIWidgetsGallery . gallery {
8
+ /*
9
+ class CupertinoAlertDemo : StatefulWidget {
10
+ public static string routeName = "/cupertino/alert";
11
+ public override State createState() => new _CupertinoAlertDemoState();
12
+ }
13
+
14
+ class _CupertinoAlertDemoState : State<CupertinoAlertDemo> {
15
+ string lastSelectedValue;
16
+
17
+ void showDemoDialog(
18
+ BuildContext context = null,
19
+ Widget child = null
20
+ ) {
21
+ CupertinoRouteUtils.showCupertinoDialog<string>(
22
+ context: context,
23
+ builder: (BuildContext _context) => child
24
+ ).Then((string value) => {
25
+ if (value != null) {
26
+ this.setState(() => { this.lastSelectedValue = value; });
27
+ }
28
+ });
29
+ }
30
+
31
+ void showDemoActionSheet(
32
+ BuildContext context = null,
33
+ Widget child = null
34
+ ) {
35
+ CupertinoRouteUtils.showCupertinoModalPopup<string>(
36
+ context: context,
37
+ builder: (BuildContext _context) => child
38
+ ).Then((string value) => {
39
+ if (value != null) {
40
+ this.setState(() => { this.lastSelectedValue = value; });
41
+ }
42
+ });
43
+ }
44
+
45
+ public override Widget build(BuildContext context) {
46
+ return new CupertinoPageScaffold(
47
+ navigationBar: new CupertinoNavigationBar(
48
+ middle: new Text("Alerts"),
49
+ previousPageTitle: "Cupertino",
50
+ trailing: new CupertinoDemoDocumentationButton(CupertinoAlertDemo.routeName)
51
+ ),
52
+ child:
53
+ new DefaultTextStyle(
54
+ style: CupertinoTheme.of(context).textTheme.textStyle,
55
+ child: new Builder(
56
+ builder: (BuildContext _context) => {
57
+ List<Widget> stackChildren = new List<Widget> {
58
+ new ListView(
59
+ padding: EdgeInsets.symmetric(vertical: 24.0f, horizontal: 72.0f)
60
+ + MediaQuery.of(_context).padding,
61
+ children: new List<Widget> {
62
+ CupertinoButton.filled(
63
+ child: new Text("Alert"),
64
+ onPressed: () => {
65
+ this.showDemoDialog(
66
+ context: _context,
67
+ child: new CupertinoAlertDialog(
68
+ title: new Text("Discard draft?"),
69
+ actions: new List<Widget> {
70
+ new CupertinoDialogAction(
71
+ child: new Text("Discard"),
72
+ isDestructiveAction: true,
73
+ onPressed: () => { Navigator.pop(_context, "Discard"); }
74
+ ),
75
+ new CupertinoDialogAction(
76
+ child: new Text("Cancel"),
77
+ isDefaultAction: true,
78
+ onPressed: () => { Navigator.pop(_context, "Cancel"); }
79
+ ),
80
+ }
81
+ )
82
+ );
83
+ }
84
+ ),
85
+ new Padding(padding: EdgeInsets.all(8.0f)),
86
+ CupertinoButton.filled(
87
+ child: new Text("Alert with Title"),
88
+ padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
89
+ onPressed: () => {
90
+ this.showDemoDialog(
91
+ context: _context,
92
+ child: new CupertinoAlertDialog(
93
+ title: new Text(
94
+ "Allow \"Maps\" to access your location while you are using the app?")
95
+ ,
96
+ content: new Text(
97
+ "Your current location will be displayed on the map and used \n" +
98
+ "for directions, nearby search results, and estimated travel times.")
99
+ ,
100
+ actions: new List<Widget> {
101
+ new CupertinoDialogAction(
102
+ child: new Text("Don\"t Allow"),
103
+ onPressed: () => {
104
+ Navigator.pop(_context, "Disallow");
105
+ }
106
+ ),
107
+ new CupertinoDialogAction(
108
+ child: new Text("Allow"),
109
+ onPressed: () => { Navigator.pop(_context, "Allow"); }
110
+ ),
111
+ }
112
+ )
113
+ );
114
+ }
115
+ ),
116
+ new Padding(padding: EdgeInsets.all(8.0f)),
117
+ CupertinoButton.filled(
118
+ child: new Text("Alert with Buttons"),
119
+ padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
120
+ onPressed: () => {
121
+ this.showDemoDialog(
122
+ context: _context,
123
+ child: new CupertinoDessertDialog(
124
+ title: new Text("Select Favorite Dessert"),
125
+ content: new Text(
126
+ "Please select your favorite type of dessert from the \n" +
127
+ "list below. Your selection will be used to customize the suggested \n" +
128
+ "list of eateries in your area.")
129
+ )
130
+ );
131
+ }
132
+ ),
133
+ new Padding(padding: EdgeInsets.all(8.0f)),
134
+ CupertinoButton.filled(
135
+ child: new Text("Alert Buttons Only"),
136
+ padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
137
+ onPressed: () => {
138
+ this.showDemoDialog(
139
+ context: _context,
140
+ child: new CupertinoDessertDialog()
141
+ );
142
+ }
143
+ ),
144
+ new Padding(padding: EdgeInsets.all(8.0f)),
145
+ CupertinoButton.filled(
146
+ child: new Text("Action Sheet"),
147
+ padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
148
+ onPressed: () => {
149
+ this.showDemoActionSheet(
150
+ context: _context,
151
+ child: new CupertinoActionSheet(
152
+ title: new Text("Favorite Dessert"),
153
+ message:
154
+ new Text(
155
+ "Please select the best dessert from the options below."),
156
+ actions:
157
+ new List<Widget> {
158
+ new CupertinoActionSheetAction(
159
+ child: new Text("Profiteroles"),
160
+ onPressed: () => {
161
+ Navigator.pop(_context, "Profiteroles");
162
+ }
163
+ ),
164
+ new CupertinoActionSheetAction(
165
+ child: new Text("Cannolis"),
166
+ onPressed: () => {
167
+ Navigator.pop(_context, "Cannolis");
168
+ }
169
+ ),
170
+ new CupertinoActionSheetAction(
171
+ child: new Text("Trifle"),
172
+ onPressed: () => { Navigator.pop(_context, "Trifle"); }
173
+ ),
174
+ },
175
+ cancelButton: new CupertinoActionSheetAction(
176
+ child: new Text("Cancel"),
177
+ isDefaultAction:
178
+ true,
179
+ onPressed:
180
+ () => { Navigator.pop(_context, "Cancel"); }
181
+ )
182
+ )
183
+ );
184
+ }
185
+ )
186
+ }
187
+ )
188
+ };
189
+
190
+ if (this.lastSelectedValue != null) {
191
+ stackChildren.Add(
192
+ new Positioned(
193
+ bottom: 32.0f,
194
+ child: new Text("You selected: $lastSelectedValue")
195
+ )
196
+ );
197
+ }
198
+
199
+ return new Stack(
200
+ alignment: Alignment.center,
201
+ children: stackChildren
202
+ );
203
+ }
204
+ )
205
+ )
206
+ );
207
+ }
208
+ }
209
+
210
+ class CupertinoDessertDialog : StatelessWidget {
211
+ public CupertinoDessertDialog(
212
+ Key key = null,
213
+ Widget title = null,
214
+ Widget content = null
215
+ ) : base(key: key) {
216
+ this.title = title;
217
+ this.content = content;
218
+ }
219
+
220
+ public readonly Widget title;
221
+ public readonly Widget content;
222
+
223
+ public override Widget build(BuildContext context) {
224
+ return new CupertinoAlertDialog(
225
+ title: title,
226
+ content: content,
227
+ actions: new List<Widget> {
228
+ new CupertinoDialogAction(
229
+ child: new Text("Cheesecake"),
230
+ onPressed: () => { Navigator.pop(context, "Cheesecake"); }
231
+ ),
232
+ new CupertinoDialogAction(
233
+ child: new Text("Tiramisu"),
234
+ onPressed: () => { Navigator.pop(context, "Tiramisu"); }
235
+ ),
236
+ new CupertinoDialogAction(
237
+ child: new Text("Apple Pie"),
238
+ onPressed:
239
+ () => { Navigator.pop(context, "Apple Pie"); }
240
+ ),
241
+ new CupertinoDialogAction(
242
+ child: new Text("Devil\"s food cake"),
243
+ onPressed:
244
+ () => { Navigator.pop(context, "Devil\"s food cake"); }
245
+ ),
246
+ new CupertinoDialogAction(
247
+ child: new Text("Banana Split"),
248
+ onPressed:
249
+ () => { Navigator.pop(context, "Banana Split"); }
250
+ ),
251
+ new CupertinoDialogAction(
252
+ child: new Text("Oatmeal Cookie"),
253
+ onPressed:
254
+ () => { Navigator.pop(context, "Oatmeal Cookies"); }
255
+ ),
256
+ new CupertinoDialogAction(
257
+ child: new Text("Chocolate Brownie"),
258
+ onPressed:
259
+ () => { Navigator.pop(context, "Chocolate Brownies"); }
260
+ ),
261
+ new CupertinoDialogAction(
262
+ child: new Text("Cancel"),
263
+ isDestructiveAction:
264
+ true,
265
+ onPressed:
266
+ () => { Navigator.pop(context, "Cancel"); }
267
+ ),
268
+ }
269
+ );
270
+ }
271
+ }
272
+ */
273
+ }
0 commit comments