-
Notifications
You must be signed in to change notification settings - Fork 204
/
PopupCustomizations.cs
355 lines (325 loc) · 18.4 KB
/
PopupCustomizations.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Graphics;
using Syncfusion.Android.PopupLayout;
using Android.Graphics.Drawables;
using System.Threading.Tasks;
using Android.Util;
namespace SampleBrowser
{
public class PopupCustomizations : SamplePage
{
SfPopupLayout initialPopup;
SfPopupLayout animationPopup;
FrameLayout mainView;
List<TableItem> items;
internal static ListView movieList;
ListView theatreList;
LinearLayout dateSelectionView;
LinearLayout dateView;
internal static RelativeLayout secondPage;
TextView dayLabel;
TextView dateLabel;
Context cont;
float density;
bool pageExited = false;
public override View GetSampleContent(Context context)
{
cont = context;
density = cont.Resources.DisplayMetrics.Density;
CreateMainView();
CreateMovieSelectionPage();
CreateDateSelectionPage();
(context as AllControlsSamplePage).ActionBar.CustomView.SetBackgroundColor(Color.DarkGray);
(context as AllControlsSamplePage).ActionBar.SetBackgroundDrawable(new ColorDrawable(Color.DarkGray));
TheaterAdapter.counter = 0;
return mainView;
}
private void CreateDateSelectionPage()
{
secondPage = new RelativeLayout(cont);
LinearLayout secondPageContent = new LinearLayout(cont);
secondPageContent.Orientation = Orientation.Vertical;
secondPage.Id = 2;
TouchObserverView rel = new TouchObserverView(cont);
rel.Alpha = 0.8f;
rel.ViewAttachedToWindow += async delegate
{
for (int i = 0; i < 3; i++)
{
if (pageExited)
return;
if (TheaterAdapter.counter == 0)
{
rel.Visibility = ViewStates.Visible;
CreateAnimationPopup();
animationPopup.Show(10, 0);
TheaterAdapter.counter++;
await Task.Delay(700);
}
else if (TheaterAdapter.counter == 1)
{
animationPopup.Dismiss();
await Task.Delay(700);
rel.Visibility = ViewStates.Visible;
var image = new ImageView(cont);
animationPopup.PopupView.AnimationMode = AnimationMode.SlideOnLeft;
image.SetImageResource(Resource.Drawable.Popup_TheatrInfo);
animationPopup.PopupView.ContentView = image;
animationPopup.Show((int)(cont.Resources.DisplayMetrics.WidthPixels / density - 40), 135);
TheaterAdapter.counter++;
await Task.Delay(700);
}
else if (TheaterAdapter.counter == 2)
{
animationPopup.Dismiss();
await Task.Delay(700);
rel.Visibility = ViewStates.Visible;
var image = new ImageView(cont);
animationPopup.PopupView.AnimationMode = AnimationMode.SlideOnTop;
image.SetImageResource(Resource.Drawable.Popup_SelectSeats);
animationPopup.PopupView.ContentView = image;
animationPopup.Show(10, 80);
TheaterAdapter.counter++;
await Task.Delay(700);
rel.Visibility = ViewStates.Gone;
animationPopup.StaysOpen = false;
animationPopup.Dismiss();
}
if (TheaterAdapter.counter >= 4)
{
animationPopup.StaysOpen = false;
animationPopup.Dismiss();
}
}
animationPopup.StaysOpen = false;
rel.Visibility = ViewStates.Gone;
animationPopup.Dismiss();
TheaterAdapter.counter = 0;
};
dateSelectionView = new LinearLayout(cont);
dateSelectionView.Orientation = Orientation.Horizontal;
dateSelectionView.AddView(CreateDateView(0, 0), cont.Resources.DisplayMetrics.WidthPixels / 7, ViewGroup.LayoutParams.MatchParent);
dateSelectionView.AddView(CreateDateView(1), cont.Resources.DisplayMetrics.WidthPixels / 7, ViewGroup.LayoutParams.MatchParent);
dateSelectionView.AddView(CreateDateView(2), cont.Resources.DisplayMetrics.WidthPixels / 7, ViewGroup.LayoutParams.MatchParent);
dateSelectionView.AddView(CreateDateView(3), cont.Resources.DisplayMetrics.WidthPixels / 7, ViewGroup.LayoutParams.MatchParent);
dateSelectionView.AddView(CreateDateView(4), cont.Resources.DisplayMetrics.WidthPixels / 7, ViewGroup.LayoutParams.MatchParent);
dateSelectionView.AddView(CreateDateView(5), cont.Resources.DisplayMetrics.WidthPixels / 7, ViewGroup.LayoutParams.MatchParent);
dateSelectionView.AddView(CreateDateView(6), cont.Resources.DisplayMetrics.WidthPixels / 7, ViewGroup.LayoutParams.MatchParent);
theatreList = new ListView(cont);
PopulateTheatreList();
theatreList.Adapter = new TheaterAdapter((cont as AllControlsSamplePage), items, mainView);
theatreList.ItemClick += MovieList_ItemClick;
theatreList.ViewDetachedFromWindow += TheatreList_ViewDetachedFromWindow;
secondPageContent.AddView(dateSelectionView, ViewGroup.LayoutParams.MatchParent, (int)(62 * density));
secondPageContent.AddView(theatreList, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
secondPage.AddView(secondPageContent, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
secondPage.AddView(rel, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
rel.SetBackgroundColor(Color.Black);
}
private void TheatreList_ViewDetachedFromWindow(object sender, View.ViewDetachedFromWindowEventArgs e)
{
if (animationPopup != null)
{
animationPopup.Dismiss();
animationPopup.Visibility = ViewStates.Gone;
}
pageExited = true;
}
public override void Destroy()
{
base.Destroy();
theatreList.ViewDetachedFromWindow -= TheatreList_ViewDetachedFromWindow;
dateView.Click -= DateView_Click;
movieList.ViewAttachedToWindow -= ListViewLoaded;
movieList.ViewDetachedFromWindow -= MovieList_ViewDetachedFromWindow;
movieList.ItemClick -= MovieList_ItemClick;
}
private void CreateAnimationPopup()
{
var image = new ImageView(cont);
image.SetImageResource(Resource.Drawable.Popup_DateSelected);
animationPopup = new SfPopupLayout(cont);
animationPopup.PopupView.AnimationMode = AnimationMode.Zoom;
animationPopup.PopupView.ShowHeader = false;
animationPopup.PopupView.ShowFooter = false;
animationPopup.PopupView.ContentView = image;
animationPopup.PopupView.HeightRequest = 200;
animationPopup.PopupView.WidthRequest = 200;
animationPopup.PopupView.SetBackgroundColor(Color.Transparent);
animationPopup.PopupView.SetBackgroundColor(Color.Transparent);
animationPopup.PopupView.ContentView.SetBackgroundColor(Color.Transparent);
animationPopup.PopupView.PopupStyle.BorderColor = Color.Transparent;
}
private void PopulateTheatreList()
{
items = new List<TableItem>();
items.Add(new TableItem() { Heading = "ABC Cinemas Dolby Atmos", SubHeading = "No.15, 12th Main Road, Sector 1", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="10:00 AM",Timing2="4:00 PM" });
items.Add(new TableItem() { Heading = "XYZ Theater 4K Dolby Atmos", SubHeading = "No.275, 3rd Cross Road,Area 27", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="11:00 AM",Timing2="6:00 PM" });
items.Add(new TableItem() { Heading = "QWERTY Theater", SubHeading = "No.275, 3rd Cross Road,Sector North", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="10:30 AM"});
items.Add(new TableItem() { Heading = "FYI Cinemas 4K", SubHeading = "No.15, 12th Main Road,Sector South", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="3:00 PM" ,});
items.Add(new TableItem() { Heading = "The Cinemas Dolby Digital", SubHeading = "No.275, 3rd Cross Road,Layout 71", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="2:30 PM" ,Timing2="9:00 PM"});
items.Add(new TableItem() { Heading = "SF Theater Dolby Atmos RDX", SubHeading = "North West Layout", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="1:30 PM" ,Timing2="6:00 PM"});
items.Add(new TableItem() { Heading = "Grid Cinemas 4K Dolby Atmos", SubHeading = "No.15, 12th Main Road,Area 33", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="3:30 PM"});
items.Add(new TableItem() { Heading = "Grand Theater", SubHeading = "No.275, 3rd Cross Road,South Sector", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="6:00 PM"});
items.Add(new TableItem() { Heading = "Layout Cinemas Dolby Atmos RDX", SubHeading = "No.15, 12th Main Road,Area 152", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="6:00 PM" ,Timing2="10:30 PM"});
items.Add(new TableItem() { Heading = "Xamarin Cinemas Dolby Atmos RDX", SubHeading = "No.275, 3rd Cross Road,Sector 77", ImageResourceId = Resource.Drawable.Popup_Info, Timing1="2:30 PM" ,Timing2="6:30 PM" });
}
private LinearLayout CreateDateView(int date, object selected = null)
{
dateView = new LinearLayout(cont);
if (selected == null)
dateView.SetBackgroundColor(Color.White);
else
dateView.SetBackgroundColor(Color.ParseColor("#007CEE"));
dateView.Click += DateView_Click;
dateView.Orientation = Orientation.Vertical;
dayLabel = new TextView(cont);
dayLabel.SetBackgroundColor(Color.Transparent);
dayLabel.Text = DateTime.Now.AddDays(date).DayOfWeek.ToString().Substring(0, 3).ToUpper();
if (selected == null)
dayLabel.SetTextColor(Color.Argb(54, 00, 00, 00));
else
dayLabel.SetTextColor(Color.White);
dayLabel.SetTypeface(Typeface.DefaultBold, TypefaceStyle.Bold);
dayLabel.SetTextSize(Android.Util.ComplexUnitType.Dip, 12);
dayLabel.Gravity = GravityFlags.CenterHorizontal | GravityFlags.CenterVertical;
dateLabel = new TextView(cont);
dateLabel.SetBackgroundColor(Color.Transparent);
dateLabel.Text = DateTime.Now.AddDays(date).Day.ToString();
dateLabel.TextAlignment = TextAlignment.Center;
if (selected == null)
dateLabel.SetTextColor(Color.Black);
else
dateLabel.SetTextColor(Color.White);
dateLabel.SetTextSize(Android.Util.ComplexUnitType.Dip, 14);
dateLabel.SetTypeface(Typeface.DefaultBold, TypefaceStyle.Bold);
dateLabel.Gravity = GravityFlags.CenterHorizontal;
dateView.AddView(dayLabel, ViewGroup.LayoutParams.MatchParent, (int)(31 * density));
dateView.AddView(dateLabel, ViewGroup.LayoutParams.MatchParent, (int)(31 * density));
return dateView;
}
private void DateView_Click(object sender, EventArgs e)
{
for (int i = 0; i < ((sender as LinearLayout).Parent as LinearLayout).ChildCount; i++)
{
// Remove selection color to other date views
(((sender as LinearLayout).Parent as LinearLayout).GetChildAt(i) as LinearLayout).SetBackgroundColor(Color.White);
((((sender as LinearLayout).Parent as LinearLayout).GetChildAt(i) as LinearLayout).GetChildAt(0) as TextView).SetTextColor(Color.Argb(54, 00, 00, 00));
((((sender as LinearLayout).Parent as LinearLayout).GetChildAt(i) as LinearLayout).GetChildAt(1) as TextView).SetTextColor(Color.Black);
}
((sender as LinearLayout).GetChildAt(0) as TextView).SetTextColor(Color.White);
((sender as LinearLayout).GetChildAt(1) as TextView).SetTextColor(Color.White);
(sender as LinearLayout).SetBackgroundColor(Color.ParseColor("#007CEE"));
}
private void CreateMovieSelectionPage()
{
movieList = new ListView(cont);
movieList.ViewAttachedToWindow += ListViewLoaded;
movieList.ViewDetachedFromWindow += MovieList_ViewDetachedFromWindow;
movieList.Id = 1;
PopulateMovieList();
movieList.Adapter = new MovieAdapter((cont as AllControlsSamplePage), items, mainView);
movieList.ItemClick += MovieList_ItemClick;
mainView.AddView(movieList);
}
private void MovieList_ViewDetachedFromWindow(object sender, View.ViewDetachedFromWindowEventArgs e)
{
if (initialPopup != null)
{
initialPopup.Dispose();
initialPopup = null;
}
}
private void ListViewLoaded(object sender, View.ViewAttachedToWindowEventArgs e)
{
DisplayInitialPopup();
}
private void CreateMainView()
{
mainView = new FrameLayout(cont);
}
private void PopulateMovieList()
{
items = new List<TableItem>();
items.Add(new TableItem() { Heading = "Longest Run", SubHeading = "Liam Kneeson | Dean Kruger", ImageResourceId = Resource.Drawable.Popup_Movie1 });
items.Add(new TableItem() { Heading = "AA-Team", SubHeading = "Dirk Benedict | Liam Kneeson", ImageResourceId = Resource.Drawable.Popup_Movie2});
items.Add(new TableItem() { Heading = "Configuring 2", SubHeading = "Vera Farmigan | Pat Wilson", ImageResourceId = Resource.Drawable.Popup_Movie3});
items.Add(new TableItem() { Heading = "Inside Us 2", SubHeading = "Pat Wilson | Rose Bryane", ImageResourceId = Resource.Drawable.Popup_Movie4});
items.Add(new TableItem() { Heading = "Safer House", SubHeading = "Regan Reynolds | Denzol Washington", ImageResourceId = Resource.Drawable.Popup_Movie5});
items.Add(new TableItem() { Heading = "Run All Day", SubHeading = "Liam Kneeson | Jeniffer Rodriguez", ImageResourceId = Resource.Drawable.Popup_Movie6});
items.Add(new TableItem() { Heading = "Code Red", SubHeading = "Jake Gylle | Michelle Manhatan", ImageResourceId = Resource.Drawable.Popup_Movie7});
items.Add(new TableItem() { Heading = "Clash Of The Dragons", SubHeading = "Gemma Verteron | Sam Worthonn", ImageResourceId = Resource.Drawable.Popup_Movie8});
items.Add(new TableItem() { Heading = "A Run Among The TombStones", SubHeading = "Liam Kneeson | Daniel Stevens", ImageResourceId = Resource.Drawable.Popup_Movie9});
items.Add(new TableItem() { Heading = "Error 404", SubHeading = "Liam Kneeson | Dene Kruger", ImageResourceId = Resource.Drawable.Popup_Movie10});
}
private void MovieList_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
var backbutton = ((((this.cont as AllControlsSamplePage).SettingsButton.Parent as RelativeLayout).GetChildAt(1) as LinearLayout).GetChildAt(0) as RelativeLayout).GetChildAt(0);
backbutton.Click += backbutton_Click;
}
private void backbutton_Click(object sender, EventArgs e)
{
var child = this.mainView.GetChildAt(0);
if (child.Id == 2)
{
this.mainView.RemoveView(child);
if (this.mainView.IndexOfChild(PopupCustomizations.movieList) == -1)
this.mainView.AddView(movieList);
}
}
internal void DisplayInitialPopup()
{
if (pageExited)
return;
initialPopup = new SfPopupLayout(cont);
initialPopup.PopupView.AppearanceMode = AppearanceMode.OneButton;
initialPopup.PopupView.ShowFooter = true;
initialPopup.PopupView.ShowCloseButton = false;
initialPopup.PopupView.HeaderTitle = "Book tickets !";
initialPopup.PopupView.AcceptButtonText = "OK";
initialPopup.PopupView.PopupStyle.HeaderTextSize = 16;
initialPopup.StaysOpen = true;
TextView messageView = new TextView(this.cont);
messageView.Text = "Click on the book button to start booking tickets";
messageView.SetTextColor(Color.Black);
messageView.SetBackgroundColor(Color.White);
messageView.TextSize = 14;
initialPopup.PopupView.ContentView = messageView;
initialPopup.PopupView.ContentView.SetPadding((int)(10 * density), (int)(10 * density), (int)(10 * density), (int)(10 * density));
initialPopup.PopupView.PopupStyle.CornerRadius = 3;
initialPopup.PopupView.HeightRequest = 180;
initialPopup.Show();
}
}
internal class TouchObserverView : View
{
public TouchObserverView(Context context) : base(context)
{
}
public TouchObserverView(Context context, IAttributeSet attrs) : base(context, attrs)
{
}
public TouchObserverView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
{
}
public TouchObserverView(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes) : base(context, attrs, defStyleAttr, defStyleRes)
{
}
protected TouchObserverView(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
}
public override bool OnTouchEvent(MotionEvent e)
{
return true;
}
}
}