summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2634.cs
blob: b2cf73909907d768d1845e973d2d8ee9b3b51a97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
using System;

using Xamarin.Forms;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 2634, "Keyboard causes view to scroll incorrectly", PlatformAffected.iOS)]
	public class Issue2634 : ContentPage
	{
		public Issue2634 ()
		{
			Content = new AddPatientView ();
		}

		public class AddPatientView : ContentView
		{
			Entry _firstNameEntry;

			public AddPatientView ()
			{
				var bvBackground = new Frame {
					Content = new Label { Text = "" },
					OutlineColor = Color.FromRgb (0x06, 0x68, 0xCF),
					BackgroundColor = Color.FromRgba (0f, 0f, 0f, 0.4f),
					HasShadow = true
				};

				var addGrid = new Grid {
					VerticalOptions = LayoutOptions.FillAndExpand,
					RowDefinitions = {
						new RowDefinition { Height = new GridLength (10, GridUnitType.Absolute) },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
						new RowDefinition { Height = new GridLength (10, GridUnitType.Absolute) },
					},
					ColumnDefinitions = {
						new ColumnDefinition { Width = new GridLength (10, GridUnitType.Absolute) },
						new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
						new ColumnDefinition { Width = new GridLength (10, GridUnitType.Absolute) },
					},
					ColumnSpacing = 1,
					RowSpacing = 1,
					Padding = 0
				};


				#region QuickAdd Data Entry
				var gridAddData = new Grid {
					RowDefinitions = {
						new RowDefinition { Height = new GridLength (0, GridUnitType.Absolute) },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = new GridLength (15, GridUnitType.Absolute) },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = new GridLength (15, GridUnitType.Absolute) },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = new GridLength (15, GridUnitType.Absolute) },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = new GridLength (15, GridUnitType.Absolute) },
						new RowDefinition { Height = GridLength.Auto },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
					},
					ColumnDefinitions = {
						new ColumnDefinition { Width = new GridLength (60, GridUnitType.Absolute)  },
						new ColumnDefinition { Width = GridLength.Auto },
						new ColumnDefinition { Width = new GridLength (10, GridUnitType.Absolute)  },
						new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star)  },
						new ColumnDefinition { Width = new GridLength (60, GridUnitType.Absolute)  }
					},
					BackgroundColor = Color.Transparent,
					ColumnSpacing = 1,
					RowSpacing = 1,
					Padding = 0
				};
				Color textColor = Color.Blue;
				Color dataColor = Color.Black;

				var slFirstName = new StackLayout { Orientation = StackOrientation.Vertical };
				var lblFirstNameLabel = new Label {
					Text = "First Name",
#pragma warning disable 618
					Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold),
#pragma warning restore 618
					TextColor = textColor
				};
				_firstNameEntry = new Entry {
					Keyboard = Keyboard.Default,
					TextColor = dataColor,
					Placeholder = "First Name (required)",
				};
				slFirstName.Children.Add (lblFirstNameLabel);
				slFirstName.Children.Add (_firstNameEntry);
				gridAddData.Children.Add (slFirstName, 1, 4, 1, 2);

				var slMiddleName = new StackLayout { Orientation = StackOrientation.Vertical };
				var lblMiddleNameLabel = new Label {
					Text = "Middle Name",
#pragma warning disable 618
					Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold),
#pragma warning restore 618
					TextColor = textColor
				};
				var entMiddleName = new Entry {
					Keyboard = Keyboard.Default,
					TextColor = dataColor,
					Placeholder = "Middle Name",
				};
				slMiddleName.Children.Add (lblMiddleNameLabel);
				slMiddleName.Children.Add (entMiddleName);
				gridAddData.Children.Add (slMiddleName, 1, 4, 3, 4);

				var slLastName = new StackLayout { Orientation = StackOrientation.Vertical };
				var lblLastNameLabel = new Label {
					Text = "Last Name",
#pragma warning disable 618
					Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold),
#pragma warning restore 618
					TextColor = textColor
				};
				var entLastName = new Entry {
					Keyboard = Keyboard.Default,
					TextColor = dataColor,
					Placeholder = "Last Name (required)",
				};
				slLastName.Children.Add (lblLastNameLabel);
				slLastName.Children.Add (entLastName);
				gridAddData.Children.Add (slLastName, 1, 4, 5, 6);

				var slDob = new StackLayout { Orientation = StackOrientation.Vertical };
				var lblDobLabel = new Label {
					Text = "Date of Birth",
#pragma warning disable 618
					Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold),
#pragma warning restore 618
					TextColor = textColor,
#pragma warning disable 618
					XAlign = TextAlignment.Start
#pragma warning restore 618
				};
				var entDob = new Entry {
					TextColor = dataColor,
					Placeholder = "mm/dd/yyyy (required)",
					Keyboard = Keyboard.Numeric
				};
				slDob.Children.Add (lblDobLabel);
				slDob.Children.Add (entDob);
				gridAddData.Children.Add (slDob, 1, 7);

				var slGender = new StackLayout { Orientation = StackOrientation.Vertical };
				var lblGenderLabel = new Label {
					Text = "Gender",
#pragma warning disable 618
					Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold),
#pragma warning restore 618
					TextColor = textColor,
#pragma warning disable 618
					XAlign = TextAlignment.Start
#pragma warning restore 618
				};
				slGender.Children.Add (lblGenderLabel);


				gridAddData.Children.Add (slGender, 3, 7);

				var slHomePhone = new StackLayout { Orientation = StackOrientation.Vertical };
				var lblHomePhoneLabel = new Label {
					Text = "Home Phone",
#pragma warning disable 618
					Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold),
#pragma warning restore 618
					TextColor = textColor,
#pragma warning disable 618
					XAlign = TextAlignment.Start
#pragma warning restore 618
				};
				var entHomePhone = new Entry {
					TextColor = dataColor,
					Keyboard = Keyboard.Telephone,
					Placeholder = "888-888-8888",
					//MaxLength = 12
				};
				entHomePhone.TextChanged += (object sender, TextChangedEventArgs e) => {
				};
				slHomePhone.Children.Add (lblHomePhoneLabel);
				slHomePhone.Children.Add (entHomePhone);
				gridAddData.Children.Add (slHomePhone, 1, 9);

				var slMobilePhone = new StackLayout { Orientation = StackOrientation.Vertical };
				var lblMobilePhoneLabel = new Label {
					Text = "Mobile Phone",
#pragma warning disable 618
					Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold),
#pragma warning restore 618
					TextColor = textColor,
#pragma warning disable 618
					XAlign = TextAlignment.Start
#pragma warning restore 618
				};
				var entMobilePhone = new Entry {
					TextColor = dataColor,
					Keyboard = Keyboard.Telephone,
					Placeholder = "888-888-8888",
				};
				entMobilePhone.TextChanged += (object sender, TextChangedEventArgs e) => {
				};
				slMobilePhone.Children.Add (lblMobilePhoneLabel);
				slMobilePhone.Children.Add (entMobilePhone);
				gridAddData.Children.Add (slMobilePhone, 3, 9);
				#endregion

				string breakText = "_______________________________________________________________________________________________________________________________________________________________________________";
				var lblBreakLine = new Label { LineBreakMode = LineBreakMode.NoWrap, TextColor = Color.Red };
				lblBreakLine.Text = breakText;
				addGrid.Children.Add (lblBreakLine, 0, 3, 2, 3);

				var slFrameContent = new StackLayout { Orientation = StackOrientation.Vertical };
				slFrameContent.Children.Add (addGrid);
				var svAddData = new ScrollView { Content = gridAddData, IsClippedToBounds = true, IsVisible = true };
				slFrameContent.Children.Add (svAddData);

				var addFrame = new Frame {
					Content = slFrameContent,
					Padding = 5,
					HasShadow = true
				};

				var rl = new RelativeLayout ();
				rl.Children.Add (bvBackground, Forms.Constraint.Constant (0), Forms.Constraint.Constant (0),
					Forms.Constraint.RelativeToParent ((parent) =>
						parent.Width),
					Forms.Constraint.RelativeToParent ((parent) =>
						parent.Height));

				rl.Children.Add (addFrame,
					Forms.Constraint.RelativeToParent ((parent) =>
						(parent.Width * .25) / 2),
					Forms.Constraint.Constant (Device.OnPlatform (60, 40, 40)),
					Forms.Constraint.RelativeToParent ((parent) =>
						parent.Width * .75));

				Content = rl;
			}

			void cancelButton_Clicked (object sender, EventArgs e)
			{
				_firstNameEntry.Focus ();
				_firstNameEntry.Unfocus ();   // done to remove focus from an entry field so keyboard will go away
			}

			void doneButton_Clicked (object sender, EventArgs e)
			{
				_firstNameEntry.Focus ();
				_firstNameEntry.Unfocus ();   // done to remove focus from an entry field so keyboard will go away
			}

			DataTemplate CreateDtForList ()
			{
				var dt = new DataTemplate (() => {
					// grid for one row definition
					var grid = new Grid {
						RowDefinitions = {
							new RowDefinition { Height = new GridLength (84, GridUnitType.Absolute) },
						},
						ColumnDefinitions = {
							new ColumnDefinition { Width = new GridLength (15, GridUnitType.Absolute)  },
							new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star)  },
							new ColumnDefinition { Width = new GridLength (3, GridUnitType.Absolute)  }
						},
						ColumnSpacing = 1,
						RowSpacing = 1,
						Padding = 0,
						VerticalOptions = LayoutOptions.Center
					};

					Color txtColor = Color.Blue;
					Font dataFont = Font.SystemFontOfSize (NamedSize.Medium);
					var nameData = new Label {
						TextColor = txtColor,
#pragma warning disable 618
						Font = dataFont,
#pragma warning restore 618

#pragma warning disable 618
						XAlign = TextAlignment.Start,
#pragma warning restore 618

#pragma warning disable 618
						YAlign = TextAlignment.Center,
#pragma warning restore 618
						VerticalOptions = LayoutOptions.Center
					};
					nameData.SetBinding (Label.TextProperty, "Name");
					var genderData = new Label {
						TextColor = txtColor,
#pragma warning disable 618
						Font = dataFont,
#pragma warning restore 618

#pragma warning disable 618
						XAlign = TextAlignment.Start,
#pragma warning restore 618

#pragma warning disable 618
						YAlign = TextAlignment.Center,
#pragma warning restore 618
						VerticalOptions = LayoutOptions.Center
					};
					genderData.SetBinding (Label.TextProperty, "Gender");
					var slNameGender = new StackLayout { Orientation = StackOrientation.Horizontal };
#pragma warning disable 618
					var lblGender1 = new Label { Text = " (", Font = dataFont };
#pragma warning restore 618

#pragma warning disable 618
					var lblGender2 = new Label { Text = ")", Font = dataFont };
#pragma warning restore 618
					slNameGender.Children.Add (nameData);
					slNameGender.Children.Add (lblGender1);
					slNameGender.Children.Add (genderData);
					slNameGender.Children.Add (lblGender2);


					var lblDob = new Label {
						TextColor = txtColor,
						Text = "DOB: ",
#pragma warning disable 618
						Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold)
#pragma warning restore 618
					};
					var dobData = new Label {
						TextColor = txtColor,
#pragma warning disable 618
						Font = dataFont,
#pragma warning restore 618

#pragma warning disable 618
						XAlign = TextAlignment.Start,
#pragma warning restore 618

#pragma warning disable 618
						YAlign = TextAlignment.Center,
#pragma warning restore 618
						VerticalOptions = LayoutOptions.Center
					};
					dobData.SetBinding (Label.TextProperty, "DateOfBirth");
					var slDobPhone = new StackLayout { Orientation = StackOrientation.Horizontal };
					slDobPhone.Children.Add (lblDob);
					slDobPhone.Children.Add (dobData);

#pragma warning disable 618
					var lblSpacer = new Label { Text = "      ", Font = dataFont };
#pragma warning restore 618
					slDobPhone.Children.Add (lblSpacer);

					var lblPhone = new Label {
						TextColor = txtColor,
						Text = "PHONE: ",
#pragma warning disable 618
						Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold)
#pragma warning restore 618
					};
					var phoneData = new Label {
						TextColor = txtColor,
#pragma warning disable 618
						Font = dataFont,
#pragma warning restore 618

#pragma warning disable 618
						XAlign = TextAlignment.Start,
#pragma warning restore 618

#pragma warning disable 618
						YAlign = TextAlignment.Center,
#pragma warning restore 618
						VerticalOptions = LayoutOptions.Center
					};
					phoneData.SetBinding (Label.TextProperty, "PrimaryPhone");
					slDobPhone.Children.Add (lblPhone);
					slDobPhone.Children.Add (phoneData);

					var slTotal = new StackLayout { Orientation = StackOrientation.Vertical };
					slTotal.Children.Add (slNameGender);
					slTotal.Children.Add (slDobPhone);

					grid.Children.Add (slTotal, 1, 0);
					return new ViewCell {
						View = grid
					};

				});
				return dt;
			}
		}
	}
}