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");
            }
        }
Ejemplo n.º 2
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");
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (Reachability.IsHostReachable(Settings._baseDomain))
            {
                LoadingOverlay loadingOverlay = new LoadingOverlay(View.Frame);
                View.Add(loadingOverlay);
                Task.Run(() =>
                {
                    var image = HelperMethods.FromUrl(Settings.BanManProURL);
                    BeginInvokeOnMainThread(() =>
                    {
                        loadingOverlay.Hide();
                        BanManProImageView.Image = image;
                    });
                });
            }
            else
            {
                BanManProImageView.Image = UIImage.FromBundle("ad_placeholder.jpg");
            }

            tapGesture1 = new UITapGestureRecognizer(TapImageAction1);

            int currentIndex = this.DataObject.MagazinePageIndex;
            int totalPages   = this.DataObject.TotalPages;

            PageIndicator.SetIndicatorState(currentIndex, totalPages);
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 6
0
        public async static void SwapLikeButtonState(UIButton senderButton, Ad ad)
        {
            if (Reachability.IsHostReachable(Settings._baseDomain))
            {
                int adID;
                int.TryParse(ad.ID, out adID);
                if (ad.IsLiked)
                {
                    //attempt to record unlike in the API
                    if (adID != 0)
                    {
                        ad.IsLiked = false;
                        senderButton.SetImage(UIImage.FromBundle("like"), UIControlState.Normal);

                        AdLikeResponse adLikeResponse = await new AdLikeResponse().RecordAdLike(adID, false);

                        if (adLikeResponse.Status != "Success")
                        {
                            if (adLikeResponse.ResponseMsg.Equals("E1000"))
                            {
                                SendBasicAlert("Oops", "Auth token invalid or expired");
                            }

                            ad.IsLiked = true;
                            senderButton.SetImage(UIImage.FromBundle("like_selected"), UIControlState.Normal);
                        }
                    }
                }
                else
                {
                    //attempt to record like in the API

                    if (adID != 0)
                    {
                        ad.IsLiked = true;
                        senderButton.SetImage(UIImage.FromBundle("like_selected"), UIControlState.Normal);

                        AdLikeResponse adLikeResponse = await new AdLikeResponse().RecordAdLike(adID, true);

                        if (adLikeResponse.Status != "Success")
                        {
                            if (adLikeResponse.ResponseMsg.Equals("E1000"))
                            {
                                SendBasicAlert("Oops", "Auth token invalid or expired");
                            }

                            ad.IsLiked = false;
                            senderButton.SetImage(UIImage.FromBundle("like"), UIControlState.Normal);
                        }
                    }
                }
            }
            else
            {
                SendBasicAlert("Connect to a Network", "Please connect to a network to like this ad");
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
        async void TechnicalSpecButton_TouchUpInside(object sender, EventArgs e)
        {
            Ad ad = new Ad();

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



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


            SpecResponse specResponse = new SpecResponse();

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

            if (specification.SpecId != 0)
            {
                var specTableViewController = this.Storyboard.InstantiateViewController("SpecViewController_") as SpecViewController_;

                specTableViewController.Spec = specification;

                this.PresentViewController(specTableViewController, true, null);
            }
            else
            {
                if (!Reachability.IsHostReachable(Settings._baseDomain))
                {
                    var alert = UIAlertController.Create("Connect to a Network", "Please connect to a network to retrieve these aircraft specs", UIAlertControllerStyle.Alert);

                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null));
                    if (alert.PopoverPresentationController != null)
                    {
                        alert.PopoverPresentationController.SourceView = this.View;
                        alert.PopoverPresentationController.PermittedArrowDirections = UIPopoverArrowDirection.Up;
                    }
                    PresentViewController(alert, animated: true, completionHandler: null);
                }
            }
        }
        public async override void Selected(UIPickerView picker, nint row, nint component)
        {
            var selected = Settings.ClassificationList[(int)picker.SelectedRowInComponent(0)];

            //Assign value to registration object
            Settings.ClassificationId = selected.ClassificationId;

            //if class value is selected, show designation)
            if (selected.ClassificationId != 0)
            {
                if (Reachability.IsHostReachable(Settings._baseDomain))
                {
                    var manufactuerResponse = await CMMDResponse.GetCMMDResponseAsync(Settings.ClassificationId, 0);

                    Owner.CMMDResonseProperty             = manufactuerResponse;
                    Owner.ManufacturePickerProperty.Alpha = 1f;
                    Owner.ManufacturePickerProperty.Model = new ManufactureModel(Owner);

                    if (Settings.ManufacturerId != 0)
                    {
                        int manufacturerIndex = manufactuerResponse.MfgLst.IndexOf(manufactuerResponse.MfgLst.FirstOrDefault(r => r.ManufacturerId == Settings.ManufacturerId));
                        Owner.ManufacturePickerProperty.Select(manufacturerIndex, 0, true);
                        Owner.ManufacturePickerProperty.Model.Selected(Owner.ManufacturePickerProperty, manufacturerIndex, 0);
                    }
                }
                else
                {
                    var alert = UIAlertController.Create("Please connect to the internet", "Internet access is required.", UIAlertControllerStyle.Alert);

                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) =>
                    {
                        this.Selected(picker, 0, 0);
                    }));

                    Owner.PresentViewController(alert, animated: true, completionHandler: () =>
                    {
                    });
                }
            }
            else
            {
                Owner.ManufacturePickerProperty.Alpha = 0f;
                Owner.DesigPickerProperty.Alpha       = 0f;
            }
        }
        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.");
            }
        }
Ejemplo n.º 12
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);
        }
        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);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            PageHeaderLabel.BackgroundColor = UIColor.Gray;

            SizeF size = new SizeF(320, UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 600 : 800);

            ProfileScrollView.ContentSize = size;


            MapCCodeList         = new List <Location>();
            LocationList         = new List <Location>();
            provinceList         = new List <Location>();
            stateList            = new List <Location>();
            FilteredLocationList = new List <Location>();
            SelectedMapCCode     = new Location();
            SelectedLocation     = new Location();


            FirstNameTextField.AttributedPlaceholder = new NSAttributedString(
                "FIRST NAME",
                font: FirstNameTextField.Font,
                foregroundColor: UIColor.White
                );

            LastNameTextField.AttributedPlaceholder = new NSAttributedString(

                "LAST NAME",
                font: LastNameTextField.Font,
                foregroundColor: UIColor.White
                );

            MobilePhoneTextField.AttributedPlaceholder = new NSAttributedString(
                "MOBILE PHONE",
                font: MobilePhoneTextField.Font,
                foregroundColor: UIColor.White
                );



            CompanyTextField.AttributedPlaceholder = new NSAttributedString(
                "COMPANY",
                font: CompanyTextField.Font,
                foregroundColor: UIColor.White
                );


            FirstNameTextField.Text   = Settings.FirstName;
            MobilePhoneTextField.Text = Settings.Phone;
            LastNameTextField.Text    = Settings.LastName;
            //Task.Run(async () => {
            //	try
            //	{
            //		AuthResponse response1 = await AuthResponse.GetAuthResponseAsync(Settings.AppID, Settings.Username, Settings.Password);

            //		APIManager manager = new APIManager();

            //		var reponseProfile = await manager.getUserProfile(Settings.AppID, Settings.Username, response1.AuthToken, Settings.Password);


            //		InvokeOnMainThread(() =>
            //				{

            //					//CompanyTextField.Text = reponseProfile.Company;
            //				});

            //	}
            //	catch (Exception e) {

            //	}

            //});

            //ContainerViewWidthConstraint.Constant = View.Bounds.Width - 40;
            ContainerView.BackgroundColor = UIColor.Clear;
            ContainerView.Alpha           = .8f;

            //CGSize contentSize = new CGSize(View.Bounds.Width - 40, ContainerView.Bounds.Height);
            //ProfileScrollView.ContentSize = contentSize;
            //LocationResponseList = new List<LocationResponse>();


            MapCCodePickerView.Model = new MapCCodeModel(this);


            Task.Run(async() =>
            {
                try
                {
                    LocationResponse location = new LocationResponse();
                    if (Reachability.IsHostReachable(Settings._baseDomain))
                    {
                        location = await LocationResponse.GetLocations();
                        if (location.Equals(null))
                        {
                            return;
                        }
                        if (location.Status != "Success")
                        {
                            InvokeOnMainThread(() =>
                            {
                                var alert = UIAlertController.Create("There was a problem loading location data", "Please try again.", UIAlertControllerStyle.Alert);

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

                                PresentViewController(alert, animated: true, completionHandler: () =>
                                {
                                });
                            });
                        }
                        else
                        {
                            //Save to settings file to use object during the rest of the registration process
                            Settings.LocationResponse = location;

                            var distinctMapCodes = location.Locations.Select(row => row.MapCCode).Distinct().ToList();
                            List <Location> filteredLocationListByFirstMapCode = new List <Location>();



                            foreach (var mapCode in distinctMapCodes)
                            {
                                Location loc = location.Locations.FirstOrDefault(row => row.MapCCode == mapCode);

                                if (loc != null)
                                {
                                    if (loc.MapCCode == "WO")
                                    {
                                        Location placeholderLocation     = new Location();
                                        placeholderLocation.LocationId   = loc.LocationId;
                                        placeholderLocation.LocName      = "World";
                                        placeholderLocation.Abbreviation = loc.Abbreviation;
                                        placeholderLocation.MapCCode     = loc.MapCCode;
                                        placeholderLocation.DisplayOrder = loc.DisplayOrder + 1;
                                        filteredLocationListByFirstMapCode.Add(placeholderLocation);
                                    }
                                    else
                                    {
                                        filteredLocationListByFirstMapCode.Add(loc);
                                    }
                                }
                            }
                            MapCCodeList             = filteredLocationListByFirstMapCode.OrderByDescending(row => row.DisplayOrder).ToList();
                            Location sleLocation     = new Location();
                            sleLocation.LocationId   = 0;
                            sleLocation.LocName      = "Select";
                            sleLocation.Abbreviation = "Select";
                            sleLocation.MapCCode     = "SE";
                            sleLocation.DisplayOrder = 0;
                            MapCCodeList.Insert(0, sleLocation);

                            LocationList         = location.Locations.OrderBy(row => row.DisplayOrder).ToList();
                            FilteredLocationList = LocationList;
                            provinceList         = location.ProvinceLst.OrderBy(row => row.DisplayOrder).ToList();
                            stateList            = location.StatesLst.OrderBy(row => row.DisplayOrder).ToList();

                            if (MapCCodeList.Count > 1 && Settings.LocationPickerSelectedId == 0)
                            {
                                //Assign value to registration objec
                                Settings.LocationPickerSelectedId = MapCCodeList[0].LocationId;
                            }

                            InvokeOnMainThread(() =>
                            {
                                MapCCodePickerView.Model = new MapCCodeModel(this);
                                LocationsPicker.Model    = new LocationsModel(this);

                                if (Settings.IsRegistered)
                                {
                                    var previouslSelectedLocation = MapCCodeList.FirstOrDefault(row => row.LocationId == Settings.LocationPickerSelectedId);

                                    if (previouslSelectedLocation != null)
                                    {
                                        int currentIndex = MapCCodeList.IndexOf(MapCCodeList.FirstOrDefault(row => row.LocationId == Settings.LocationPickerSelectedId));;
                                        MapCCodePickerView.Select(currentIndex, 0, true);
                                    }
                                    else
                                    {
                                        if (Settings.LocationPickerSelectedId != 0)
                                        {
                                            int locationId = Settings.LocationPickerSelectedId;
                                            int mapCIndex  = MapCCodeList.IndexOf(MapCCodeList.FirstOrDefault(row => row.LocationId == 0));
                                            MapCCodePickerView.Select(mapCIndex, 0, true);
                                            MapCCodePickerView.Model.Selected(MapCCodePickerView, mapCIndex, 0);

                                            int locationCInddex = FilteredLocationList.IndexOf(FilteredLocationList.FirstOrDefault(row => row.LocationId == locationId));
                                            LocationsPicker.Select(locationCInddex, 0, true);
                                            LocationsPicker.Model.Selected(LocationsPicker, locationCInddex, 0);
                                            //LocationPicker.Alpha = 1f;
                                        }
                                    }
                                }
                                else
                                {
                                    //MapCCodePicker.Model.Selected(MapCCodePicker, 0, 0);
                                    MapCCodePickerView.Select(0, 0, true);
                                }
                            });
                        }
                    }
                    else
                    {
                        InvokeOnMainThread(() =>
                        {
                            var alert = UIAlertController.Create("Please connect to the internet", "Internet access is required.", UIAlertControllerStyle.Alert);

                            alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) =>
                            {
                                RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController;
                                //var firstStep = registrationVC.Steps.FirstOrDefault();
                                //registrationVC._pageViewController.SetViewControllers(new[] { firstStep as UIViewController }, UIPageViewControllerNavigationDirection.Reverse, true, (finished) =>
                                //{
                                //	if (finished)
                                //	{
                                //		//finalStep.StepActivated(this, new MultiStepProcessStepEventArgs());

                                //	}
                                //});
                                registrationVC.DismissViewController(true, null);
                            }));

                            PresentViewController(alert, animated: true, completionHandler: () =>
                            {
                            });
                        });
                    }
                }
                catch (Exception exe) {
                }
            }
                     );
        }
Ejemplo n.º 15
0
        public static void LoadWebViewWithAd(UITapGestureRecognizer tap, Ad ad, UIView mainView)
        {
            if (Reachability.IsHostReachable(Settings._baseDomain))
            {
                LoadingOverlay loadingOverlay = new LoadingOverlay(mainView.Frame);

                var frame   = new CGRect(0, 0, mainView.Bounds.Width, mainView.Bounds.Height);
                var webView = new UIWebView(frame);


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


                var url = ad.AircraftForSaleURL;
                //commenting to test banmanpro
                //var url = "https://www.globalair.com/banmanpro/ad.aspx?ZoneID=94&Task=Get&Mode=HTML&SiteID=1&PageID=78751";
                webView.LoadRequest(new NSUrlRequest(new NSUrl(url)));

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

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

                    int width, height;

                    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        width  = 110;
                        height = 75;
                    }
                    else
                    {
                        width  = 60;
                        height = 40;
                    }

                    UIImageView imageView            = new UIImageView(new CGRect(mainView.Bounds.Width - width, mainView.Bounds.Height / 2, width, height));
                    imageView.Image                  = UIImage.FromBundle("swipe_left");
                    imageView.Alpha                  = .5f;
                    imageView.UserInteractionEnabled = true;
                    imageView.BackgroundColor        = UIColor.Gray;
                    imageView.ContentMode            = UIViewContentMode.ScaleAspectFit;
                    imageView.Layer.CornerRadius     = 20;

                    //imageView.MultipleTouchEnabled = true;

                    webView.AddSubview(imageView);
                    webView.AddSubview(closeButton);

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

                UIView.CommitAnimations();
            }
            else
            {
                SendBasicAlert("Connect to a Network", "Please connect to a network to view this ad");
            }
        }
        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);
            }
        }
Ejemplo n.º 17
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            Gai.SharedInstance.DispatchInterval        = 20;
            Gai.SharedInstance.TrackUncaughtExceptions = true;

            Tracker = Gai.SharedInstance.GetTracker(TrackingId);

            //Clay Martin 10/21/17: Allowing IDFA collection for more sophisticated analytics
            Tracker.SetAllowIdfaCollection(true);

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif
            // Make sure you set the application name before doing any inserts or gets
            BlobCache.ApplicationName = "AircraftForSaleAkavache";
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            //Wait until need to update content in the background... once implemented let the OS decide how often to fetch new content
            UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(UIApplication.BackgroundFetchIntervalMinimum);

            //Register for push notifications is user indicates wishes to receive
            if (Settings.IsRegisterForPushNotifications)
            {
                this.PromptForPushNotifications();
            }

            var              storyboard    = UIStoryboard.FromName("Main_ipad", NSBundle.MainBundle);
            bool             skipFirstStep = Settings.IsRegistered;
            UIViewController rootViewController;
            if (skipFirstStep)
            {
                rootViewController = storyboard.InstantiateViewController("MainTabBarController") as MainTabBarController;
            }
            else
            {
                rootViewController = storyboard.InstantiateInitialViewController();
            }

            Window.RootViewController = rootViewController;
            Window.MakeKeyAndVisible();


            UINavigationBar.Appearance.BarTintColor = UIColor.Black;


            if (!Reachability.IsHostReachable(Settings._baseDomain))
            {
                var alert = UIAlertController.Create("Connect to a Network", Settings._networkProblemMessage, UIAlertControllerStyle.Alert);

                alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null));

                if (alert.PopoverPresentationController != null)
                {
                    alert.PopoverPresentationController.SourceView = rootViewController.View;
                    alert.PopoverPresentationController.PermittedArrowDirections = UIPopoverArrowDirection.Up;
                }
                rootViewController.PresentViewController(alert, animated: true, completionHandler: null);
            }
            else
            {
                //Determine if need to dump cache
                if (Settings.LastImageCacheDump != string.Empty)
                {
                    DateTime startDate = DateTime.Parse(Settings.LastImageCacheDump);
                    double   days      = (DateTime.Now - startDate).TotalDays;
                    if (days > 7)
                    {
                        SDImageCache.SharedImageCache.ClearMemory();
                        SDImageCache.SharedImageCache.ClearDisk();
                        Settings.LastImageCacheDump = string.Empty;
                    }
                }

                //Determine if app was launched from a push notification

                if (launchOptions != null && launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    launchedFromPushNotification = true;
                }
                else
                {
                    launchedFromPushNotification = false;
                }

                if (!launchedFromPushNotification)
                {
                    //Task.Run(async () =>
                    //{
                    //    await PerformBackgroundDataFetchFromBuyplaneAPI(() =>
                    //    {
                    //        InvokeOnMainThread(() =>
                    //        {

                    var vc = Window.RootViewController;
                    while (vc.PresentedViewController != null)
                    {
                        vc = vc.PresentedViewController;
                    }

                    if (vc is MainTabBarController)
                    {
                        var maintTabBarController = vc as MainTabBarController;
                        var magNavVC = maintTabBarController.ViewControllers.FirstOrDefault(row => row is MagazineNavigationViewController);
                        if (magNavVC != null)
                        {
                            var chooseClassVC = (magNavVC as MagazineNavigationViewController).ViewControllers.FirstOrDefault(row => row is ChooseClassificationCollectionViewController);
                            if (chooseClassVC != null)
                            {
                                (chooseClassVC as ChooseClassificationCollectionViewController).LoadBackgroundImages();
                                if (launchOptions != null && launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                                {
                                    NSDictionary notificationDictionary = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                                    ReceivedRemoteNotification(application, notificationDictionary);
                                }
                            }
                        }
                    }

                    //        });

                    //    });
                    //});
                }
                else
                {
                    var vc = Window.RootViewController;
                    while (vc.PresentedViewController != null)
                    {
                        vc = vc.PresentedViewController;
                    }

                    if (vc is MainTabBarController)
                    {
                        var maintTabBarController = vc as MainTabBarController;
                        var magNavVC = maintTabBarController.ViewControllers.FirstOrDefault(row => row is MagazineNavigationViewController);
                        if (magNavVC != null)
                        {
                            var chooseClassVC = (magNavVC as MagazineNavigationViewController).ViewControllers.FirstOrDefault(row => row is ChooseClassificationCollectionViewController);
                            if (chooseClassVC != null)
                            {
                                (chooseClassVC as ChooseClassificationCollectionViewController).LoadBackgroundImages();
                                if (launchOptions != null && launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                                {
                                    NSDictionary notificationDictionary = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                                    ReceivedRemoteNotification(application, notificationDictionary);
                                }
                            }
                        }
                    }
                }


                //});
            }



            return(true);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UIImageView background = new UIImageView();

//assign our image file to the UIImageView
            background.Image = UIImage.FromBundle("new_home_bg1");

            //assign the UIImageView as the background view of the table
            this.TableView.BackgroundView = background;

            //set the textbox background to light gray
            this.TableView.BackgroundColor = UIColor.LightGray;

            //set the background of each table cell to clear
            foreach (var cell in this.TableView.VisibleCells)
            {
                cell.BackgroundColor = UIColor.Clear;
                cell.SelectionStyle  = UITableViewCellSelectionStyle.None;
            }

            var statusBarHeight = UIApplication.SharedApplication.StatusBarFrame.Height;

            MultiStepProcessHorizontalViewController parentViewController = this.ParentViewController as MultiStepProcessHorizontalViewController;
            var navigationController = parentViewController.ContainerViewController.NavigationController;
            var navBarHeight         = navigationController.NavigationBar.Bounds.Height;

            TableView.ContentInset = new UIEdgeInsets(statusBarHeight + navBarHeight, 0, 50, 0);

            MapCCodeList         = new List <Location>();
            LocationList         = new List <Location>();
            provinceList         = new List <Location>();
            stateList            = new List <Location>();
            FilteredLocationList = new List <Location>();
            SelectedMapCCode     = new Location();
            SelectedLocation     = new Location();

            LocationsPickerViewProperty.Alpha = 0f;
            //LocationPickerWidthConstraintProperty.Constant = 0f;
            //if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            //{
            //	MapCCodePickerWidthConstraint.Constant = 80f;
            //}
            //else {
            //	MapCCodePickerWidthConstraint.Constant = 150f;
            //}

            //Load values if already registered
            if (Settings.IsRegistered)
            {
                EmailTextField.Text       = Settings.Email;
                PasswordTextField.Text    = Settings.Password;
                FirstNameTextField.Text   = Settings.FirstName;
                LastNameTextField.Text    = Settings.LastName;
                PhoneTextField.Text       = Settings.Phone;
                CompanyTextField.Text     = Settings.Company;
                HomeAirportTextField.Text = Settings.HomeAirport;
            }

            //hide keyboard when touch anywhere
            HideKeyboardGesture = new UITapGestureRecognizer(() =>
            {
                View.EndEditing(true);
            });

            Task.Run(async() =>
            {
                LocationResponse location = new LocationResponse();
                if (Reachability.IsHostReachable(Settings._baseDomain))
                {
                    location = await LocationResponse.GetLocations();
                    if (location.Status != "Success")
                    {
                        InvokeOnMainThread(() =>
                        {
                            var alert = UIAlertController.Create("There was a problem loading registration data", "Please try again.", UIAlertControllerStyle.Alert);

                            alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) =>
                            {
                                RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController;
                                //var firstStep = registrationVC.Steps.FirstOrDefault();
                                //registrationVC._pageViewController.SetViewControllers(new[] { firstStep as UIViewController }, UIPageViewControllerNavigationDirection.Reverse, true, (finished) =>
                                //{
                                //	if (finished)
                                //	{
                                //		//finalStep.StepActivated(this, new MultiStepProcessStepEventArgs());

                                //	}
                                //});
                                registrationVC.DismissViewController(true, null);
                            }));

                            PresentViewController(alert, animated: true, completionHandler: () =>
                            {
                            });
                        });
                    }
                    else
                    {
                        //Save to settings file to use object during the rest of the registration process
                        Settings.LocationResponse = location;

                        var distinctMapCodes = location.Locations.Select(row => row.MapCCode).Distinct().ToList();
                        List <Location> filteredLocationListByFirstMapCode = new List <Location>();
                        foreach (var mapCode in distinctMapCodes)
                        {
                            Location loc = location.Locations.FirstOrDefault(row => row.MapCCode == mapCode);

                            if (loc != null)
                            {
                                if (loc.MapCCode == "WO")
                                {
                                    Location placeholderLocation     = new Location();
                                    placeholderLocation.LocationId   = loc.LocationId;
                                    placeholderLocation.LocName      = "World";
                                    placeholderLocation.Abbreviation = loc.Abbreviation;
                                    placeholderLocation.MapCCode     = loc.MapCCode;
                                    placeholderLocation.DisplayOrder = loc.DisplayOrder;
                                    filteredLocationListByFirstMapCode.Add(placeholderLocation);
                                }
                                else
                                {
                                    filteredLocationListByFirstMapCode.Add(loc);
                                }
                            }
                        }
                        MapCCodeList = filteredLocationListByFirstMapCode.OrderByDescending(row => row.DisplayOrder).ToList();

                        Location sleLocation     = new Location();
                        sleLocation.LocationId   = 0;
                        sleLocation.LocName      = "Select";
                        sleLocation.Abbreviation = "Select";
                        sleLocation.MapCCode     = "SE";
                        sleLocation.DisplayOrder = 0;
                        MapCCodeList.Insert(0, sleLocation);

                        LocationList         = location.Locations.OrderBy(row => row.DisplayOrder).ToList();
                        provinceList         = location.ProvinceLst.OrderBy(row => row.DisplayOrder).ToList();
                        stateList            = location.StatesLst.OrderBy(row => row.DisplayOrder).ToList();
                        FilteredLocationList = LocationList;

                        if (MapCCodeList.Count > 1 && Settings.LocationPickerSelectedId == 0)
                        {
                            //Assign value to registration objec
                            Settings.LocationPickerSelectedId = MapCCodeList[0].LocationId;
                        }

                        InvokeOnMainThread(() =>
                        {
                            MapCCodePicker.Model = new MapCCodeMod(this);
                            LocationPicker.Model = new LocationsMod(this);

                            if (Settings.IsRegistered)
                            {
                                var previouslSelectedLocation = MapCCodeList.FirstOrDefault(row => row.LocationId == Settings.LocationPickerSelectedId);

                                if (previouslSelectedLocation != null)
                                {
                                    int currentIndex = MapCCodeList.IndexOf(MapCCodeList.FirstOrDefault(row => row.LocationId == Settings.LocationPickerSelectedId));;
                                    MapCCodePicker.Select(currentIndex, 0, true);
                                }
                                else
                                {
                                    if (Settings.LocationPickerSelectedId != 0)
                                    {
                                        int locationId = Settings.LocationPickerSelectedId;
                                        int mapCIndex  = MapCCodeList.IndexOf(MapCCodeList.FirstOrDefault(row => row.LocationId == 0));
                                        MapCCodePicker.Select(mapCIndex, 0, true);
                                        MapCCodePicker.Model.Selected(MapCCodePicker, mapCIndex, 0);

                                        int locationCInddex = FilteredLocationList.IndexOf(FilteredLocationList.FirstOrDefault(row => row.LocationId == locationId));
                                        LocationPicker.Select(locationCInddex, 0, true);
                                        LocationPicker.Model.Selected(LocationPicker, locationCInddex, 0);
                                        //LocationPicker.Alpha = 1f;
                                    }
                                }
                            }
                            else
                            {
                                //MapCCodePicker.Model.Selected(MapCCodePicker, 0, 0);
                                MapCCodePicker.Select(0, 0, true);
                            }
                        });
                    }
                }
                else
                {
                    InvokeOnMainThread(() =>
                    {
                        var alert = UIAlertController.Create("Please connect to the internet", "Internet access is required.", UIAlertControllerStyle.Alert);

                        alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) =>
                        {
                            RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController;
                            //var firstStep = registrationVC.Steps.FirstOrDefault();
                            //registrationVC._pageViewController.SetViewControllers(new[] { firstStep as UIViewController }, UIPageViewControllerNavigationDirection.Reverse, true, (finished) =>
                            //{
                            //	if (finished)
                            //	{
                            //		//finalStep.StepActivated(this, new MultiStepProcessStepEventArgs());

                            //	}
                            //});
                            registrationVC.DismissViewController(true, null);
                        }));

                        PresentViewController(alert, animated: true, completionHandler: () =>
                        {
                        });
                    });
                }
            });
        }
Ejemplo n.º 19
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;
        }