Exemplo n.º 1
0
        public void PushCustomModal(View view)
        {
            if (view.BackgroundColor == Color.Default)
            {
                view.BackgroundColor = Color.White;
            }

            var bounds = UIScreen.MainScreen.Bounds;
            var width  = bounds.Width;
            var height = bounds.Height;

            var modal = new ContentView()
            {
                BackgroundColor = new Color(0, 0, 0, 0.5)
            };
            var fullrect = new CGRect(0, 0, width, height);

            var nativeModal = FormsViewToNativeiOS.ConvertFormsToNative(modal, fullrect);

            var rect            = new CGRect(15, 35, width - 30, height - 50);
            var nativeConverted = FormsViewToNativeiOS.ConvertFormsToNative(view, rect);

            nav = UIApplication.SharedApplication.KeyWindow.RootViewController.ChildViewControllers[0] as UINavigationController;

            var viewController = new UIViewController();

            viewController.ModalPresentationStyle = UIModalPresentationStyle.Custom;
            viewController.View.BackgroundColor   = UIColor.Clear;

            viewController.View.AddSubview(nativeModal);
            viewController.View.AddSubview(nativeConverted);

            nav.PresentModalViewController(viewController, false);
        }
Exemplo n.º 2
0
        public void ShowContact(NavigationPage page)
        {
            var key = DateTime.Now.ToString();
            var newPersonController = new ABNewPersonViewController();
            var person = new ABPerson();

            person.FirstName          = "John " + key;
            person.LastName           = "Doe" + key;
            newPersonController.Title = "This is a test";

            newPersonController.DisplayedPerson = person;

            UINavigationController nav = null;

            foreach (var vc in UIApplication.SharedApplication.Windows[0].RootViewController.ChildViewControllers)
            {
                if (vc is UINavigationController)
                {
                    nav = (UINavigationController)vc;
                }
            }

            newPersonController.NewPersonComplete += (object sender, ABNewPersonCompleteEventArgs e) =>
            {
                nav.DismissModalViewController(true);
            };


            nav.PresentModalViewController(new UINavigationController(newPersonController), true);
        }
Exemplo n.º 3
0
        private Task <Card> ReadAsync(Products supportedProducts, string apiKey)
        {
            var window = UIApplication.SharedApplication.KeyWindow;

            if (window == null)
            {
                throw new InvalidOperationException("There's no current active window");
            }

            if (navigationController == null)
            {
                throw new InvalidOperationException("There's no current navigation controller");
            }

            var id   = GetRequestId();
            var ntcs = new TaskCompletionSource <Card>(id);

            if (Interlocked.CompareExchange(ref completionSource, ntcs, null) != null)
            {
                throw new InvalidOperationException("Only one operation can be active at a time");
            }

            readerController = new ReaderController(supportedProducts.ToArray(), apiKey, id);

            navigationController.PresentModalViewController(readerController, true);

            EventHandler <CardReadEventArgs> handler = null;

            handler = (s, e) =>
            {
                var tcs = Interlocked.Exchange(ref completionSource, null);
                readerController.CardRead -= handler;
                if (e.RequestId != id)
                {
                    navigationController.DismissModalViewController(true);
                    return;
                }
                if (e.IsCanceled)
                {
                    navigationController.DismissModalViewController(true);
                    tcs.SetResult(null);
                }
                else if (e.Error != null)
                {
                    navigationController.DismissModalViewController(true);
                    tcs.SetException(e.Error);
                }
                else
                {
                    navigationController.DismissModalViewController(true);
                    tcs.SetResult(e.Card);
                }
            };

            readerController.CardRead += handler;

            return(completionSource.Task);
        }
Exemplo n.º 4
0
 public void NavigateToPopover(UIViewController vc, bool animated)
 {
     if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
     {
     }
     else
     {
         _masterNavigationController.PresentModalViewController(vc, animated);
     }
 }
Exemplo n.º 5
0
 public void PushToModel(UIViewController vc)
 {
     if (_splitViewController != null)
     {
         _splitViewController.PresentModalViewController(vc, true);
     }
     else
     {
         _masterNavigationController.PresentModalViewController(vc, true);
     }
 }
Exemplo n.º 6
0
        Task <byte[]> TakeAsync()
        {
            var window = UIApplication.SharedApplication.KeyWindow;

            if (window == null)
            {
                throw new InvalidOperationException("No hay una ventana activa");
            }
            if (navigationController == null)
            {
                throw new InvalidOperationException("No hay un controlador de navegacion en la aplicación");
            }
            var id   = GetRequestId();
            var ntcs = new TaskCompletionSource <byte[]>(id);

            if (Interlocked.CompareExchange(ref completionSource, ntcs, null) != null)
            {
                throw new InvalidOperationException("Sólo se puede hacer una operación a la vez");
            }
            cameraController = new CameraContoller(id);
            navigationController.PresentModalViewController(cameraController, true);
            EventHandler <PhotoEventArgs> handler = null;

            handler = (s, e) =>
            {
                var tcs = Interlocked.Exchange(ref completionSource, null);
                cameraController.PhotoRead -= handler;
                if (e.RequestId != id)
                {
                    navigationController.DismissModalViewController(true);
                }
                if (e.IsCancelled)
                {
                    navigationController.DismissModalViewController(true);
                    tcs.SetResult(null);
                }
                else if (e.Error != null)
                {
                    navigationController.DismissModalViewController(true);
                    tcs.SetException(e.Error);
                }
                else
                {
                    navigationController.DismissModalViewController(true);
                    tcs.SetResult(e.Photo);
                }
            };

            cameraController.PhotoRead += handler;

            return(completionSource.Task);
        }
Exemplo n.º 7
0
        void pickAColorBtn_HandleTouchUpInside(object sender, EventArgs e)
        {
            picker              = new ColorPickerViewController();
            picker.ColorPicked += HandleColorPicked;
            picker.Title        = "Pick a color!";
            UINavigationController pickerNav = new UINavigationController(picker);

            pickerNav.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

            doneBtn = new UIBarButtonItem(UIBarButtonSystemItem.Done);
            picker.NavigationItem.RightBarButtonItem = doneBtn;
            doneBtn.Clicked += doneBtn_HandleClicked;
            nav.PresentModalViewController(pickerNav, true);
        }
Exemplo n.º 8
0
        private RootElement RenderPicker(Item values, Item pickerValues)
        {
            // build a section with all the items in the current list
            section = new Section();
            foreach (var item in currentList)
            {
                CheckboxElement ce = new CheckboxElement(item.Name);
                // set the value to true if the current item is in the values list
                ce.Value   = values.Items.IndexOf(item) < 0 ? false : true;
                ce.Tapped += delegate { Checkbox_Click(ce, new EventArgs()); };
                section.Add(ce);
            }

            Section itemTypeSection = null;

            if (itemTypeID == SystemItemTypes.Contact)
            {
                itemTypeSection = new Section()
                {
                    new StringElement("Add contact", delegate {
                        var picker           = new ABPeoplePickerNavigationController();
                        picker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                            // process the contact - if it's not null, handle adding the new contact to the ListPicker
                            var contact = ContactPickerHelper.ProcessContact(e.Person);
                            if (contact != null)
                            {
                                HandleAddedContact(contact);
                            }
                            picker.DismissModalViewControllerAnimated(true);
                        };

                        picker.Cancelled += delegate {
                            picker.DismissModalViewControllerAnimated(true);
                        };

                        // present the contact picker
                        controller.PresentModalViewController(picker, true);
                    }),
                };
            }

            var listPickerRoot = new RootElement(caption);

            if (itemTypeSection != null)
            {
                listPickerRoot.Add(itemTypeSection);
            }
            listPickerRoot.Add(section);
            return(listPickerRoot);
        }
Exemplo n.º 9
0
 //alert stuff
 void ShowAlert(string name)
 {
     /*
      * UIAlertView alert = new UIAlertView();
      * alert.Title = "Meeting Request";
      * alert.AddButton("OK");
      * alert.AddButton("No Thanks");
      * alert.Message = "Do you wish to meeting with " + name + "?";
      * alert.Clicked += HandleAlertClicked;
      * navigationController.View.AddSubview(alert);
      * navigationController.View.LayoutSubviews();
      * navigationController.View.BringSubviewToFront(alert);
      * alert.Show();
      */
     navigationController.PresentModalViewController(new ShowViewController(name, navigationController), true);
 }
Exemplo n.º 10
0
        private void OpenFile(string filePath, DataItem item)
        {
            var    sbounds = UIScreen.MainScreen.Bounds;
            string ext     = UrlHelper.GetExtension(filePath);

            if (ext.ToUpper() == ".MOV" || ext.ToUpper() == ".M4V")
            {
                var movieController = new AdvancedUIViewController();
                moviePlayer            = new MPMoviePlayerController(NSUrl.FromFilename(filePath));
                moviePlayer.View.Frame = new RectangleF(
                    sbounds.X,
                    sbounds.Y - 20,
                    sbounds.Width,
                    sbounds.Height - 30
                    );
                moviePlayer.ControlStyle          = MPMovieControlStyle.Fullscreen;
                moviePlayer.View.AutoresizingMask = (UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight);
                moviePlayer.ShouldAutoplay        = true;
                moviePlayer.PrepareToPlay();
                moviePlayer.Play();

                var btnClose = UIButton.FromType(UIButtonType.RoundedRect);
                btnClose.Frame = new RectangleF(3, 7, 60, 30);
                btnClose.SetTitle("Close", UIControlState.Normal);
                btnClose.SetTitleColor(UIColor.Black, UIControlState.Normal);
                btnClose.TouchDown += delegate {
                    movieController.DismissModalViewControllerAnimated(true);
                };

                var btnShare = UIButton.FromType(UIButtonType.RoundedRect);
                btnShare.Frame = new RectangleF(
                    (sbounds.Width / 2) - 50,
                    sbounds.Height - 50,
                    100,
                    30
                    );
                btnShare.SetTitle("Share", UIControlState.Normal);
                btnShare.SetTitleColor(UIColor.Black, UIControlState.Normal);
                btnShare.TouchDown += delegate {
                    ResharedItem     = item;
                    ResharedItemType = FileType.Video;
                    ShowSecretsView();
                };

                movieController.View.AddSubview(moviePlayer.View);
                movieController.View.AddSubview(btnClose);
                movieController.View.AddSubview(btnShare);
                navigation.PresentModalViewController(movieController, true);
            }
            else if (ext.ToUpper() == ".JPEG" || ext.ToUpper() == ".JPG" || ext.ToUpper() == ".PNG")
            {
                ALAssetsLibrary library = new ALAssetsLibrary();
                library.AssetForUrl(new NSUrl(filePath),
                                    (asset) => {
                    if (asset != null)
                    {
                        var imageController = new AdvancedUIViewController();
                        var image           = UIImage.FromImage(asset.DefaultRepresentation.GetFullScreenImage());
                        var imageView       = new UIImageView(image);
                        imageView.Frame     = sbounds;
                        imageView.UserInteractionEnabled = true;
                        imageView.ClipsToBounds          = true;
                        imageView.ContentMode            = UIViewContentMode.ScaleAspectFit;

                        var btnClose   = UIButton.FromType(UIButtonType.RoundedRect);
                        btnClose.Frame = new RectangleF(
                            (sbounds.Width / 2) - 50,
                            20,
                            100,
                            30
                            );
                        btnClose.SetTitle("Close", UIControlState.Normal);
                        btnClose.SetTitleColor(UIColor.Black, UIControlState.Normal);
                        btnClose.TouchDown += delegate {
                            imageController.DismissModalViewControllerAnimated(true);
                        };

                        var btnShare   = UIButton.FromType(UIButtonType.RoundedRect);
                        btnShare.Frame = new RectangleF(
                            (sbounds.Width / 2) - 50,
                            sbounds.Height - 60,
                            100,
                            30
                            );
                        btnShare.SetTitle("Share", UIControlState.Normal);
                        btnShare.SetTitleColor(UIColor.Black, UIControlState.Normal);
                        btnShare.TouchDown += delegate {
                            ResharedItem     = item;
                            ResharedItemType = FileType.Photo;
                            ShowSecretsView();
                        };

                        var scrollView                        = new UIScrollView(sbounds);
                        scrollView.ClipsToBounds              = true;
                        scrollView.ContentSize                = sbounds.Size;
                        scrollView.BackgroundColor            = UIColor.Gray;
                        scrollView.MinimumZoomScale           = 1.0f;
                        scrollView.MaximumZoomScale           = 3.0f;
                        scrollView.MultipleTouchEnabled       = true;
                        scrollView.AutoresizingMask           = (UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight);
                        scrollView.ViewForZoomingInScrollView = delegate(UIScrollView sv) {
                            return(imageView);
                        };

                        scrollView.AddSubview(imageView);
                        imageController.View.AddSubview(scrollView);
                        imageController.View.AddSubview(btnClose);
                        imageController.View.AddSubview(btnShare);
                        navigation.PresentModalViewController(imageController, true);
                    }
                    else
                    {
                        Console.Out.WriteLine("Asset is null.");
                    }
                },
                                    (error) => {
                    if (error != null)
                    {
                        Console.Out.WriteLine("Error: " + error.LocalizedDescription);
                    }
                }
                                    );
            }
            else
            {
                var btnShare = UIButton.FromType(UIButtonType.RoundedRect);
                btnShare.Frame = new RectangleF(
                    (sbounds.Width / 2) - 50,
                    sbounds.Height - 50,
                    100,
                    30
                    );
                btnShare.SetTitle("Share", UIControlState.Normal);
                btnShare.SetTitleColor(UIColor.Black, UIControlState.Normal);
                btnShare.Tag        = SHARE_BUTTON_TAG;
                btnShare.TouchDown += delegate {
                    ResharedItem     = item;
                    ResharedItemType = FileType.Other;
                    ShowSecretsView();
                };

                navigation.Add(btnShare);
                interactionControllerDelegate  = new  UIDocumentInteractionControllerDelegateClass(navigation);
                interactionController          = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(filePath));
                interactionController.Delegate = interactionControllerDelegate;
                InvokeOnMainThread(delegate {
                    interactionController.PresentPreview(true);
                });
            }
        }
        public override void ViewDidLoad()
        {
            try
            {
                //this.NavCtrl.NavigationBar.BarStyle = UIBarStyle.BlackTranslucent;
                //UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
                //NavCtrl.NavigationBar.BackgroundColor = UIColor.Clear;
                nfloat ScreenHeight = UIScreen.MainScreen.Bounds.Height;
                ScreenHeight = (ScreenHeight - 100) / 3;
                Boolean internetStatus = Reachability.IsHostReachable("https://www.google.com");
                if (internetStatus == false)
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "Sorry",
                        Message = "Not connected to internet.Please connect and retry."
                    };

                    alert.AddButton("OK");
                    alert.Show();
                }
                BTProgressHUD.Dismiss();
                UIImageView backgroud = new UIImageView();
                backgroud.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, ScreenHeight - 20);
                backgroud.Image = new UIImage("proback.png");
                backgroud.UserInteractionEnabled = false;
                btnBack.UserInteractionEnabled   = false;
                //imgProfile.Frame = new CGRect((View.Frame.Width / 2) - 72, 3 * (backgroud.Frame.Height / 3), 144, 152);
                //UITapGestureRecognizer singleTap = new UITapGestureRecognizer();
                //singleTap.CancelsTouchesInView = false;
                //Scroll.AddGestureRecognizer(singleTap);
                //DismissKeyboardOnBackgroundTap();
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyBoardDownNotification);
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardUpNotification);
                LoggingClass.LogInfo("Entered into Profile View", screenid);
                pickerDataModel = new StatePickerDataModel();
                pickerDataModel.Items.Add("---Select your state---");
                pickerDataModel.Items.Add("AL");
                pickerDataModel.Items.Add("AK");
                pickerDataModel.Items.Add("AZ");
                pickerDataModel.Items.Add("AR");
                pickerDataModel.Items.Add("CA");
                pickerDataModel.Items.Add("CO");
                pickerDataModel.Items.Add("CT");
                pickerDataModel.Items.Add("DE");
                pickerDataModel.Items.Add("FL");
                pickerDataModel.Items.Add("GA");
                pickerDataModel.Items.Add("HI");
                pickerDataModel.Items.Add("ID");
                pickerDataModel.Items.Add("IL");
                pickerDataModel.Items.Add("IN");
                pickerDataModel.Items.Add("IA");
                pickerDataModel.Items.Add("KS");
                pickerDataModel.Items.Add("KY");
                pickerDataModel.Items.Add("LA");
                pickerDataModel.Items.Add("ME");
                pickerDataModel.Items.Add("MD");
                pickerDataModel.Items.Add("MA");
                pickerDataModel.Items.Add("MI");
                pickerDataModel.Items.Add("MN");
                pickerDataModel.Items.Add("MS");
                pickerDataModel.Items.Add("MO");
                pickerDataModel.Items.Add("MT");
                pickerDataModel.Items.Add("NE");
                pickerDataModel.Items.Add("NV");
                pickerDataModel.Items.Add("NH");
                pickerDataModel.Items.Add("NJ");
                pickerDataModel.Items.Add("NM");
                pickerDataModel.Items.Add("NY");
                pickerDataModel.Items.Add("NC");
                pickerDataModel.Items.Add("ND");
                pickerDataModel.Items.Add("OH");
                pickerDataModel.Items.Add("OK");
                pickerDataModel.Items.Add("OR");
                pickerDataModel.Items.Add("PA");
                pickerDataModel.Items.Add("RI");
                pickerDataModel.Items.Add("SC");
                pickerDataModel.Items.Add("SD");
                pickerDataModel.Items.Add("TN");
                pickerDataModel.Items.Add("TX");
                pickerDataModel.Items.Add("UT");
                pickerDataModel.Items.Add("VT");
                pickerDataModel.Items.Add("VA");
                pickerDataModel.Items.Add("WA");
                pickerDataModel.Items.Add("WV");
                pickerDataModel.Items.Add("WI");
                pickerDataModel.Items.Add("WY");

                statePicker.Model = pickerDataModel;
                //statePicker.BackgroundColor = UIColor.Red;
                //statePicker = new UIPickerView(new CGRect(01,01,UIScreen.MainScreen.Bounds.Width,UIScreen.MainScreen.Bounds.Height));
                //	//UIScreen.MainScreen.Bounds.X-UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height, UIScreen.MainScreen.Bounds.Width, 180));
                StoreDataModel = new StorePickerDataModel();
                StoreDataModel.Items.Add("---Select preffered store---");
                StoreDataModel.Items.Add("Wall");
                StoreDataModel.Items.Add("Pt. Pleasant Beach");
                StoreDataModel.Items.Add("All");
                storePicker.Model = StoreDataModel;
                //statePicker.Select(5, 0, true);
                //LoggingClass.UploadErrorLogs();
                if (CurrentUser.RetreiveUserId() == 0)
                {
                    DownloadAsync();
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "This feature is allowed only for VIP Card holders",
                        //Message = "Coming Soon..."
                    };

                    alert.AddButton("OK");
                    alert.AddButton("Log in");
                    alert.AddButton("Know more");
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 1)
                        {
                            CurrentUser.Clear();
                            LoginViewController yourController = new LoginViewController();
                            yourController.nav      = NavCtrl;
                            yourController.RootTabs = CurrentUser.RootTabs;
                            NavCtrl.PushViewController(yourController, false);
                            //NavCtrl.PopViewController(false);
                            //NavCtrl.PopViewController(false);
                        }
                    };
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 2)
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                        }
                    };
                    alert.Show();
                    btnUpdate.UserInteractionEnabled   = false;
                    txtLastName.UserInteractionEnabled = false;
                    txtPhone.UserInteractionEnabled    = false;
                    txtAddress.UserInteractionEnabled  = false;
                    txtZipCode.UserInteractionEnabled  = false;
                    txtEmail.UserInteractionEnabled    = false;
                    statePicker.UserInteractionEnabled = false;
                    storePicker.UserInteractionEnabled = false;
                    imgProfile.UserInteractionEnabled  = false;
                    btnPicEdit.UserInteractionEnabled  = false;
                }
                else
                {
                    DownloadAsync();
                    cRes = svc.GetCustomerDetails(CurrentUser.RetreiveUserId()).Result;
                    //txtFirstName.Text = cRes.customer.FirstName;
                    name             = cRes.customer.FirstName + " " + cRes.customer.LastName;
                    name             = name.Trim();
                    txtLastName.Text = name;                    //cRes.customer.FirstName+" "+cRes.customer.LastName;
                    //txtCity.Text = cRes.customer.City;
                    txtEmail.Text = cRes.customer.Email;
                    if (cRes.customer.PhoneNumber.Length != 10)
                    {
                        //cRes.customer.PhoneNumber
                        txtPhone.Text = cRes.customer.PhoneNumber;
                    }
                    txtCardnumber.Text = cRes.customer.CardNumber;
                    txtExpirydate.Text = cRes.customer.ExpireDate.ToString("MM-dd-yyyy");
                    txtZipCode.Text    = cRes.customer.Zip;
                    string state = cRes.customer.State;
                    if (pickerDataModel.Items.Contains(state))
                    {
                        int i = pickerDataModel.Items.FindIndex(x => x == state);
                        statePicker.Select(i, 0, false);
                    }
                    int prefStore = cRes.customer.PreferredStore;
                    storePicker.Select(prefStore, 0, false);
                    txtAddress.Text = cRes.customer.Address1 + cRes.customer.Address2 + cRes.customer.City;
                    //txtFirstName.ShouldReturn += (TextField) =>
                    // {
                    //  ((UITextField)TextField).ResignFirstResponder();
                    //  return true;
                    // };
                    txtLastName.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtEmail.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtPhone.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtAddress.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtZipCode.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtZipCode.AccessibilityScroll(UIAccessibilityScrollDirection.Up);
                    btnUpdate.SetTitleColor(UIColor.Purple, UIControlState.Normal);
                    //btnEdit.SetTitleColor(UIColor.Purple, UIControlState.Normal);
                    //btnUpdate.TouchDown += (sender, e) =>
                    //{
                    //	BTProgressHUD.Show("Updating profile..."); //show spinner + text
                    //};
                    //btnUpdate.TouchUpInside += async (sender, e) =>
                    //{
                    //	if (txtPhone.Text.Length > 10 || txtPhone.Text.Length < 10)
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Phone number is invalid");
                    //	}
                    //	else if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Email is invalid");
                    //	}
                    //	else if ((txtZipCode.Text.Length!=5))
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid");
                    //	}
                    //	else
                    //	{
                    //		LoggingClass.LogInfo("Update button into Profile View", screenid);
                    //		Customer cust = new Customer();
                    //		cust.CustomerID = CurrentUser.RetreiveUserId();
                    //		cust.Address1 = txtAddress.Text;
                    //		name = txtLastName.Text;
                    //	name = name.Trim();
                    //	try
                    //	{
                    //		string[] str1 = name.Split(' ');
                    //		if (str1.Length == 2)
                    //		{
                    //			cust.FirstName = str1[0];
                    //			cust.LastName = str1[1];
                    //		}
                    //		else
                    //		{
                    //			cust.FirstName = str1[0] + str1[1];
                    //			cust.LastName = str1[2];
                    //		}
                    //	}
                    //	catch (Exception exe)
                    //	{
                    //		LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                    //	}
                    //		cust.Email = txtEmail.Text;
                    //		cust.PhoneNumber = txtPhone.Text;
                    //		cust.State = pickerDataModel.SelectedItem;
                    //		cust.Zip = txtZipCode.Text;
                    //		cust.PreferredStore = StoreDataModel.SelectedItem;
                    //		CurrentUser.PutStore(StoreDataModel.SelectedItem);
                    //		await svc.UpdateCustomer(cust);
                    //		BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                    //		//try
                    //		//{
                    //		//	NavCtrl.PopViewController(true);
                    //		//	//NavCtrl.PushViewController(new FirstViewController(handle), false);
                    //		//}
                    //		//catch (Exception exe)
                    //		//{
                    //		//	LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                    //		//}
                    //	}
                    //};
                    btnUpdate.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                    UIImage imgbtnCam = UIImage.FromFile("cam.png");
                    imgbtnCam = ResizeImage(imgbtnCam, 25, 25);
                    btnPicEdit.SetImage(imgbtnCam, UIControlState.Normal);
                    btnBack.UserInteractionEnabled = false;
                    //btnPicEdit.SetTitle("Edit", UIControlState.Normal);
                    //try
                    //{
                    btnPicEdit.TouchUpInside += (sender, e) =>
                    {
                        try
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Please choose an option to upload profile picture",
                                //Message = "Coming Soon..."
                            };
                            alert.AddButton("Cancel");
                            alert.AddButton("Camera");
                            alert.AddButton("Gallery");
                            alert.Clicked += (senderalert, buttonArgs) =>
                            {
                                if (buttonArgs.ButtonIndex == 1)
                                {
                                    try
                                    {
                                        IsCameraAuthorized();
                                        TweetStation.Camera.TakePicture(this, (obj) =>
                                        {
                                            var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
                                            var meta  = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
                                            UploadProfilePic(photo);
                                            //ALAssetsLibrary library = new ALAssetsLibrary();
                                            //library.WriteImageToSavedPhotosAlbum(photo.CGImage, meta, (assetUrl, error) =>
                                            //{
                                            //	UploadProfilePic(assetUrl.ToString());
                                            //	Console.WriteLine("assetUrl:" + assetUrl);
                                            //});
                                            //var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                                        });
                                    }
                                    catch (Exception exe)
                                    {
                                        LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                    }
                                }
                            };
                            alert.Clicked += (senderalert, buttonArgs) =>
                            {
                                if (buttonArgs.ButtonIndex == 2)
                                {
                                    imagePicker                       = new UIImagePickerController();
                                    imagePicker.SourceType            = UIImagePickerControllerSourceType.PhotoLibrary;
                                    imagePicker.MediaTypes            = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                                    imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                                    imagePicker.Canceled             += Handle_Canceled;
                                    NavCtrl.PresentModalViewController(imagePicker, true);
                                }
                            };
                            alert.Show();
                            //imagePicker = new UIImagePickerController();
                            //imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
                            //imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                            //imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                            //imagePicker.Canceled += Handle_Canceled;
                            //NavCtrl.PresentModalViewController(imagePicker, true);
                        }
                        catch (Exception exe)
                        {
                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                        }
                    };
                }
                //imgEmail.Image = new UIImage("mail.png");
                //imgAddr.Image = new UIImage("add.png");
                //imgPhone.Image = new UIImage("phone1.png");
                Scroll = new UIScrollView
                {
                    Frame            = new CGRect(0, 0, View.Frame.Width, View.Frame.Height),
                    ContentSize      = new CGSize(View.Frame.Width, View.Frame.Height),
                    BackgroundColor  = UIColor.White,
                    AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
                };

                UIToolbar toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, Convert.ToSingle(this.View.Frame.Size.Width), 44.0f));
                toolbar.TintColor   = UIColor.White;
                toolbar.BarStyle    = UIBarStyle.Default;
                toolbar.Translucent = true;
                UITapGestureRecognizer taps = new UITapGestureRecognizer();
                taps.CancelsTouchesInView = false;
                taps.AddTarget(() => Scroll.EndEditing(true));
                Scroll.AddGestureRecognizer(taps);
                UIImage imgbtnUpdate = UIImage.FromFile("tick.png");
                imgbtnUpdate = ResizeImage(imgbtnUpdate, 25, 25);
                //var topBtn = new UIBarButtonItem(imgbtnUpdate, UIBarButtonItemStyle.Plain, async delegate
                //{
                btnUpdate.TouchUpInside += async delegate
                {
                    //if (txtPhone.Text.Length!=12)
                    //{
                    //	BTProgressHUD.ShowErrorWithStatus("Phone number is invalid");
                    //}
                    if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                    {
                        BTProgressHUD.ShowErrorWithStatus("Email is invalid");
                    }
                    else if ((txtZipCode.Text.Length != 5))
                    {
                        BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid");
                    }
                    else
                    {
                        BTProgressHUD.Show("Updating Profile...");
                        LoggingClass.LogInfo("Update button into Profile View", screenid);
                        Customer cust = new Customer();
                        cust.CustomerID = CurrentUser.RetreiveUserId();
                        cust.Address1   = txtAddress.Text;
                        //cust.FirstName = txtFirstName.Text;
                        name = txtLastName.Text;
                        name = name.Trim();
                        try
                        {
                            string[] str1 = name.Split(' ');
                            if (str1.Length == 2)
                            {
                                cust.FirstName = str1[0];
                                cust.LastName  = str1[1];
                            }
                            else
                            {
                                cust.FirstName = str1[0] + str1[1];
                                cust.LastName  = str1[2];
                            }
                        }
                        catch (Exception exe)
                        {
                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                        }
                        cust.Email       = txtEmail.Text;
                        cust.PhoneNumber = txtPhone.Text;

                        if (pickerDataModel.SelectedItem == "---Select your state---")
                        {
                            if (pickerDataModel.Items.Contains(cRes.customer.State))
                            {
                                int i = pickerDataModel.Items.FindIndex(x => x == cRes.customer.State);
                                statePicker.Select(i, 0, false);
                            }
                            cust.State = cRes.customer.State;
                        }
                        else
                        {
                            cust.State = pickerDataModel.SelectedItem;
                        }
                        cust.Zip = txtZipCode.Text;
                        if (StoreDataModel.SelectedItem == 0)
                        {
                            cust.PreferredStore = cRes.customer.PreferredStore;
                            storePicker.Select(cRes.customer.PreferredStore, 0, false);
                            CurrentUser.PutStore(cust.PreferredStore);
                        }
                        else
                        {
                            cust.PreferredStore = StoreDataModel.SelectedItem;
                            CurrentUser.PutStore(cust.PreferredStore);
                        }
                        await svc.UpdateCustomer(cust);

                        BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                    }
                };
                imgProfile.ClipsToBounds   = true;
                imgProfile.BackgroundColor = UIColor.White;
                //NavigationController.NavigationBar.TopItem.SetRightBarButtonItem(topBtn, true);
                btnBack.BackgroundColor = UIColor.FromRGB(93, 93, 93);
                Scroll.AddSubview(backgroud);
                Scroll.AddSubview(btnBack);
                //Scroll.AddSubview(imgAddr);
                //Scroll.AddSubview(imgPhone);
                //Scroll.AddSubview(imgEmail);
                Scroll.AddSubview(txtEmail);
                Scroll.AddSubview(statePicker);
                Scroll.AddSubview(storePicker);
                Scroll.AddSubview(txtPhone);
                Scroll.AddSubview(txtZipCode);
                //Scroll.AddSubview(txtFirstName);
                Scroll.AddSubview(txtLastName);
                Scroll.AddSubview(txtAddress);
                Scroll.AddSubview(imgProfile);
                Scroll.AddSubview(btnPicEdit);
                Scroll.AddSubview(lblEmail);
                Scroll.AddSubview(lblState);
                Scroll.AddSubview(lblMobile);
                Scroll.AddSubview(lblAddress);
                Scroll.AddSubview(lblZipcode);
                //Scroll.AddSubview(lblFirstname);
                Scroll.AddSubview(lblLastname);
                Scroll.AddSubview(btnUpdate);
                Scroll.AddSubview(lblStorePi);
                Scroll.AddSubview(lblExpiryDate);
                Scroll.AddSubview(txtExpirydate);
                Scroll.AddSubview(lblcardnumber);
                Scroll.AddSubview(txtCardnumber);

                //View.AddSubview(Scroll);

                for (int i = 0; i < Scroll.Subviews.Length; i++)
                {
                    nfloat n = Scroll.Subviews[i].Frame.Size.Height;
                    h = h + n;
                }
                //Console.WriteLine(h);
                Scroll.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, h - 200);
                View = (Scroll);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
Exemplo n.º 12
0
        public override Task <TEditorResponse> ShowTEditor(string html, ToolbarBuilder toolbarBuilder = null, EventHandler <ToolbarBuilderEventArgs> toolbarBuilderOnClick = null, bool autoFocusInput = false)
        {
            TaskCompletionSource <TEditorResponse> taskRes = new TaskCompletionSource <TEditorResponse>();
            var            tvc     = new TEditorViewController();
            ToolbarBuilder builder = toolbarBuilder;

            if (toolbarBuilder == null)
            {
                builder = new ToolbarBuilder();
            }
            tvc.BuildToolbar(builder, toolbarBuilderOnClick);
            tvc.SetHTML(html);
            tvc.SetAutoFocusInput(autoFocusInput);
            tvc.Title = CrossTEditor.PageTitle;

            UINavigationController nav = null;

            tvc.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(CrossTEditor.CancelText, UIBarButtonItemStyle.Plain, (item, args) =>
            {
                if (nav != null)
                {
                    if (UIKit.UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        nav.DismissModalViewController(true);
                    }
                    else
                    {
                        nav.PopViewController(true);
                    }
                }
                taskRes.SetResult(new TEditorResponse()
                {
                    IsSave = false, HTML = string.Empty
                });
            }), true);
            tvc.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(CrossTEditor.SaveText, UIBarButtonItemStyle.Done, async(item, args) =>
            {
                if (nav != null)
                {
                    if (UIKit.UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        nav.DismissModalViewController(true);
                    }
                    else
                    {
                        nav.PopViewController(true);
                    }
                }
                taskRes.SetResult(new TEditorResponse()
                {
                    IsSave = true, HTML = await tvc.GetHTML()
                });
            }), true);

            var root   = UIApplication.SharedApplication.KeyWindow.RootViewController;
            var window = UIApplication.SharedApplication.Windows;

            var rootWindow = window?.FirstOrDefault()?.RootViewController?.ModalViewController;

            if (rootWindow != null)
            {
                nav = GetNavController(rootWindow);
            }
            else
            {
                nav = GetNavController(root);
            }

            if (nav != null)
            {
                if (UIKit.UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    var childViewControllers = nav.ChildViewControllers;

                    var newnav = new UINavigationController(tvc);
                    newnav.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
                    nav.PresentModalViewController(newnav, true);
                }
                else
                {
                    nav.PushViewController(tvc, true);
                }
            }
            return(taskRes.Task);
        }
Exemplo n.º 13
0
        void Internal_ViewDidLoad(bool v)
        {
            try
            {
                //Getting Screen height and width
                nfloat ScreenHeight = UIScreen.MainScreen.Bounds.Height;
                nfloat ScreenWidth  = UIScreen.MainScreen.Bounds.Width;
                //Caliculating height for profile background image
                nfloat probackimgheight = (ScreenHeight - 100) / 3;
                nfloat imgprofile       = 120;
                nfloat Space            = 30;
                nfloat strtx            = 90;
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyBoardDownNotification);
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardUpNotification);

                pickerDataModel = new StatePickerDataModel();
                //pickerDataModel.Items.Add("Select your state");
                pickerDataModel.Items.Add("AL");
                pickerDataModel.Items.Add("AK");
                pickerDataModel.Items.Add("AZ");
                pickerDataModel.Items.Add("AR");
                pickerDataModel.Items.Add("CA");
                pickerDataModel.Items.Add("CO");
                pickerDataModel.Items.Add("CT");
                pickerDataModel.Items.Add("DE");
                pickerDataModel.Items.Add("FL");
                pickerDataModel.Items.Add("GA");
                pickerDataModel.Items.Add("HI");
                pickerDataModel.Items.Add("ID");
                pickerDataModel.Items.Add("IL");
                pickerDataModel.Items.Add("IN");
                pickerDataModel.Items.Add("IA");
                pickerDataModel.Items.Add("KS");
                pickerDataModel.Items.Add("KY");
                pickerDataModel.Items.Add("LA");
                pickerDataModel.Items.Add("ME");
                pickerDataModel.Items.Add("MD");
                pickerDataModel.Items.Add("MA");
                pickerDataModel.Items.Add("MI");
                pickerDataModel.Items.Add("MN");
                pickerDataModel.Items.Add("MS");
                pickerDataModel.Items.Add("MO");
                pickerDataModel.Items.Add("MT");
                pickerDataModel.Items.Add("NE");
                pickerDataModel.Items.Add("NV");
                pickerDataModel.Items.Add("NH");
                pickerDataModel.Items.Add("NJ");
                pickerDataModel.Items.Add("NM");
                pickerDataModel.Items.Add("NY");
                pickerDataModel.Items.Add("NC");
                pickerDataModel.Items.Add("ND");
                pickerDataModel.Items.Add("OH");
                pickerDataModel.Items.Add("OK");
                pickerDataModel.Items.Add("OR");
                pickerDataModel.Items.Add("PA");
                pickerDataModel.Items.Add("RI");
                pickerDataModel.Items.Add("SC");
                pickerDataModel.Items.Add("SD");
                pickerDataModel.Items.Add("TN");
                pickerDataModel.Items.Add("TX");
                pickerDataModel.Items.Add("UT");
                pickerDataModel.Items.Add("VT");
                pickerDataModel.Items.Add("VA");
                pickerDataModel.Items.Add("WA");
                pickerDataModel.Items.Add("WV");
                pickerDataModel.Items.Add("WI");
                pickerDataModel.Items.Add("WY");

                StoreDataModel = new StorePickerDataModel();
                StoreDataModel.Items.Add("Select your store");
                StoreDataModel.Items.Add("Wall");
                StoreDataModel.Items.Add("Pt. Pleasant Beach");
                StoreDataModel.Items.Add("All");

                BTProgressHUD.Dismiss();

                //Background image controller
                UIImageView backgroud = new UIImageView();
                backgroud.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, probackimgheight - 20);
                backgroud.Image = new UIImage("proback.png");
                backgroud.UserInteractionEnabled = false;

                nfloat x = (ScreenWidth / 2) - (imgprofile / 2);
                x = x - 10;
                nfloat y = ((backgroud.Frame.Height) / 2) - 30;

                UIBotton btnImageBack = new UIBotton
                {
                    UserInteractionEnabled = false,
                    Frame           = new CGRect(x, y + 10, imgprofile + 20, imgprofile + 20),
                    BackgroundColor = UIColor.Black
                };
                imgprofilepic = new UIImageView
                {
                    Frame           = new CGRect(x + 10, y + 20, imgprofile, imgprofile),
                    BackgroundColor = UIColor.White
                };
                imgprofilepic.Image = new UIImage("Images/loadin.png");

                btnChange = new UIButton
                {
                    Frame = new CGRect(x + (imgprofilepic.Frame.Width - 10), y + (imgprofilepic.Frame.Height), 30, 30)
                };

                UIImage imgbtnCam = UIImage.FromFile("edit.png");
                imgbtnCam = ResizeImage(imgbtnCam, 25, 25);
                btnChange.SetImage(imgbtnCam, UIControlState.Normal);
                btnChange.SetBackgroundImage(imgbtnCam, UIControlState.Normal);
                //btnChange.BackgroundColor = UIColor.Blue;
                ScreenWidth  = 25;
                ScreenHeight = UIScreen.MainScreen.Bounds.Width - (strtx + 10);
                y            = y + imgprofilepic.Bounds.Height + 50;

                UILabel lblName = new UILabel
                {
                    Text  = "Name:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtName = new UITextField
                {
                    Frame       = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    Placeholder = "E.g. John Doe",
                    BorderStyle = UITextBorderStyle.RoundedRect,
                    Font        = UIFont.FromName("HelveticaNeue", 13f)
                                  //UserInteractionEnabled=true
                };
                txtName.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblEmail = new UILabel
                {
                    Text  = "Email:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                //y = y + lblEmail.Bounds.Height;
                txtEmail = new UITextField
                {
                    Placeholder  = "E.g. [email protected]",
                    Frame        = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.EmailAddress,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnabled=true
                };
                txtEmail.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblMobile = new UILabel
                {
                    Text  = "Mobile:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };

                txtFirst3 = new UITextField
                {
                    Placeholder = "123",
                    //Text="123",
                    Frame        = new CGRect(strtx, y, 50, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnabled = true
                };
                //strtx = strtx + 10;
                UILabel symIphon1 = new UILabel
                {
                    Text  = "-",
                    Frame = new CGRect(strtx + 50, y, 10, ScreenWidth)
                };
                txtSecond3 = new UITextField
                {
                    Placeholder = "456",
                    //Text="123",
                    Frame        = new CGRect(strtx + 60, y, 50, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                };
                UILabel symIphon2 = new UILabel
                {
                    Text  = "-",
                    Frame = new CGRect(strtx + 110, y, 10, ScreenWidth)
                };
                txtLast4 = new UITextField
                {
                    Placeholder = "7890",
                    //Text="1234",
                    Frame        = new CGRect(strtx + 120, y, UIScreen.MainScreen.Bounds.Width - (strtx + 130), ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnable
                };
                txtLast4.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                txtFirst3.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                txtSecond3.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblAddress = new UILabel
                {
                    Text  = "Address:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtAddress = new UITextField
                {
                    Placeholder = "E.g. 1600 Pennsylvania Ave NW",
                    Frame       = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    BorderStyle = UITextBorderStyle.RoundedRect,
                    Font        = UIFont.FromName("HelveticaNeue", 13f)
                };
                txtAddress.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblState = new UILabel
                {
                    Text  = "State:",
                    Frame = new CGRect(10, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                stpicker.Frame = new CGRect(strtx, y, 50, 90);
                //stpicker.BackgroundColor = UIColor.LightGray;
                stpicker.Model = pickerDataModel;
                //stpicker.Hidden = true;

                //
                nfloat  zipx       = strtx + 80;
                UILabel lblZipcode = new UILabel
                {
                    Text  = "Zipcode:",
                    Frame = new CGRect(zipx, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtZipcode = new UITextField
                {
                    Placeholder            = "E.g. 08632",
                    Frame                  = new CGRect(zipx + 70, y + 25, 80, ScreenWidth),
                    BorderStyle            = UITextBorderStyle.RoundedRect,
                    UserInteractionEnabled = true,
                    KeyboardType           = UIKeyboardType.NumberPad,
                    Font = UIFont.FromName("HelveticaNeue", 13f)
                };
                txtZipcode.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + 90;
                //y = y + Space;
                UILabel lblCardExpiry = new UILabel
                {
                    Text  = "Expiry:",
                    Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                UILabel lblCardDate = new UILabel
                {
                    Frame = new CGRect((UIScreen.MainScreen.Bounds.Width / 2) + 70, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue", 13f)
                };
                //y = y + Space;
                UILabel lblcardnumber = new UILabel
                {
                    Text  = "Card #:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                UILabel CardNumer = new UILabel
                {
                    Frame = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue", 13f)
                };
                y = y + Space;
                UILabel lblMystore = new UILabel
                {
                    Text  = "My Store:",
                    Frame = new CGRect(10, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                StorePicker.Frame = new CGRect(strtx, y, UIScreen.MainScreen.Bounds.Width - (strtx + 10), 90);
                //StorePicker.BackgroundColor = UIColor.LightGray;
                StorePicker.Hidden = false;
                y         = y + 90;
                btnUpdate = new UIButton();
                btnUpdate.SetTitle("Update", UIControlState.Normal);
                btnUpdate.Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2 - 25, y, 100, 30);
                btnUpdate.SetTitleColor(UIColor.White, UIControlState.Normal);
                btnUpdate.BackgroundColor     = UIColor.Purple;
                btnUpdate.Font                = UIFont.FromName("HelveticaNeue-Bold", 16f);
                btnUpdate.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                StorePicker.Model             = StoreDataModel;
                Scroll = new UIScrollView
                {
                    Frame            = new CGRect(0, 0, View.Frame.Width, View.Frame.Height),
                    ContentSize      = new CGSize(View.Frame.Width, View.Frame.Height),
                    BackgroundColor  = UIColor.White,
                    AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
                };
                UITapGestureRecognizer taps = new UITapGestureRecognizer();
                taps.CancelsTouchesInView = false;
                taps.AddTarget(() => Scroll.EndEditing(true));

                if (CurrentUser.RetreiveUserId() == 0)
                {
                    Scroll.AddSubview(stpicker);
                    Scroll.AddSubview(StorePicker);
                    StorePicker.UserInteractionEnabled = false;
                    stpicker.UserInteractionEnabled    = false;
                    txtName.UserInteractionEnabled     = false;
                    txtEmail.UserInteractionEnabled    = false;
                    txtFirst3.UserInteractionEnabled   = false;
                    txtSecond3.UserInteractionEnabled  = false;
                    txtLast4.UserInteractionEnabled    = false;
                    txtAddress.UserInteractionEnabled  = false;
                    txtZipcode.UserInteractionEnabled  = false;
                    btnChange.UserInteractionEnabled   = false;
                    btnUpdate.UserInteractionEnabled   = false;
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "This feature is allowed only for VIP Card holders",
                        //Message = "Coming Soon..."
                    };

                    alert.AddButton("OK");
                    alert.AddButton("Log in");
                    alert.AddButton("Know more");
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 1)
                        {
                            CurrentUser.Clear();
                            LoginViewController yourController = new LoginViewController();
                            yourController.nav      = NavCtrl;
                            yourController.RootTabs = CurrentUser.RootTabs;
                            NavCtrl.PushViewController(yourController, false);
                        }
                    };
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 2)
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                        }
                    };
                    alert.Show();
                }
                else
                {
                    Scroll.AddSubview(stpicker);
                    Scroll.AddSubview(StorePicker);
                    DownloadAsync();
                    cRes = svc.GetCustomerDetails(CurrentUser.RetreiveUserId()).Result;
                    if (cRes.customer.CardNumber != null && cRes.customer.CardNumber != "")
                    {
                        name          = cRes.customer.FirstName + " " + cRes.customer.LastName;
                        name          = name.Trim();
                        txtName.Text  = name;
                        txtEmail.Text = cRes.customer.Email;
                        if (cRes.customer.PhoneNumber != null && cRes.customer.PhoneNumber != "")
                        {
                            //if (cRes.customer.PhoneNumber.Length != 10)
                            //{
                            //Console.WriteLine(cRes.customer.PhoneNumber);
                            txtFirst3.Text = cRes.customer.PhoneNumber.Substring(0, 3);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(0, 3));
                            txtSecond3.Text = cRes.customer.PhoneNumber.Substring(3, 3);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(3, 3));
                            txtLast4.Text = cRes.customer.PhoneNumber.Substring(6);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(6));
                            //}
                        }
                        CardNumer.Text   = cRes.customer.CardNumber;
                        lblCardDate.Text = cRes.customer.ExpireDate.ToString("MM-dd-yyyy");
                        txtZipcode.Text  = cRes.customer.Zip;
                        string state = cRes.customer.State;
                        if (pickerDataModel.Items.Contains(state))
                        {
                            int i = pickerDataModel.Items.FindIndex(n => n == state);
                            stpicker.Select(i, 0, false);
                        }
                        int prefStore = cRes.customer.PreferredStore;
                        StorePicker.Select(prefStore, 0, false);
                        txtAddress.Text = cRes.customer.Address1 + cRes.customer.Address2 + cRes.customer.City;
                        txtZipcode.AccessibilityScroll(UIAccessibilityScrollDirection.Up);
                        btnChange.TouchUpInside += (sender, e) =>
                        {
                            try
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Please choose an option to upload profile picture",
                                    //Message = "Coming Soon..."
                                };
                                alert.AddButton("Cancel");
                                alert.AddButton("Camera");
                                alert.AddButton("Gallery");
                                alert.Clicked += (senderalert, buttonArgs) =>
                                {
                                    if (buttonArgs.ButtonIndex == 1)
                                    {
                                        try
                                        {
                                            IsCameraAuthorized();
                                            TweetStation.Camera.TakePicture(this, (obj) =>
                                            {
                                                var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
                                                var meta  = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
                                                UploadProfilePic(photo);
                                            });
                                        }
                                        catch (Exception exe)
                                        {
                                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                        }
                                    }
                                };
                                alert.Clicked += (senderalert, buttonArgs) =>
                                {
                                    if (buttonArgs.ButtonIndex == 2)
                                    {
                                        imagePicker                       = new UIImagePickerController();
                                        imagePicker.SourceType            = UIImagePickerControllerSourceType.PhotoLibrary;
                                        imagePicker.MediaTypes            = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                                        imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                                        imagePicker.Canceled             += Handle_Canceled;
                                        NavCtrl.PresentModalViewController(imagePicker, true);
                                    }
                                };
                                alert.Show();
                            }
                            catch (Exception exe)
                            {
                                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                            }
                        };

                        btnUpdate.TouchUpInside += async delegate
                        {
                            string txtMobilenumber = txtFirst3.Text + txtSecond3.Text + txtLast4.Text;
                            if (txtMobilenumber.Length != 10)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Phone number is invalid", 3000);
                            }
                            if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Email is invalid", 3000);
                            }
                            else if ((txtZipcode.Text.Length != 5))
                            {
                                BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid", 3000);
                            }
                            else if (txtFirst3.Text.Length != 3 || txtSecond3.Text.Length != 3 || txtLast4.Text.Length != 4)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Phone number is invalid", 3000);
                            }
                            else
                            {
                                BTProgressHUD.Show("Updating Profile...");
                                LoggingClass.LogInfo("Update button into Profile View", screenid);
                                Customer cust = new Customer();
                                cust.CustomerID = CurrentUser.RetreiveUserId();
                                cust.Address1   = txtAddress.Text;
                                name            = txtName.Text;
                                name            = name.Trim();
                                try
                                {
                                    string[] str1 = name.Split(' ');
                                    if (str1.Length == 2)
                                    {
                                        cust.FirstName = str1[0];
                                        cust.LastName  = str1[1];
                                    }
                                    else
                                    {
                                        cust.FirstName = str1[0] + str1[1];
                                        cust.LastName  = str1[2];
                                    }
                                }
                                catch (Exception exe)
                                {
                                    LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                }
                                cust.Email       = txtEmail.Text;
                                cust.PhoneNumber = txtMobilenumber;

                                if (pickerDataModel.SelectedItem == "AL")
                                {
                                    if (pickerDataModel.Items.Contains(cRes.customer.State))
                                    {
                                        int i = pickerDataModel.Items.FindIndex(n => n == cRes.customer.State);
                                        stpicker.Select(i, 0, false);
                                    }
                                    cust.State = cRes.customer.State;
                                }
                                else
                                {
                                    cust.State = pickerDataModel.SelectedItem;
                                }
                                cust.Zip = txtZipcode.Text;
                                if (StoreDataModel.SelectedItem == 0)
                                {
                                    cust.PreferredStore = cRes.customer.PreferredStore;
                                    StorePicker.Select(cRes.customer.PreferredStore, 0, false);
                                    CurrentUser.PutStore(cust.PreferredStore);
                                }
                                else
                                {
                                    cust.PreferredStore = StoreDataModel.SelectedItem;
                                    CurrentUser.PutStore(cust.PreferredStore);
                                }
                                await svc.UpdateCustomer(cust);

                                BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                            }
                        };
                    }
                    else
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title   = "Sorry",
                            Message = "Something went wrong. We are on it"
                        };

                        alert.AddButton("OK");
                        alert.Show();
                    }
                }

                Scroll.AddGestureRecognizer(taps);
                Scroll.AddSubview(backgroud);
                Scroll.AddSubview(btnImageBack);
                Scroll.AddSubview(imgprofilepic);
                Scroll.AddSubview(btnChange);
                Scroll.AddSubview(lblName);
                Scroll.AddSubview(txtName);
                Scroll.AddSubview(lblEmail);
                Scroll.AddSubview(txtEmail);
                Scroll.AddSubview(lblMobile);
                Scroll.AddSubview(txtFirst3);
                Scroll.AddSubview(symIphon1);
                Scroll.AddSubview(txtSecond3);
                Scroll.AddSubview(symIphon2);
                Scroll.AddSubview(txtLast4);
                Scroll.AddSubview(lblState);
                //Scroll.AddSubview(stpicker);
                Scroll.AddSubview(lblAddress);
                Scroll.AddSubview(txtAddress);
                Scroll.AddSubview(lblZipcode);
                Scroll.AddSubview(txtZipcode);
                //Scroll.AddSubview(StorePicker);
                Scroll.AddSubview(lblMystore);
                Scroll.AddSubview(lblCardExpiry);
                Scroll.AddSubview(lblCardDate);
                Scroll.AddSubview(lblcardnumber);
                Scroll.AddSubview(CardNumer);
                Scroll.AddSubview(btnUpdate);

                //for (int i = 0; i<Scroll.Subviews.Length ; i++)
                //{
                //	nfloat n = Scroll.Subviews[i].Bounds.Height;// Frame.Size.Height;
                //	h = h + n;
                //}
                //Console.WriteLine(h+"\n"+ScreenHeight);
                h = y + 50;
                Scroll.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, h);
                View = (Scroll);
            }
            catch (Exception e)
            {
                UIAlertView alert = new UIAlertView()
                {
                    Title   = "Sorry",
                    Message = "Something went wrong. We are on it"
                };

                alert.AddButton("OK");
                alert.Show();
                LoggingClass.LogError(e.Message, screenid, e.StackTrace);
                //Console.WriteLine(e.Message + "\n" + e.StackTrace);
            }
        }