-
Notifications
You must be signed in to change notification settings - Fork 204
/
RadioButton_Mobile.cs
162 lines (145 loc) · 6.96 KB
/
RadioButton_Mobile.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
#region Copyright Syncfusion Inc. 2001-2024.
// Copyright Syncfusion Inc. 2001-2024. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using UIKit;
using Syncfusion.iOS.Buttons;
using CoreGraphics;
using CoreAnimation;
namespace SampleBrowser
{
public class RadioButton_Mobile : SampleView
{
UIView View;
UIStackView mainStackView = new UIStackView();
UILabel hedinglbl = new UILabel();
UILabel payamountlabl = new UILabel();
UILabel amntLabl = new UILabel();
UILabel selcetPaylbl = new UILabel();
SfRadioGroup sfr = new SfRadioGroup();
UIButton button = new UIButton();
CALayer layer = new CALayer();
CALayer innerLayer = new CALayer();
UIAlertView alertView = new UIAlertView();
SfRadioButton netBanking = new SfRadioButton();
SfRadioButton debitCard = new SfRadioButton();
SfRadioButton creditCard = new SfRadioButton();
UIFontDescriptor descriptor = null;
UIFontDescriptorSymbolicTraits traits = (UIFontDescriptorSymbolicTraits)0;
public RadioButton_Mobile()
{
View = new UIView();
//Main statck
layer.BorderWidth = 1.5f;
layer.CornerRadius = 10;
layer.BorderColor = UIColor.FromRGB(205, 205, 205).CGColor;
Layer.AddSublayer(layer);
//inner layer
innerLayer.BorderWidth = 1.5f;
innerLayer.CornerRadius = 10;
innerLayer.BorderColor = UIColor.FromRGB(205, 205, 205).CGColor;
mainStackView.Layer.AddSublayer(innerLayer);
descriptor = new UIFontDescriptor().CreateWithFamily(amntLabl.Font.FamilyName);
traits = traits | UIFontDescriptorSymbolicTraits.Bold;
descriptor = descriptor.CreateWithTraits(traits);
//heading
hedinglbl.Text = "Complete your Payment";
hedinglbl.TextColor = UIColor.FromRGB(85, 85, 85);
hedinglbl.Font = UIFont.FromDescriptor(descriptor, 20);
mainStackView.AddSubview(hedinglbl);
//payable
payamountlabl.Text = "Total payable amount";
payamountlabl.TextColor = UIColor.Black;
mainStackView.AddSubview(payamountlabl);
//amount
amntLabl.Text = "$120";
amntLabl.TextColor = UIColor.FromRGB(0, 125, 230);
amntLabl.Font = UIFont.FromDescriptor(descriptor, 18);
mainStackView.AddSubview(amntLabl);
//amount
selcetPaylbl.Text = "Select your payment mode";
mainStackView.AddSubview(selcetPaylbl);
//RadioGroup
sfr.Axis = UILayoutConstraintAxis.Vertical;
sfr.Spacing = 20;
netBanking.SetTitle("Net banking", UIControlState.Normal);
netBanking.StateChanged += paymentMode_StateChanged;
sfr.AddArrangedSubview(netBanking);
debitCard.SetTitle("Debit card", UIControlState.Normal);
debitCard.StateChanged += paymentMode_StateChanged;
sfr.AddArrangedSubview(debitCard);
creditCard.SetTitle("Credit card", UIControlState.Normal);
creditCard.StateChanged += paymentMode_StateChanged;
sfr.AddArrangedSubview(creditCard);
mainStackView.AddSubview(sfr);
View.AddSubview(mainStackView);
button.SetTitle("Pay Now", UIControlState.Normal);
button.SetTitleColor(UIColor.LightGray, UIControlState.Disabled);
button.SetTitleColor(UIColor.White, UIControlState.Normal);
button.TouchDown += Button_Clicked;
button.BackgroundColor = UIColor.FromRGB(0, 125, 230);
button.Enabled = false;
alertView.Message = "Payment Successfull !";
alertView.AddButton("OK");
View.AddSubview(button);
AddSubview(View);
}
public override void LayoutSubviews()
{
foreach (var view in this.Subviews)
{
view.Frame = new CGRect(Frame.Location.X, 0.0f, Frame.Size.Width, Frame.Size.Height);
if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
{
mainStackView.Frame = new CGRect(45, 110, Frame.Size.Width - 110, 550);
layer.Frame = new CGRect(45, 90, Frame.Size.Width - 110, 550);
hedinglbl.Frame = new CGRect(150, 20, 400, 45);
payamountlabl.Frame = new CGRect(20, 100, 350, 35);
amntLabl.Frame = new CGRect(580, 100, 350, 35);
innerLayer.Frame = new CGRect(17, 170, 625, 2);
selcetPaylbl.Frame = new CGRect(20, 205, 400, 35);
sfr.Frame = new CGRect(20, 275, 200, 200);
sfr.Spacing = 40;
button.Frame = new CGRect(0, Frame.Size.Height - 40, Frame.Size.Width, 40);
hedinglbl.Font = UIFont.FromDescriptor(descriptor, 30);
payamountlabl.Font = UIFont.FromName(payamountlabl.Font.FamilyName, 22);
amntLabl.Font = UIFont.FromDescriptor(descriptor, 22);
selcetPaylbl.Font = UIFont.FromName(selcetPaylbl.Font.FamilyName, 22);
netBanking.Font = UIFont.FromName(netBanking.Font.FamilyName, 20);
debitCard.Font = UIFont.FromName(netBanking.Font.FamilyName, 20);
creditCard.Font = UIFont.FromName(netBanking.Font.FamilyName, 20);
button.Font = UIFont.FromName(netBanking.Font.FamilyName, 25);
}
else
{
mainStackView.Frame = new CGRect(20, 35, Frame.Size.Width - 40, 400);
layer.Frame = new CGRect(20, 35, Frame.Size.Width - 40, 400);
hedinglbl.Frame = new CGRect(20, 20, 260, 30);
payamountlabl.Frame = new CGRect(10, 75, 200, 35);
amntLabl.Frame = new CGRect(220, 75, 200, 35);
innerLayer.Frame = new CGRect(8, 140, 263, 1);
selcetPaylbl.Frame = new CGRect(10, 165, 250, 35);
sfr.Frame = new CGRect(10, 220, 200, 150);
button.Frame = new CGRect(0, 465, Frame.Size.Width, 38);
}
}
base.LayoutSubviews();
}
private void Button_Clicked(object sender, EventArgs e)
{
alertView.Show();
debitCard.IsChecked = false;
creditCard.IsChecked = false;
netBanking.IsChecked = false;
button.Enabled = false;
}
private void paymentMode_StateChanged(object sender, StateChangedEventArgs eventArgs)
{
button.Enabled = true;
}
}
}