async void CompleteRegistrationButton_TouchUpInside(object sender, EventArgs e) { if (Reachability.IsHostReachable(Settings._baseDomain)) { LoadingOverlay loadingIndicator = new LoadingOverlay(this.View.Frame, "Loading ..."); this.View.AddSubview(loadingIndicator); //Attempt to register in the API var response = await MagAppRegisterResponse.RegisterAsync(); if (response.Status == "Success") { Settings.IsRegistered = true; var alert = UIAlertController.Create("Congratulations!", "You have successfully registered.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) => { })); PresentViewController(alert, animated: true, completionHandler: () => { RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController; var loginVC = registrationVC.PresentingViewController as LoginViewController; registrationVC.DismissViewController(true, null); if (loginVC != null) { loginVC.PerformSegue("LoadTabBarControllerSeque", loginVC); } }); } else { loadingIndicator.Hide(); HelperMethods.SendBasicAlert("Oops.", "There was a problem registering. Please try again."); } } else { HelperMethods.SendBasicAlert("Please connect to the internet", "Internet access is required."); } }
async void CompleteRegistrationButton_TouchUpInside(object sender, EventArgs e) { Settings.FirstName = FirstNameTextField.Text; Settings.LastName = LastNameTextField.Text; Settings.Phone = MobilePhoneTextField.Text; Settings.Company = CompanyTextField.Text; if (Reachability.IsHostReachable(Settings._baseDomain)) { var response = await MagAppRegisterResponse.updateAsync(); if (response.Status == "Success") { Settings.IsRegistered = true; var alert = UIAlertController.Create("Congratulations!", "You have successfully updated.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) => { })); PresentViewController(alert, animated: true, completionHandler: () => { // UIViewController registrationVC = (this.ParentViewController); //registrationVC.DismissViewController(true, null); }); } else { HelperMethods.SendBasicAlert("Oops.", "There was a problem updating. Please try again."); } } else { HelperMethods.SendBasicAlert("Please connect to the internet", "Internet access is required."); } }
public override void ViewDidLoad() { NavigationItem.Title = "Registration"; NavigationItem.BackBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, null); HideKeyboardGesture = new UITapGestureRecognizer(() => { View.EndEditing(true); }); var finishButton = new UIBarButtonItem("Finish", UIBarButtonItemStyle.Plain, async(sender, args) => { if (Reachability.IsHostReachable(Settings._baseDomain)) { LoadingOverlay loadingIndicator = new LoadingOverlay(this.View.Frame, "Loading ..."); this.View.AddSubview(loadingIndicator); //Attempt to register in the API var response = await MagAppRegisterResponse.RegisterAsync(); if (response.Status == "Success") { loadingIndicator.Hide(); Settings.IsRegistered = true; //var registrationStoryboard = UIStoryboard.FromName("Main_ipad", NSBundle.MainBundle); //PushNotificationPromptViewController pushNotificationPromptViewController = (PushNotificationPromptViewController)registrationStoryboard.InstantiateViewController("PushNotificationPromptViewController"); //pushNotificationPromptViewController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; //PresentViewController(pushNotificationPromptViewController, true, () => //{ var alert = UIAlertController.Create("Congratulations!", "You have successfully registered.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) => { this.DismissViewController(true, null); var loginViewController = this.PresentingViewController as LoginViewController; this.NavigationController.DismissViewController(true, null); if (loginViewController != null) { loginViewController.PerformSegue("LoadTabBarControllerSeque", loginViewController); } })); PresentViewController(alert, animated: true, completionHandler: () => { }); //}); } else { loadingIndicator.Hide(); HelperMethods.SendBasicAlert("Oops.", response.ResponseMsg); } } else { HelperMethods.SendBasicAlert("Please connect to the internet", "Internet access is required."); } }); UITextAttributes icoFontAttribute = new UITextAttributes(); icoFontAttribute.Font = UIFont.BoldSystemFontOfSize(20); icoFontAttribute.TextColor = UIColor.White; finishButton.SetTitleTextAttributes(icoFontAttribute, UIControlState.Normal); this.NavigationItem.SetRightBarButtonItem(finishButton, true); var orderByPicker = new UIPickerView(); orderByPicker.Model = new SortOptionsViewModel(); orderByPicker.ShowSelectionIndicator = true; UIToolbar orderByToolbar = new UIToolbar(); orderByToolbar.BarStyle = UIBarStyle.Black; orderByToolbar.Translucent = true; orderByToolbar.SizeToFit(); UIBarButtonItem orderByDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { UITextField textview = OrderByTextField; textview.Text = Settings.SortOptions; textview.ResignFirstResponder(); }); orderByToolbar.SetItems(new UIBarButtonItem[] { orderByDoneButton }, true); OrderByTextField.InputView = orderByPicker; OrderByTextField.InputAccessoryView = orderByToolbar; var timeframePicker = new UIPickerView(); timeframePicker.Model = new TimeframeViewModel(); timeframePicker.ShowSelectionIndicator = true; UIToolbar timeframeToolbar = new UIToolbar(); timeframeToolbar.BarStyle = UIBarStyle.Black; timeframeToolbar.Translucent = true; timeframeToolbar.SizeToFit(); UIBarButtonItem timeframeDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { UITextField textview = TimeFrameTextField; textview.Text = Settings.PurchaseTimeFrame + " months"; textview.ResignFirstResponder(); }); timeframeToolbar.SetItems(new UIBarButtonItem[] { timeframeDoneButton }, true); TimeFrameTextField.InputView = timeframePicker; TimeFrameTextField.InputAccessoryView = timeframeToolbar; var whyFlyPicker = new UIPickerView(); whyFlyPicker.Model = new PurposeViewModel(); whyFlyPicker.ShowSelectionIndicator = true; UIToolbar whyFlyToolbar = new UIToolbar(); whyFlyToolbar.BarStyle = UIBarStyle.Black; whyFlyToolbar.Translucent = true; whyFlyToolbar.SizeToFit(); UIBarButtonItem whyFlyDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { UITextField textview = WhyFlyTextField; //var selected = Settings.LocationResponse.PurposeForFlying.FirstOrDefault(row => row.FlyingPurposeId == Settings.PurposeId); textview.Text = Settings.PurposeString; textview.ResignFirstResponder(); }); whyFlyToolbar.SetItems(new UIBarButtonItem[] { whyFlyDoneButton }, true); WhyFlyTextField.InputView = whyFlyPicker; WhyFlyTextField.InputAccessoryView = whyFlyToolbar; var borderFrameHeight = WhyFlyTextField.Frame.Size.Height - 1; var borderFrameWidth = this.View.Bounds.Width - 20; var borderBackgroundColor = UIColor.Gray.CGColor; // create CALayer var bottomBorder1 = new CALayer(); bottomBorder1.Frame = new CGRect(0.0f, borderFrameHeight, borderFrameWidth, 1.0f); bottomBorder1.BackgroundColor = borderBackgroundColor; var bottomBorder2 = new CALayer(); bottomBorder2.Frame = new CGRect(0.0f, borderFrameHeight, borderFrameWidth, 1.0f); bottomBorder2.BackgroundColor = borderBackgroundColor; var bottomBorder3 = new CALayer(); bottomBorder3.Frame = new CGRect(0.0f, borderFrameHeight, borderFrameWidth, 1.0f); bottomBorder3.BackgroundColor = borderBackgroundColor; var bottomBorder4 = new CALayer(); bottomBorder4.Frame = new CGRect(0.0f, borderFrameHeight, borderFrameWidth, 1.0f); bottomBorder4.BackgroundColor = borderBackgroundColor; var fontSize = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 22.0f : 16.0f; var fontObject = UIFont.SystemFontOfSize(fontSize); WhyFlyTextField.Layer.AddSublayer(bottomBorder2); WhyFlyTextField.Layer.MasksToBounds = true; WhyFlyTextField.AttributedPlaceholder = new NSAttributedString( "Select from list", font: fontObject, foregroundColor: UIColor.DarkGray ); WhyFlyTextField.Font = fontObject; WhyFlyTextField.Text = Settings.PurposeString ?? string.Empty; TimeFrameTextField.Layer.AddSublayer(bottomBorder3); TimeFrameTextField.Layer.MasksToBounds = true; TimeFrameTextField.AttributedPlaceholder = new NSAttributedString( "Select from list", font: fontObject, foregroundColor: UIColor.DarkGray ); TimeFrameTextField.Font = fontObject; TimeFrameTextField.Text = Settings.PurchaseTimeFrame != 0 ? Settings.PurchaseTimeFrame + " months" : string.Empty; OrderByTextField.Layer.AddSublayer(bottomBorder4); OrderByTextField.Layer.MasksToBounds = true; OrderByTextField.AttributedPlaceholder = new NSAttributedString( "Select from list", font: fontObject, foregroundColor: UIColor.DarkGray ); OrderByTextField.Font = fontObject; OrderByTextField.Text = Settings.SortOptions ?? string.Empty; // add to UITextField HoursTextView.Layer.AddSublayer(bottomBorder1); HoursTextView.Layer.MasksToBounds = true; HoursTextView.Font = fontObject; HoursTextView.KeyboardType = UIKeyboardType.NumberPad; HoursTextView.EditingDidEnd += (sender, e) => { if (HoursTextView.Text != string.Empty) { int hours = 0; if (int.TryParse(HoursTextView.Text, out hours) && hours > 0) { Settings.Hours = hours; } } }; HoursTextView.Text = Settings.Hours != 0 ? Settings.Hours.ToString() : string.Empty; }