/
FixedPastProblemsOverlay.cs
executable file
·122 lines (101 loc) · 3.96 KB
/
FixedPastProblemsOverlay.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
using System;
using CoreGraphics;
using UIKit;
namespace AircraftForSale
{
public class FixedPastProblemsOverlay : UIView
{
// control declarations
UIButton registerButton;
UIButton laterButton;
UILabel solicitLabel;
public UIViewController ParentViewController
{
get;
set;
}
public FixedPastProblemsOverlay(CGRect frame) : base(frame)
{
int fontSizeForSolicitLabel = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 18 : 10;
int fontSizeForRegisterButton = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 30 : 18;
int fontSizeForLaterButton = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 15 : 10;
// configurable bits
BackgroundColor = UIColor.White.ColorWithAlpha(.7f);
var centerPoint = new CGPoint(frame.Size.Width / 2, frame.Size.Height / 2);
UIView backgroundModalView = new UIView(new CGRect(0,0, UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? frame.Size.Width * .5 : frame.Size.Width * .6, UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? frame.Size.Height * .25 : frame.Size.Height * .3));
backgroundModalView.BackgroundColor = UIColor.White;
backgroundModalView.Center = centerPoint;
backgroundModalView.Layer.CornerRadius = (float)(frame.Size.Height * .45) / 4;
backgroundModalView.ClipsToBounds = true;
this.AddSubview(backgroundModalView);
AutoresizingMask = UIViewAutoresizing.All;
nfloat labelHeight = backgroundModalView.Frame.Height/ 2.75f;
nfloat labelWidth = (System.nfloat)(backgroundModalView.Frame.Width * .75);
// derive the center x and y
nfloat centerX = backgroundModalView.Frame.Width / 2;
nfloat centerY = backgroundModalView.Frame.Height / 2;
solicitLabel = new UILabel(new CGRect(
centerX - (labelWidth / 2),
centerY - (centerY/1.5),
labelWidth,
labelHeight
));
solicitLabel.Lines = 0;
solicitLabel.TextColor = UIColor.Black;
//Clay Martin 1/1/18: Change app name to BuyPlane
solicitLabel.Text = "Welcome Back";
solicitLabel.TextAlignment = UITextAlignment.Center;
solicitLabel.Font = UIFont.BoldSystemFontOfSize(fontSizeForSolicitLabel);
solicitLabel.AutoresizingMask = UIViewAutoresizing.All;
solicitLabel.LineBreakMode = UILineBreakMode.WordWrap;
solicitLabel.AdjustsFontSizeToFitWidth = false;
backgroundModalView.AddSubview(solicitLabel);
registerButton = new UIButton(UIButtonType.RoundedRect);
registerButton.SetTitle("REGISTER NOW!", UIControlState.Normal);
registerButton.Frame = new CGRect(
centerX - (labelWidth / 2),
centerY,
labelWidth,
labelHeight
);
registerButton.Font = UIFont.BoldSystemFontOfSize(fontSizeForRegisterButton);
registerButton.AutoresizingMask = UIViewAutoresizing.All;
registerButton.TouchUpInside += (sender, e) =>
{
if (ParentViewController != null)
{
FavoriteClassificationsViewController favClassificationsVC = new FavoriteClassificationsViewController(new AircraftGridLayout(ParentViewController));
ParentViewController.ShowViewController(new UINavigationController(favClassificationsVC), this);
Hide();
}
};
backgroundModalView.AddSubview(registerButton);
laterButton = new UIButton(UIButtonType.RoundedRect);
laterButton.SetTitle("I'LL REGISTER LATER", UIControlState.Normal);
laterButton.Frame = new CGRect(
centerX - (labelWidth / 2),
centerY + (centerY / 2.5),
labelWidth,
labelHeight
);
laterButton.Font = UIFont.BoldSystemFontOfSize(fontSizeForLaterButton);
laterButton.AutoresizingMask = UIViewAutoresizing.All;
laterButton.TouchUpInside += (sender, e) =>
{
Hide();
};
backgroundModalView.AddSubview(laterButton);
}
/// <summary>
/// Fades out the control and then removes it from the super view
/// </summary>
public void Hide()
{
UIView.Animate(
0.5, // duration
() => { Alpha = 0; },
() => { RemoveFromSuperview(); }
);
}
}
}