Example #1
0
        async void AdRGButton_TouchUpInside(object sender, EventArgs e)
        {
            Ad ad = new Ad();

            if (sender == Ad1RGButton)
            {
                ad = DataObject.Ads[2];
            }

            if (Reachability.IsHostReachable(Settings._baseDomain))
            {
                SpecResponse specResponse = new SpecResponse();

                var specification = await specResponse.GetSpecBySpecIDDesignationIDAsync(ad.SpecId, ad.DesignationId);

                if (specification.SpecId != 0)
                {
                    MapViewController mapViewController = (MapViewController)Storyboard.InstantiateViewController("MapViewController");
                    mapViewController.SpecFieldList = specification.SpecFieldDictionary[SpecTableViewSource._rangeSection];
                    ShowDetailViewController(mapViewController, this);
                }
            }

            else
            {
                HelperMethods.SendBasicAlert("Connect to a Network", Settings._networkProblemMessage);
            }
        }
        async void AdPhone1_TouchUpInside(object sender, EventArgs e)
        {
            var ad = DataObject.Ads[0];
            var brokerPhoneNumber = ad.BrokerPhone;
            var url = new NSUrl("tel:" + brokerPhoneNumber);

            if (!UIApplication.SharedApplication.OpenUrl(url))
            {
                var av = new UIAlertView("Not supported",
                                         "Phone calls are not supported on this device",
                                         null,
                                         "OK",
                                         null);
                av.Show();
            }
            else
            {
                //Send Inquiry
                //Clay Martin 1/1/18: Change app name to BuyPlane
                var response = await AdInquiryResponse.AdInquiry(int.Parse(ad.ID), string.Empty, string.Empty, ad.BrokerPhone, string.Empty
                                                                 , ad.BrokerId, AdInquirySource.Call, "Inquiry about " + ad.Name + " from GlobalAir.com BuyPlane Magazine");

                if (response.Status != "Success")
                {
                    HelperMethods.SendBasicAlert("Oops", "There was a problem sending your email to the aircraft broker. Please try again");
                }
            }
        }
Example #3
0
        void SendEmail_TouchUpInside(object sender, EventArgs args)
        {
            if (Reachability.IsHostReachable(Settings._baseDomain))
            {
                UIButton senderButton = sender as UIButton;

                EmailInquiryViewController emailInquiryViewController = (EmailInquiryViewController)Storyboard.InstantiateViewController("EmailInquiryViewController");
                Ad ad = new Ad();
                if (senderButton == AdEmail1)
                {
                    ad = DataObject.Ads[0];
                }

                if (senderButton == AdEmail2)
                {
                    ad = DataObject.Ads[1];
                }

                if (senderButton == AdEmail3)
                {
                    ad = DataObject.Ads[2];
                }
                if (senderButton == AdEmail4)
                {
                    ad = DataObject.Ads[3];
                }
                emailInquiryViewController.AdProperty = ad;
                this.PresentViewController(emailInquiryViewController, true, null);
            }
            else
            {
                HelperMethods.SendBasicAlert("Connect to a Network", "Please connect to a network to send this email");
            }
        }
        void RefreshButton_TouchUpInside(object sender, EventArgs e)
        {
            if (Reachability.IsHostReachable(Settings._baseDomain))
            {
                LoadingOverlay loadingIndicator = new LoadingOverlay(this.View.Frame);
                this.View.AddSubview(loadingIndicator);
                // button was clicked
                //List<Ad> adList = new List<Ad>();

                Task.Run(async() =>
                {
                    foreach (var classification in Settings.GetFavoredClassifications())
                    {
                        Ad.DeleteAdsByClassification(classification);
                        //adList.AddRange(await Ad.GetAdsByClassificationAsync(classification));
                    }

                    BeginInvokeOnMainThread(() =>
                    {
                        loadingIndicator.Hide();
                    });

                    await LoadTable();
                });
            }
            else
            {
                HelperMethods.SendBasicAlert("Connect to a Network", "Please connect to a network to refresh these ads");
            }
        }
Example #5
0
        void TapImageAction1(UITapGestureRecognizer tap)
        {
            if (Reachability.IsHostReachable(Settings._baseDomain))
            {
                LoadingOverlay loadingOverlay = new LoadingOverlay(View.Frame);
                var            webView        = new UIWebView(View.Frame);


                webView.LoadFinished += (sender, e) =>
                {
                    loadingOverlay.Hide();
                };

                var banManProHREF = Settings.BanManProURL.Replace("Task=Get", "Task=Click");
                ;
                webView.LoadRequest(new NSUrlRequest(new NSUrl(banManProHREF)));

                UIView.BeginAnimations("fadeflag");
                UIView.Animate(1, () =>
                {
                    tap.View.Alpha = .5f;
                }, () =>
                {
                    View.AddSubview(webView);
                    View.AddSubview(loadingOverlay);

                    UIButton closeButton = new UIButton(new CGRect(View.Bounds.Width - 75, 0, 75, 50));
                    closeButton.SetImage(UIImage.FromBundle("close"), UIControlState.Normal);
                    closeButton.BackgroundColor = UIColor.White.ColorWithAlpha(.5f);
                    closeButton.TouchUpInside  += (sender, e) =>
                    {
                        try
                        {
                            webView.RemoveFromSuperview();
                            closeButton.RemoveFromSuperview();
                        }
                        finally
                        {
                            webView.Dispose();
                        }
                    };

                    UIImageView imageView = new UIImageView(new CGRect(View.Bounds.Width - 75, View.Bounds.Height / 2, 75, 50));
                    imageView.Image       = UIImage.FromBundle("swipe_left");
                    imageView.Alpha       = .5f;
                    webView.AddSubview(closeButton);
                    webView.AddSubview(imageView);

                    tap.View.Alpha = 1f;
                });

                UIView.CommitAnimations();
            }
            else
            {
                HelperMethods.SendBasicAlert("Connect to a Network", "Please connect to a network to view this ad");
            }
        }
Example #6
0
        void AdMessages_TouchUpInside(object sender, EventArgs e)
        {
            Ad ad = new Ad();

            if (sender == Ad1MessageButton)
            {
                ad = DataObject.Ads[2];
            }

            if (sender == Ad2MessageButton)
            {
                ad = DataObject.Ads[1];
            }

            if (sender == Ad3MessageButton)
            {
                ad = DataObject.Ads[0];
            }

            var brokerPhoneNumber = ad.BrokerCellPhone;
            //var brokerPhoneNumber = "5024171595";

            var smsTo = NSUrl.FromString("sms:" + brokerPhoneNumber);

            if (UIApplication.SharedApplication.CanOpenUrl(smsTo))
            {
                //Clay Martin 1/1/18: Change app name to BuyPlane
                string textMessageBody = "Inquiry about " + ad.Name + " from GlobalAir.com BuyPlane Magazine";

                Action successCallBack = async() =>
                {
                    //Send Inquiry
                    var response = await AdInquiryResponse.AdInquiry(int.Parse(ad.ID), string.Empty, string.Empty, brokerPhoneNumber, string.Empty
                                                                     , ad.BrokerId, AdInquirySource.Text, textMessageBody);

                    if (response.Status != "Success")
                    {
                        HelperMethods.SendBasicAlert("Oops", "There was a problem sending your email to the aircraft broker. Please try again");
                    }
                };

                //try to send text message in the ap
                HelperMethods.ShowAndSendSMS(this, new string[] { brokerPhoneNumber }, textMessageBody, successCallBack);
            }
            else
            {
                var av = new UIAlertView("Not supported",
                                         "Text messaging is not supported on this device",
                                         null,
                                         "OK",
                                         null);
                av.Show();
            }
        }
Example #7
0
        public override UIView GetViewForHeader(UITableView tableView, nint section)
        {
            var headerWidth     = tableView.Frame.Width;
            var headerHeight    = 25;
            var labelLeftMargin = 20;

            UIView containerView = new UIView(new CoreGraphics.CGRect(0, 0, headerWidth, headerHeight));

            var textColor = UIColor.FromRGB(50, 205, 50);
            var font      = UIFont.BoldSystemFontOfSize(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ?24:16);

            var sectionName = keys[section];

            if (sectionName != _rangeSection)
            {
                UILabel headerLabel = new UILabel(new CoreGraphics.CGRect(labelLeftMargin, 0, headerWidth - labelLeftMargin, headerHeight)); // Set the frame size you need
                headerLabel.TextColor = textColor;                                                                                           // Set your color
                headerLabel.Text      = sectionName;
                headerLabel.Font      = font;
                containerView.AddSubview(headerLabel);
            }
            else
            {
                UIButton button = new UIButton(new CoreGraphics.CGRect(labelLeftMargin, 0, headerWidth - labelLeftMargin, headerHeight));
                button.SetTitle(sectionName, UIControlState.Normal);
                button.SetTitleColor(textColor, UIControlState.Normal);
                button.Font = font;
                button.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                //button.SetImage(UIImage.FromBundle("map.png"), UIControlState.Normal);

                button.TouchUpInside += (sender, e) =>
                {
                    if (Reachability.IsHostReachable(Settings._baseDomain))
                    {
                        //var specSection = SpecDictionary.Where(row => row

                        MapViewController mapViewController = (MapViewController)Owner.Storyboard.InstantiateViewController("MapViewController");
                        mapViewController.SpecFieldList = SpecDictionary[_rangeSection];
                        Owner.ShowDetailViewController(mapViewController, this);
                    }

                    else
                    {
                        HelperMethods.SendBasicAlert("Connect to a Network", Settings._networkProblemMessage);
                    }
                };

                containerView.AddSubview(button);
            }


            return(containerView);
        }
Example #8
0
        public static bool ValidateRequiredRegistrationFieldExceptClassifications(string reEnterEmail, string reEnterPassword)
        {
            //Ensure required fields are input
            if (Settings.Email == null || Settings.Email == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input a valid email address");
                return(false);
            }
            if (Settings.Password == null || Settings.Password == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input a valid password");
                return(false);
            }

            if (Settings.Email != reEnterEmail)
            {
                HelperMethods.SendBasicAlert("Validation", "Email doesn't match");
                return(false);
            }

            if (Settings.Password != reEnterPassword)
            {
                HelperMethods.SendBasicAlert("Validation", "Password doesn't match");
                return(false);
            }


            if (Settings.FirstName == null || Settings.FirstName == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input your first name");
                return(false);
            }
            if (Settings.LastName == null || Settings.LastName == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input your last name");
                return(false);
            }
            if (Settings.Phone == null || Settings.Phone == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input your phone number");
                return(false);
            }

            if (Settings.LocationPickerSelectedId == 0)
            {
                HelperMethods.SendBasicAlert("Validation", "Please select your location");
                return(false);
            }

            return(true);
        }
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, Foundation.NSIndexPath indexPath)
        {
            switch (editingStyle)
            {
            case UITableViewCellEditingStyle.Delete:

                //set isliked to false on root ad
                Ad item = Owner.FavoritesAdList[indexPath.Row];

                item.IsLiked = false;
                // remove the item from the underlying data source
                Owner.FavoritesAdList.RemoveAt(indexPath.Row);
                // delete the row from the table
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);


                //attempt to change like status in the database
                Task.Run(async() =>
                {
                    AdLikeResponse adLikeResponse = await new AdLikeResponse().RecordAdLike(int.Parse(item.ID), false);

                    if (adLikeResponse.Status != "Success")
                    {
                        InvokeOnMainThread(() =>
                        {
                            HelperMethods.SendBasicAlert("Oops", adLikeResponse.ResponseMsg);
                            item.IsLiked = true;
                            // remove the item from the underlying data source
                            Owner.FavoritesAdList.Insert(indexPath.Row, item);
                            // delete the row from the table
                            tableView.InsertRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                        });
                    }
                    else
                    {
                        var allAdsByClassification = (await Ad.GetAdsByClassificationAsync(item.Classification)).ToList();
                        var thisItem     = allAdsByClassification.FirstOrDefault(row => row.ID == item.ID);
                        thisItem.IsLiked = false;
                        Ad.SaveAdsByClassification(allAdsByClassification, item.Classification);
                    }
                });

                break;

            case UITableViewCellEditingStyle.None:
                Console.WriteLine("CommitEditingStyle:None called");
                break;
            }
        }
        void PhoneTextField_EditingDidEnd(object sender, EventArgs e)
        {
            var phoneNumber = PhoneTextField.Text;

            //validate phone numberd
            if (HelperMethods.IsValidPhoneNumber(phoneNumber))
            {
                Settings.Phone = phoneNumber;
            }
            else
            {
                HelperMethods.SendBasicAlert("Validation", "Please input a valid mobile phone number");
                PhoneTextField.Text = string.Empty;
            }
        }
        void PasswordTextField_EditingDidEnd(object sender, EventArgs e)
        {
            var password = PasswordTextField.Text;

            //validate password
            if (HelperMethods.IsValidPassword(password))
            {
                Settings.Password = password;
            }
            else
            {
                HelperMethods.SendBasicAlert("Validation", "Please input a valid email password (one number, one alpha character, and minimum length of 6)");
                PasswordTextField.Text = string.Empty;
            }
        }
        void EmailTextField_EditingDidEnd(object sender, EventArgs e)
        {
            var emailAddress = EmailTextField.Text;

            //validate email address
            if (HelperMethods.IsValidEmail(emailAddress))
            {
                Settings.Email = emailAddress;
            }
            else
            {
                HelperMethods.SendBasicAlert("Validation", "Please input a valid email address");
                EmailTextField.Text = string.Empty;
            }
        }
Example #13
0
        async void SubmitButton_TouchUpInside(object sender, EventArgs e)
        {
            //if (Settings.Password != oldPassEdt.Text)
            //{
            //	HelperMethods.SendBasicAlert("Validation", "Invalid Password");
            //	return;
            //}


            if (confirmpassEdt.Text != nPassEdt.Text)
            {
                HelperMethods.SendBasicAlert("Validation", "Password doesn't match");
                return;
            }



            try {
                //AuthResponse response1 = await AuthResponse.GetAuthResponseAsync(0, Settings.Username, Settings.Password);

                APIManager manager = new APIManager();

                var response = await manager.ChangePassword(Settings.AppID, Settings.Username, Settings.AuthToken, oldPassEdt.Text, nPassEdt.Text);

                if (response == null)
                {
                    HelperMethods.SendBasicAlert("Change Password", "Failed");
                }
                else
                {
                    if (response.Status.Equals("Success"))
                    {
                        Settings.Password = nPassEdt.Text;
                        HelperMethods.SendBasicAlert("Change Password", "Done");
                    }
                    else
                    {
                        HelperMethods.SendBasicAlert("Change Password", response.ResponseMsg);
                    }
                }
            }
            catch (Exception exc) {
                HelperMethods.SendBasicAlert("Change Password", "Failed");
            }
        }
        void HoursTextField_EditingDidEnd(object sender, EventArgs e)
        {
            int  hours     = 0;
            bool isInteger = int.TryParse(HoursTextField.Text, out hours);

            if (isInteger)
            {
                Settings.Hours = hours;
            }
            else
            {
                if (HoursTextField.Text != string.Empty)
                {
                    HoursTextField.Text = string.Empty;
                    HelperMethods.SendBasicAlert("Validation", "Must input an integer (i.e. 115)");
                }
            }
        }
        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.");
            }
        }
        public override UIViewController GetNextViewController(UIPageViewController pageViewController, UIViewController referenceViewController)
        {
            int index = IndexOf((IAdLayoutInterface)referenceViewController);

            //Handle first page flip after clicking the ad name button in a MagazinePage
            if (index == -1)
            {
                index = 0;
            }

            if (index == magPageList.Count - 1)
            {
                HelperMethods.SendBasicAlert("Magazine", "We are sorry but currently there are no more aircraft to view in this magazine");
                return(null);
            }

            //referenceViewController.Dispose();

            return(GetViewController(index + 1, false));
        }
        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 ViewDidAppear(bool animated)
 {
     base.ViewDidAppear(animated);
     if (CLLocationManager.Status == CLAuthorizationStatus.Denied)
     {
         if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
         {
             var alert = UIAlertController.Create("Unable to determine location", "Would you like to change your location permissions?", UIAlertControllerStyle.Alert);
             alert.AddAction(UIAlertAction.Create("Yes", UIAlertActionStyle.Default, (UIAlertAction obj) =>
             {
                 var settingsString = UIApplication.OpenSettingsUrlString;
                 var url            = new NSUrl(settingsString);
                 UIApplication.SharedApplication.OpenUrl(url);
             }));
             alert.AddAction(UIAlertAction.Create("No Thanks", UIAlertActionStyle.Cancel, null));
             this.PresentViewController(alert, true, null);
         }
         else
         {
             HelperMethods.SendBasicAlert("Unable to determine location", "To change this, go to Settings and change location permissions for this app.");
         }
     }
 }
Example #19
0
        //public override UIView GetViewForHeader(UITableView tableView, int section)
        //{

        //}

        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            //var cell = tableView.CellAt(indexPath);

            var section = keys[indexPath.Section];

            if (section == _rangeSection)
            {
                if (Reachability.IsHostReachable(Settings._baseDomain))
                {
                    var specSection = SpecDictionary[keys[indexPath.Section]];

                    MapViewController mapViewController = (MapViewController)Owner.Storyboard.InstantiateViewController("MapViewController");
                    mapViewController.SpecFieldList = specSection;
                    Owner.ShowDetailViewController(mapViewController, this);
                }

                else
                {
                    HelperMethods.SendBasicAlert("Connect to a Network", Settings._networkProblemMessage);
                }
            }
            tableView.DeselectRow(indexPath, true);
        }
        async void SubmitButton_TouchUpInside(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(EmailAddressTextField.Text) && !string.IsNullOrEmpty(CommentsTextView.Text) && !string.IsNullOrEmpty(NameTextField.Text) && !string.IsNullOrEmpty(PhoneTextField.Text))
            {
                EmailAddressTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                EmailAddressTextField.Layer.BorderWidth = 0f;

                CommentsTextView.Layer.BorderColor = UIColor.Clear.CGColor;
                CommentsTextView.Layer.BorderWidth = 0f;

                NameTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                NameTextField.Layer.BorderWidth = 0f;


                bool isChecked = CheckButton.Selected;

                //Send Inquiry
                //Clay Martin 1/1/18: Change app name to BuyPlane
                var response = await AdInquiryResponse.AdInquiry(int.Parse(AdProperty.ID), NameTextField.Text, EmailAddressTextField.Text, PhoneTextField.Text, CommentsTextView.Text
                                                                 , AdProperty.BrokerId, AdInquirySource.Email, "Inquiry about " + AdProperty.Name + " from GlobalAir.com BuyPlane Magazine", isChecked);

                //AdInquiryResponse response = new AdInquiryResponse();
                //response.Status = "Success";

                if (response.Status != "Success")
                {
                    //var alert = UIAlertController.Create("Oops", "There was a problem sending your email to the aircraft broker. Please try again", UIAlertControllerStyle.Alert);

                    HelperMethods.SendBasicAlert("Oops", "There was a problem sending your email to the aircraft broker. Please try again");

                    //alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null));
                    ////alert.AddAction(UIAlertAction.Create("Snooze", UIAlertActionStyle.Default, action => Snooze()));
                    //if (alert.PopoverPresentationController != null)
                    //{
                    //	alert.PopoverPresentationController.SourceView = this.View;
                    //	alert.PopoverPresentationController.PermittedArrowDirections = UIPopoverArrowDirection.Up;
                    //}
                    //PresentViewController(alert, animated: true, completionHandler: null);
                }
                else
                {
                    var alert = UIAlertController.Create("Congratulations!", "Email sent successfully.", UIAlertControllerStyle.Alert);

                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) =>
                    {
                        this.PresentingViewController.DismissViewController(true, null);
                    }));

                    PresentViewController(alert, animated: true, completionHandler: () =>
                    {
                    });
                }
            }
            else
            {
                //Update UI to reflect invalid username or password

                if (string.IsNullOrEmpty(EmailAddressTextField.Text))
                {
                    EmailAddressTextField.Layer.BorderColor = UIColor.Red.CGColor;
                    EmailAddressTextField.Layer.BorderWidth = 1f;
                }
                else
                {
                    EmailAddressTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                    EmailAddressTextField.Layer.BorderWidth = 0f;
                }

                if (string.IsNullOrEmpty(PhoneTextField.Text))
                {
                    PhoneTextField.Layer.BorderColor = UIColor.Red.CGColor;
                    PhoneTextField.Layer.BorderWidth = 1f;
                }
                else
                {
                    PhoneTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                    PhoneTextField.Layer.BorderWidth = 0f;
                }

                if (string.IsNullOrEmpty(CommentsTextView.Text))
                {
                    CommentsTextView.Layer.BorderColor = UIColor.Red.CGColor;
                    CommentsTextView.Layer.BorderWidth = 1f;
                }
                else
                {
                    CommentsTextView.Layer.BorderColor = UIColor.Clear.CGColor;
                    CommentsTextView.Layer.BorderWidth = 0f;
                }

                if (string.IsNullOrEmpty(NameTextField.Text))
                {
                    NameTextField.Layer.BorderColor = UIColor.Red.CGColor;
                    NameTextField.Layer.BorderWidth = 1f;
                }
                else
                {
                    NameTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                    NameTextField.Layer.BorderWidth = 0f;
                }
            }
        }
Example #21
0
        void AdSortButton_TouchUpInside(object sender, EventArgs e)
        {
            if (!Settings.IsRegistered)
            {
                if (sender == Ad1NameButton || sender == Ad2NameButton || sender == Ad3NameButton || sender == Ad4NameButton)
                {
                    HelperMethods.MakeModelRegistrationRequiredPrompt(this, sender as UIButton);
                }
                if (sender == Ad1BrokerButton || sender == Ad2BrokerButton || sender == Ad3BrokerButton || sender == Ad4BrokerButton)
                {
                    HelperMethods.SellerRegistrationRequiredPrompt(this, sender as UIButton);
                }
                return;
            }

            Ad   ad           = new Ad();
            bool isAdNameSort = false;

            if (sender == Ad1NameButton)
            {
                ad           = DataObject.Ads[0];
                isAdNameSort = true;
            }
            if (sender == Ad2NameButton)
            {
                ad           = DataObject.Ads[1];
                isAdNameSort = true;
            }
            if (sender == Ad3NameButton)
            {
                ad           = DataObject.Ads[2];
                isAdNameSort = true;
            }
            if (sender == Ad4NameButton)
            {
                ad           = DataObject.Ads[3];
                isAdNameSort = true;
            }


            if (sender == Ad1BrokerButton)
            {
                ad           = DataObject.Ads[0];
                isAdNameSort = false;
            }
            if (sender == Ad2BrokerButton)
            {
                ad           = DataObject.Ads[1];
                isAdNameSort = false;
            }
            if (sender == Ad3BrokerButton)
            {
                ad           = DataObject.Ads[2];
                isAdNameSort = false;
            }
            if (sender == Ad4BrokerButton)
            {
                ad           = DataObject.Ads[3];
                isAdNameSort = false;
            }



            LoadingOverlay loadingIndicator = new LoadingOverlay(this.View.Frame, isAdNameSort ? "Loading Aircraft by Selected Type" : "Loading Aircraft by Selected Broker");

            this.View.AddSubview(loadingIndicator);

            var pageViewController         = this.ParentViewController as UIPageViewController;
            var magFlipBoardViewController = pageViewController.ParentViewController as MagazineFlipBoardViewController;

            var       modelController = magFlipBoardViewController.ModelController;
            List <Ad> adList          = new List <Ad>();

            Task.Run(async() =>
            {
                adList = (await Ad.GetAdsByClassificationAsync(DataObject.SelectedClassification)).ToList();

                //get ads with this name and move them to the from of the list
                List <Ad> similarAdList = new List <Ad>();

                if (isAdNameSort)
                {
                    similarAdList = adList.Where(row => row.Name == ad.Name).ToList();
                }
                else
                {
                    similarAdList = adList.Where(row => row.BrokerName == ad.BrokerName).ToList();
                }


                for (int i = 0; i < similarAdList.Count(); i++)
                {
                    adList.Remove(similarAdList[i]);
                    adList.Insert(0, similarAdList[i]);
                }

                InvokeOnMainThread(() =>
                {
                    modelController.LoadModalController(adList, DataObject.SelectedClassification);
                    loadingIndicator.Hide();
                    var startingViewController = modelController.GetViewController(0, false);
                    var viewControllers        = new UIViewController[] { startingViewController };
                    pageViewController.SetViewControllers(viewControllers, UIPageViewControllerNavigationDirection.Forward, true, null);

                    HelperMethods.SendBasicAlert("", "Aircraft arranged by " + (isAdNameSort? ad.Name:ad.BrokerName));
                });
            });
        }
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.CellAt(indexPath);


            if (Reachability.IsHostReachable(Settings._baseDomain))
            {
                var ad = Owner.FavoritesAdList[indexPath.Row];
                var statusBarHeight = UIApplication.SharedApplication.StatusBarFrame.Height;
                var tabBarHeight    = Owner.TabBarController.TabBar.Bounds.Height;

                var frame   = new CGRect(0, statusBarHeight, Owner.View.Bounds.Width, Owner.View.Bounds.Height - (statusBarHeight + tabBarHeight));
                var webView = new UIWebView(frame);

                LoadingOverlay loadingOverlay = new LoadingOverlay(Owner.View.Frame);

                webView.LoadFinished += (sender, e) =>
                {
                    loadingOverlay.Hide();
                };


                var url = ad.AircraftForSaleURL;
                webView.LoadRequest(new NSUrlRequest(new NSUrl(url)));

                UIView.BeginAnimations("fadeflag");
                UIView.Animate(1, () =>
                {
                    cell.Alpha = .5f;
                }, () =>
                {
                    Owner.View.AddSubview(webView);
                    Owner.View.AddSubview(loadingOverlay);

                    UIButton closeButton = new UIButton(new CGRect(Owner.View.Bounds.Width - 50, 0, 50, 50));
                    closeButton.SetImage(UIImage.FromBundle("close"), UIControlState.Normal);
                    closeButton.BackgroundColor = UIColor.Black;
                    closeButton.TouchUpInside  += (sender, e) =>
                    {
                        try
                        {
                            webView.RemoveFromSuperview();
                            closeButton.RemoveFromSuperview();
                        }
                        finally
                        {
                            webView.Dispose();
                        }
                    };
                    //Owner.View.AddSubview(closeButton);
                    webView.AddSubview(closeButton);

                    cell.Alpha = 1f;
                });

                UIView.CommitAnimations();
                //}
            }
            else
            {
                HelperMethods.SendBasicAlert("Connect to a Network", "Please connect to a network to view this ad");
            }



            tableView.DeselectRow(indexPath, true);
        }
        partial void OnClick(UIButton sender)
        {
            EmailTextField.ResignFirstResponder();
            PasswordTextField.ResignFirstResponder();
            FirstNameTextField.ResignFirstResponder();
            LastNameTextField.ResignFirstResponder();

            //Ensure required fields are input
            if (Settings.Email == null || Settings.Email == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input a valid email address");
                return;
            }
            if (Settings.Password == null || Settings.Password == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input a valid password");
                return;
            }

            if (Settings.Email != ReEmailTextField.Text)
            {
                HelperMethods.SendBasicAlert("Validation", "Email doesn't match");
                return;
            }

            if (Settings.Password != RePasswordTextField.Text)
            {
                HelperMethods.SendBasicAlert("Validation", "Password doesn't match");
                return;
            }


            if (Settings.FirstName == null || Settings.FirstName == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input your first name");
                return;
            }
            if (Settings.LastName == null || Settings.LastName == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input your last name");
                return;
            }
            if (Settings.Phone == null || Settings.Phone == string.Empty)
            {
                HelperMethods.SendBasicAlert("Validation", "Please input your phone number");
                return;
            }

            if (Settings.LocationPickerSelectedId == 0)
            {
                HelperMethods.SendBasicAlert("Validation", "Please select your location");
                return;
            }

            RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController;
            var stepThree = registrationVC.Steps[2];

            registrationVC._pageViewController.SetViewControllers(new[] { stepThree as UIViewController }, UIPageViewControllerNavigationDirection.Forward, true, (finished) =>
            {
                if (finished)
                {
                    //finalStep.StepActivated(this, new MultiStepProcessStepEventArgs());
                }
            });
            //throw new NotImplementedException();
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            base.ViewDidAppear(animated);

// This screen name value will remain set on the tracker and sent with
// hits until it is set to a new value or to null.
            Gai.SharedInstance.DefaultTracker.Set(GaiConstants.ScreenName, "Page View");

            Gai.SharedInstance.DefaultTracker.Send(DictionaryBuilder.CreateAppView().Build());

            StepActivated?.Invoke(this, new MultiStepProcessStepEventArgs {
                Index = StepIndex
            });


            bool needsToReturnToPreviousStep = false;
            //Ensure required fields are input
            string validationMessage = string.Empty;

            if (Settings.Email == null || Settings.Email == string.Empty)
            {
                validationMessage           = "Please input a valid email address";
                needsToReturnToPreviousStep = true;
            }
            if (Settings.Password == null || Settings.Password == string.Empty)
            {
                validationMessage           = "Please input a valid password";
                needsToReturnToPreviousStep = true;
            }
            if (Settings.FirstName == null || Settings.FirstName == string.Empty)
            {
                validationMessage           = "Please input your first name";
                needsToReturnToPreviousStep = true;
            }
            if (Settings.LastName == null || Settings.LastName == string.Empty)
            {
                validationMessage           = "Please input your last name";
                needsToReturnToPreviousStep = true;
            }
            if (Settings.Phone == null || Settings.Phone == string.Empty)
            {
                validationMessage           = "Please input your cell phone number";
                needsToReturnToPreviousStep = true;
            }
            if (Settings.LocationPickerSelectedId == 0)
            {
                validationMessage           = "Please select your location";
                needsToReturnToPreviousStep = true;
            }
            if (needsToReturnToPreviousStep)
            {
                HelperMethods.SendBasicAlert("Validation", validationMessage);
                RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController;
                var secondStep = registrationVC.Steps[1];
                InvokeOnMainThread(() =>
                {
                    registrationVC._pageViewController.SetViewControllers(new[] { secondStep as UIViewController }, UIPageViewControllerNavigationDirection.Reverse, true, (finished) =>
                    {
                        if (finished)
                        {
                            //finalStep.StepActivated(this, new MultiStepProcessStepEventArgs());
                        }
                    });
                });
            }


            //Register events
            PilotSwitch.ValueChanged += PilotSwitch_ValueChanged;
            NextButton.TouchUpInside += NextButton_TouchUpInside;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Next toolbar button item
            var nextBarButtonItem = new UIBarButtonItem("Next", UIBarButtonItemStyle.Plain, (sender, args) =>
            {
                if (Settings.AnyClassificationChosen())
                {
                    var testStoryBoard    = UIStoryboard.FromName("Registration_New", NSBundle.MainBundle);
                    var regViewController = testStoryBoard.InstantiateViewController("RegistrationStepTwo");
                    this.ShowViewController(regViewController, this);
                }
                else
                {
                    //Display message here
                    HelperMethods.SendBasicAlert("Alert", "Please select at least one aircraft classification");
                }
            });
            UIFont font;
            int    headerHight;
            var    horizontalClass = this.TraitCollection.HorizontalSizeClass;

            switch (horizontalClass)
            {
            case UIUserInterfaceSizeClass.Compact:
            {
                font        = UIFont.BoldSystemFontOfSize(13);
                headerHight = 25;
                break;
            }

            case UIUserInterfaceSizeClass.Regular:
            {
                font        = UIFont.BoldSystemFontOfSize(20);
                headerHight = 50;
                break;
            }

            default:
            {
                font        = UIFont.BoldSystemFontOfSize(20);
                headerHight = 50;
                break;
            }
            }

            UITextAttributes icoFontAttribute = new UITextAttributes();

            icoFontAttribute.Font      = font;
            icoFontAttribute.TextColor = UIColor.White;

            nextBarButtonItem.SetTitleTextAttributes(icoFontAttribute, UIControlState.Normal);

            NavigationItem.SetRightBarButtonItem(nextBarButtonItem, true);

            //Cancel toolbar button item
            var cancelBarButtonItem = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Plain, (sender, args) =>
            {
                DismissViewController(true, null);
            });

            cancelBarButtonItem.SetTitleTextAttributes(icoFontAttribute, UIControlState.Normal);

            NavigationItem.SetLeftBarButtonItem(cancelBarButtonItem, true);

            CollectionView.RegisterClassForCell(typeof(ClassificationCell), classificationCellID);

            CollectionView.BackgroundColor         = UIColor.White;
            CollectionView.AllowsMultipleSelection = true;


            var headerLabel = new UILabel()
            {
                Font            = font,
                TextAlignment   = UITextAlignment.Center,
                TextColor       = UIColor.White,
                BackgroundColor = UIColor.Gray,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            headerLabel.Text = "Select Your Favorite Classifications";
            this.View.Add(headerLabel);

            headerLabel.TopAnchor.ConstraintEqualTo(this.View.SafeAreaLayoutGuide.TopAnchor).Active     = true;
            headerLabel.LeftAnchor.ConstraintEqualTo(this.View.SafeAreaLayoutGuide.LeftAnchor).Active   = true;
            headerLabel.RightAnchor.ConstraintEqualTo(this.View.SafeAreaLayoutGuide.RightAnchor).Active = true;
            headerLabel.HeightAnchor.ConstraintEqualTo((System.nfloat)headerHight).Active = true;
            headerLabel.AdjustsFontSizeToFitWidth = true;
        }
Example #26
0
        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;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (this.TabBarController != null)
            {
                this.TabBarController.TabBar.Hidden = true;
            }



            //Ensure database refresh
            //this.NavigationItem.SetRightBarButtonItem(
            var refreshButton = new UIBarButtonItem(UIBarButtonSystemItem.Refresh, async(sender, args) =>
            {
                if (Reachability.IsHostReachable(Settings._baseDomain))
                {
                    LoadingOverlay loadingIndicator = new LoadingOverlay(this.View.Frame);
                    this.View.AddSubview(loadingIndicator);
                    // button was clicked
                    List <Ad> adList = new List <Ad>();


                    Ad.DeleteAdsByClassification(SelectedClassification);
                    adList = (await Ad.GetAdsByClassificationAsync(SelectedClassification)).ToList();


                    this.ModelController.LoadModalController(adList, SelectedClassification);

                    var firstViewController = ModelController.GetViewController(0, false);
                    var viewControllerArray = new UIViewController[] { firstViewController };
                    PageViewController.SetViewControllers(viewControllerArray, UIPageViewControllerNavigationDirection.Forward, true, null);

                    loadingIndicator.Hide();
                }
                else
                {
                    HelperMethods.SendBasicAlert("Connect to a Network", "Please connect to a network to refresh these ads");
                }
            });
            //, true);

            //start implementing search feature
            var searchButton = new UIBarButtonItem(UIBarButtonSystemItem.Search, (sender, e) =>
            {
                var errorMessage = "";
                if (ModelController != null && ModelController.adList != null && ModelController.adList.Count > 0)
                {
                    var adList = ModelController.adList;

                    SearchResultsViewController searchResultsViewController = new SearchResultsViewController();

                    searchResultsViewController.SearchResultsAdList = adList;
                    searchResultsViewController.Classification      = SelectedClassification;
                    searchResultsViewController.AdSelectedAction    = delegate
                    {
                        var pageViewController         = this.PageViewController;
                        var magFlipBoardViewController = this;



                        Ad ad = new Ad();

                        ad = searchResultsViewController.SelectedAd;

                        LoadingOverlay loadingIndicator = new LoadingOverlay(this.View.Frame, "Loading Aircraft");
                        this.View.AddSubview(loadingIndicator);

                        var modelController     = this.ModelController;
                        List <Ad> searchAddList = new List <Ad>();

                        Task.Run(async() =>
                        {
                            searchAddList = (await Ad.GetAdsByClassificationAsync(ad.Classification)).ToList();

                            //get ads with this name and move them to the from of the liste
                            List <Ad> similarAdList = new List <Ad>();

                            similarAdList = searchAddList.Where(row => row.Name == ad.Name).OrderBy(r => r.IsFeatured).ToList();

                            //similarAdList.Remove(ad);


                            for (int i = 0; i < similarAdList.Count(); i++)
                            {
                                searchAddList.Remove(similarAdList[i]);
                                searchAddList.Insert(0, similarAdList[i]);
                            }

                            //similarAdList.Remove(ad);
                            //searchAddList.Insert(0, ad);


                            var index            = searchAddList.FindIndex(x => x.ID == ad.ID);
                            var item             = searchAddList[index];
                            searchAddList[index] = searchAddList[0];
                            searchAddList[0]     = item;

                            InvokeOnMainThread(() =>
                            {
                                modelController.LoadModalController(searchAddList, ad.Classification);
                                loadingIndicator.Hide();
                                var initialViewController = modelController.GetViewController(0, false);
                                var searchViewControllers = new UIViewController[] { initialViewController };
                                pageViewController.SetViewControllers(searchViewControllers, UIPageViewControllerNavigationDirection.Forward, true, null);

                                HelperMethods.SendBasicAlert("", "Aircraft arranged based on search selection");
                            });
                        });
                    };
                    this.PresentViewController(searchResultsViewController, true, null);
                }
                else
                {
                    errorMessage = "Oops... There was a problem. Aircraft ads are not yet loaded.";
                }
                if (errorMessage != string.Empty)
                {
                    HelperMethods.SendBasicAlert("Alert", errorMessage);
                }
            });


            List <UIBarButtonItem> navButtonList = new List <UIBarButtonItem>();

            navButtonList.Add(searchButton);
            navButtonList.Add(refreshButton);


            this.NavigationItem.SetRightBarButtonItems(navButtonList.ToArray(), true);

            ModelController = new ModelController(SelectedClassification);

            // Configure the page view controller and add it as a child view controller.
            //UIPageViewControllerSpineLocation.Min
            PageViewController = new UIPageViewController(UIPageViewControllerTransitionStyle.PageCurl, UIPageViewControllerNavigationOrientation.Horizontal, UIPageViewControllerSpineLocation.Min);
            PageViewController.WeakDelegate = this;

            var startingViewController = ModelController.GetViewController(0, false);
            var viewControllers        = new UIViewController[] { startingViewController };

            PageViewController.SetViewControllers(viewControllers, UIPageViewControllerNavigationDirection.Forward, false, null);

            PageViewController.WeakDataSource = ModelController;

            AddChildViewController(PageViewController);
            View.AddSubview(PageViewController.View);

            UINavigationController magazineNavigationController = (UINavigationController)Storyboard.InstantiateViewController("MagazineNavigationViewController");
            float heightTopNavBar      = (float)magazineNavigationController.NavigationBar.Frame.Size.Height;
            float statusBarHeight      = (float)UIApplication.SharedApplication.StatusBarFrame.Height;
            float totalStatusBarHeight = heightTopNavBar + statusBarHeight;
            var   pageViewRect         = new CGRect(0, totalStatusBarHeight, View.Bounds.Width, View.Bounds.Height - totalStatusBarHeight);

            PageViewController.View.Frame = pageViewRect;

            PageViewController.DidMoveToParentViewController(this);

            // Add the page view controller's gesture recognizers to the book view controller's view so that the gestures are started more easily.
            //View.GestureRecognizers = PageViewController.GestureRecognizers;

            if (NavigateDirectlyToAdId != null && NavigateDirectlyToAdId != string.Empty)
            {
                LoadingIndicator = new LoadingOverlay(this.View.Frame, "Loading Aircraft", false);
                this.View.AddSubview(LoadingIndicator);
            }
        }
Example #28
0
        async partial void submitAction(Foundation.NSObject sender)
        {
            if (!string.IsNullOrEmpty(addressEdt.Text) && !string.IsNullOrEmpty(commentsEdt.Text) && !string.IsNullOrEmpty(nameEdt.Text) && !string.IsNullOrEmpty(phnoEdt.Text))
            {
                addressEdt.Layer.BorderColor = UIColor.Clear.CGColor;
                addressEdt.Layer.BorderWidth = 0f;

                commentsEdt.Layer.BorderColor = UIColor.Clear.CGColor;
                commentsEdt.Layer.BorderWidth = 0f;

                nameEdt.Layer.BorderColor = UIColor.Clear.CGColor;
                nameEdt.Layer.BorderWidth = 0f;


                //this.DismissViewController(true, null);

                ////Send Inquiry
                var response = await AdInquiryResponse.AdInquiry(0, nameEdt.Text, addressEdt.Text, string.Empty, commentsEdt.Text
                                                                 , 0, AdInquirySource.Email, "");

                if (response == null)
                {
                    //var alert = UIAlertController.Create("Oops", "There was a problem sending your email to the aircraft broker. Please try again", UIAlertControllerStyle.Alert);

                    HelperMethods.SendBasicAlert("Oops", "There was a problem sending your email. Please try again");
                }
                else
                {
                    var alert = UIAlertController.Create("Congratulations!", "Email sent successfully.", UIAlertControllerStyle.Alert);

                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) =>
                    {
                        if (!isModal)
                        {
                            MainTabBarController controller = this.ParentViewController as MainTabBarController;
                            //Navigate to the main magazine tab
                            controller.SelectedIndex = 0;
                        }
                    }));

                    PresentViewController(alert, animated: true, completionHandler: () =>
                    {
                    });
                }
            }
            else
            {
                //Update UI to reflect invalid username or password

                if (string.IsNullOrEmpty(addressEdt.Text))
                {
                    //UIView.Animate(1, () =>
                    //{
                    //    addressEdt.Layer.BorderColor = UIColor.Red.CGColor;
                    //    addressEdt.Layer.BorderWidth = 4f;
                    //    View.LayoutIfNeeded();
                    //}, () => {

                    //    UIView.Animate(1, () =>
                    //    {
                    //        addressEdt.Layer.BorderColor = UIColor.Red.CGColor;
                    //        addressEdt.Layer.BorderWidth = 2f;
                    //        View.LayoutIfNeeded();
                    //    });
                    //});
                    AnimateValidationBorder(addressEdt);
                }
                else
                {
                    addressEdt.Layer.BorderColor = UIColor.Clear.CGColor;
                    addressEdt.Layer.BorderWidth = 0f;
                }

                if (string.IsNullOrEmpty(phnoEdt.Text))
                {
                    //phnoEdt.Layer.BorderColor = UIColor.Red.CGColor;
                    //phnoEdt.Layer.BorderWidth = 1f;
                    AnimateValidationBorder(phnoEdt);
                }
                else
                {
                    phnoEdt.Layer.BorderColor = UIColor.Clear.CGColor;
                    phnoEdt.Layer.BorderWidth = 0f;
                }

                if (string.IsNullOrEmpty(commentsEdt.Text))
                {
                    //commentsEdt.Layer.BorderColor = UIColor.Red.CGColor;
                    //commentsEdt.Layer.BorderWidth = 1f;

                    AnimateValidationBorder(commentsEdt);
                }
                else
                {
                    commentsEdt.Layer.BorderColor = UIColor.Clear.CGColor;
                    commentsEdt.Layer.BorderWidth = 0f;
                }

                if (string.IsNullOrEmpty(nameEdt.Text))
                {
                    //nameEdt.Layer.BorderColor = UIColor.Red.CGColor;
                    //nameEdt.Layer.BorderWidth = 1f;
                    AnimateValidationBorder(nameEdt);
                }
                else
                {
                    nameEdt.Layer.BorderColor = UIColor.Clear.CGColor;
                    nameEdt.Layer.BorderWidth = 0f;
                }
            }
        }
        async void SubmitButton_TouchUpInside(object sender, EventArgs e)
        {
            UsernameTextField.Enabled = false;
            PasswordTextField.Enabled = false;

            string username = UsernameTextField.Text;
            string password = PasswordTextField.Text;



            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                if (!HelperMethods.IsValidPassword(password))
                {
                    HelperMethods.SendBasicAlert("Validation", "Passwords should contain letters and numbers and be at least 6 characters.");
                    PasswordTextField.Layer.BorderColor = UIColor.Red.CGColor;
                    PasswordTextField.Layer.BorderWidth = 1f;
                    UsernameTextField.Enabled           = true;
                    PasswordTextField.Enabled           = true;
                    return;
                }
                //Save username/password to settings

                Settings.Username = username;
                Settings.Password = password;



                LoadingOverlay loadingIndicator = new LoadingOverlay(this.View.Frame, "Loading ...");
                this.View.AddSubview(loadingIndicator);

                //AuthResponse

                BlobCache.LocalMachine.InvalidateObject <AuthResponse>(AuthResponse.getAuthResponse);

                AuthResponse response = await AuthResponse.GetAuthResponseAsync(0, Settings.Username, Settings.Password);

                Settings.AppID     = response.AppId;
                Settings.AuthToken = response.AuthToken;

                APIManager manager = new APIManager();

                {
                    //LoginResponse authResponse = await manager.loginUser(Settings.AppID, Settings.Username, Settings.Password, Settings.AuthToken);
                    LoginResponse authResponse = await manager.loginUser(Settings.AppID, Settings.Username, Settings.Password, Settings.AuthToken);

                    if (authResponse.AuthToken != null)
                    {
                        Settings.AppID     = authResponse.AppId;
                        Settings.UserID    = authResponse.MagAppUserId;
                        Settings.AuthToken = authResponse.AuthToken;
                    }
                    else
                    {
                        loadingIndicator.Hide();
                        String responseMessage = "";
                        if (authResponse.ResponseMsg != null && authResponse.ResponseMsg != string.Empty)
                        {
                            responseMessage = authResponse.ResponseMsg;
                        }
                        else
                        {
                            responseMessage = "Unable to authenticate user.";
                        }

                        if (responseMessage == "Incorrect Password")
                        {
                            MessageViewController messageViewController = (MessageViewController)Storyboard.InstantiateViewController("MessageViewController");
                            this.PresentViewController(messageViewController, true, null);
                        }
                        else
                        {
                            HelperMethods.SendBasicAlert("Login", responseMessage);
                        }
                        UsernameTextField.Enabled = true;
                        PasswordTextField.Enabled = true;
                        return;
                    }


                    try
                    {
                        var responseProfile = await manager.getUserProfile(Settings.AppID, Settings.Username, Settings.AuthToken, Settings.Password);

                        Settings.IsAmphibian    = responseProfile.C1 == 1;
                        Settings.IsCommercial   = responseProfile.C2 == 1;
                        Settings.IsExperimental = responseProfile.C3 == 1;
                        Settings.IsHelicopter   = responseProfile.C4 == 1;
                        Settings.IsJets         = responseProfile.C5 == 1;
                        Settings.IsSingles      = responseProfile.C7 == 1;
                        Settings.IsSingleEngine = responseProfile.C6 == 1;
                        Settings.IsTwinPistons  = responseProfile.C8 == 1;
                        Settings.IsTwinTurbines = responseProfile.C9 == 1;
                        Settings.IsVintage      = responseProfile.C10 == 1;
                        Settings.IsWarbirds     = responseProfile.C11 == 1;
                        Settings.IsLightSport   = responseProfile.C12 == 1;

                        Settings.Email = Settings.Username;

                        Settings.FirstName = responseProfile.FirstName;
                        Settings.LastName  = responseProfile.LastName;
                        Settings.Phone     = responseProfile.CellPhone;

                        Settings.Company                  = responseProfile.Company;
                        Settings.Hours                    = responseProfile.HourPerMonth;
                        Settings.ManufacturerId           = responseProfile.DesignationId;
                        Settings.LocationPickerSelectedId = responseProfile.CountryId;
                        Settings.Phone                    = responseProfile.CellPhone;
                        Settings.DesignationId            = responseProfile.DesignationId;
                        Settings.PurposeId                = responseProfile.FlyingPurposeId;
                        Settings.HomeAirport              = responseProfile.HomeAirport;
                        Settings.Password                 = responseProfile.Password;
                        Settings.PilotStatusId            = responseProfile.PilotStatusId;
                        Settings.PilotTypeId              = responseProfile.PilotTypeId;
                        Settings.PurchaseTimeFrame        = responseProfile.PurchaseTimeFrame;

                        loadingIndicator.Hide();
                        this.PerformSegue("LoadTabBarControllerSeque", this);
                    }
                    catch (Exception exe)
                    {
                        loadingIndicator.Hide();
                        HelperMethods.SendBasicAlert("Login", "Login Failed");
                    }
                }



                PasswordTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                PasswordTextField.Layer.BorderWidth = 0f;

                UsernameTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                UsernameTextField.Layer.BorderWidth = 0f;
            }
            else
            {
                //Update UI to reflect invalid username or password

                if (string.IsNullOrEmpty(username))
                {
                    UsernameTextField.Layer.BorderColor = UIColor.Red.CGColor;
                    UsernameTextField.Layer.BorderWidth = 1f;
                }
                else
                {
                    UsernameTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                    UsernameTextField.Layer.BorderWidth = 0f;
                }

                if (string.IsNullOrEmpty(password))
                {
                    PasswordTextField.Layer.BorderColor = UIColor.Red.CGColor;
                    PasswordTextField.Layer.BorderWidth = 1f;
                }
                else
                {
                    PasswordTextField.Layer.BorderColor = UIColor.Clear.CGColor;
                    PasswordTextField.Layer.BorderWidth = 0f;
                }
            }

            UsernameTextField.Enabled = true;
            PasswordTextField.Enabled = true;
        }