Example #1
0
 public void Error(string message)
 {
     BTProgressHUD.ShowErrorWithStatus(
         message,
         1200
         );
 }
Example #2
0
        public static IDisposable SubscribeStatus(this IObservable <bool> @this, string message)
        {
            var hud     = new Hud(null);
            var isShown = false;

            var d = @this.Subscribe(x => {
                if (x && !isShown)
                {
                    hud.Show(message);
                }
                else if (!x && isShown)
                {
                    hud.Hide();
                }
                isShown = x;
            }, err => {
                BTProgressHUD.ShowErrorWithStatus(err.Message);
                isShown = false;
            }, () => {
                if (isShown)
                {
                    BTProgressHUD.Dismiss();
                }
            });

            var d2 = Disposable.Create(() =>
            {
                if (isShown)
                {
                    BTProgressHUD.Dismiss();
                }
            });

            return(new CompositeDisposable(d, d2));
        }
        private void PaymentFailure()
        {
            this.PresentedViewController.DismissViewController(true, null);

            BTProgressHUD.ShowErrorWithStatus("Canceled!");
            LeanplumBindings.Leanplum.Track("Purchase canceled", 10);
        }
Example #4
0
        public override void LoadView()
        {
            base.LoadView();
            View.BackgroundColor = UIColor.LightGray;

            MakeButton("Show", () => {
                BTProgressHUD.Show();
                KillAfter();
            });

            MakeButton("Show Message", () => {
                BTProgressHUD.Show(status: "Processing your image");
                KillAfter();
            });

            MakeButton("Show Success", () => {
                BTProgressHUD.ShowSuccessWithStatus("Great success!");
            });

            MakeButton("Show Fail", () => {
                BTProgressHUD.ShowErrorWithStatus("Oh, thats bad");
            });

            MakeButton("Toast", () => {
                BTProgressHUD.ShowToast("Hello from the toast", showToastCentered: false);
            });


            MakeButton("Dismiss", () => {
                BTProgressHUD.Dismiss();
            });

            MakeButton("Progress", () => {
                progress = 0;
                BTProgressHUD.Show("Hello!", progress);
                if (timer != null)
                {
                    timer.Invalidate();
                }
                timer = NSTimer.CreateRepeatingTimer(0.5f, delegate {
                    progress += 0.1f;
                    if (progress > 1)
                    {
                        timer.Invalidate();
                        timer = null;
                        BTProgressHUD.Dismiss();
                    }
                    else
                    {
                        BTProgressHUD.Show("Hello!", progress);
                    }
                });
                NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
            });

            MakeButton("Dismiss", () => {
                BTProgressHUD.Dismiss();
            });
        }
Example #5
0
        async partial void LeftGate_TouchUpInside(UIButton sender)
        {
            BTProgressHUD.Show("Contacting Gates...", maskType: ProgressHUD.MaskType.Gradient);
            APISignInHelper signIn = new APISignInHelper();

            if (string.IsNullOrWhiteSpace(Settings.AuthToken))
            {
                await signIn.SignIn(Keys.Email, Keys.Password);

                BTProgressHUD.Dismiss();
            }
            else
            {
                if (TokenValidator.HasExpired(Settings.AuthToken))
                {
                    if (await signIn.SignIn(Keys.Email, Keys.Password))
                    {
                        APIDeviceHelper sendMessage = new APIDeviceHelper();

                        if (await sendMessage.SendDeviceMessage(Strings.deviceId, Strings.left_gpio_pin, Strings.mode, Strings.left_max_ticks, Strings.left_time_span))
                        {
                            BTProgressHUD.Dismiss();
                            BTProgressHUD.ShowSuccessWithStatus("Left Gate Toggled", 1000);
                        }
                        else
                        {
                            BTProgressHUD.Dismiss();
                            BTProgressHUD.ShowErrorWithStatus(Settings.ErrorMessage, 1000);
                        }
                    }
                    else
                    {
                        BTProgressHUD.Dismiss();
                        BTProgressHUD.ShowErrorWithStatus(Settings.ErrorMessage, 1000);
                    }
                }
                else
                {
                    APIDeviceHelper sendMessage = new APIDeviceHelper();

                    if (await sendMessage.SendDeviceMessage(Strings.deviceId, Strings.left_gpio_pin, Strings.mode, Strings.left_max_ticks, Strings.left_time_span))
                    {
                        BTProgressHUD.Dismiss();
                        BTProgressHUD.ShowSuccessWithStatus("Left Gate Toggled", 1000);
                    }
                    else
                    {
                        BTProgressHUD.Dismiss();
                        BTProgressHUD.ShowErrorWithStatus(Settings.ErrorMessage, 1000);
                    }
                }
            }
        }
 public override void ViewDidLoad()
 {
     try
     {
         //   this.NavigationItem.SetRightBarButtonItem(
         //	new UIBarButtonItem(UIBarButtonSystemItem.Action, (sender, args) => {
         //       // button was clicked
         //})
         //, true);
         ServiceWrapper svc = new ServiceWrapper();
         myData = svc.GetItemLists(storeId, CurrentUser.RetreiveUserId()).Result;
         if (myData.ItemList.Count != 0)
         {
             this.CollectionView.Add(refreshControl);
             refreshControl.ValueChanged += (rcSender, e) =>
             {
                 //Refresh this view
                 myData = svc.GetItemLists(storeId, CurrentUser.RetreiveUserId()).Result;
                 CollectionView.ReloadData();
                 refreshControl.EndRefreshing();
             };
             BTProgressHUD.Dismiss();
             this.View.BackgroundColor           = new UIColor(256, 256, 256, 0.8f);
             this.CollectionView.BackgroundColor = UIColor.White;
             CollectionView.RegisterClassForCell(typeof(APLCollectionViewCell), APLCollectionViewCell.Key);
         }
         else
         {
             this.View.BackgroundColor           = new UIColor(256, 256, 256, 0.8f);
             this.CollectionView.BackgroundColor = UIColor.White;
             string _name = null;
             if (storeId == 3)
             {
                 _name = LoggingClass.txtstore3;
             }
             UIAlertView alert = new UIAlertView()
             {
                 Title   = _name + " Store",
                 Message = "Coming Soon"
             };
             alert.AddButton("OK");
             alert.Show();
         }
     }
     catch (Exception ex)
     {
         BTProgressHUD.ShowErrorWithStatus("Something went wrong,We're on it.");
         LoggingClass.LogError(ex.ToString(), screen, ex.StackTrace);
     }
 }
		public async void EmailVerification()
		{
			try
			{
				DeviceToken Dt = new DeviceToken();
				if (CurrentUser.GetId() != null)
				{
					Dt = await svc.VerifyMail(CurrentUser.GetId());
				}
				if (Dt.VerificationStatus == 1)
				{
					CurrentUser.Store(cr.customer.CustomerID.ToString(), cr.customer.FirstName + cr.customer.LastName);
					CurrentUser.PutStore(cr.customer.PreferredStore);
					if (RootTabs == null || _window == null)
					{
						RootTabs = CurrentUser.RootTabs;
						_window = CurrentUser.window;
						nav = new UINavigationController(RootTabs);
						AddNavigationButtons(nav);
						_window.RootViewController = nav;
						LoggingClass.LogInfo("The User logged in with user id: " + CurrentUser.RetreiveUserId(), screenid);
					}
					else
					{
						nav = new UINavigationController(RootTabs);
						AddNavigationButtons(nav);
						_window.RootViewController = nav;
						LoggingClass.LogInfo("The User logged in with user id: " + CurrentUser.RetreiveUserId(), screenid);
					}
					BTProgressHUD.Dismiss();
				}
				else
				{
					try
					{
						BTProgressHUD.ShowErrorWithStatus("Your email is not verified plesase check email and verify.", 5000);
						View.AddSubview(btnResend);
					}
					catch (Exception ex)
					{
						LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
					}
				}
			}
			catch (Exception Exe)
			{
				LoggingClass.LogError(Exe.Message, screenid, Exe.StackTrace);
			}
		}
Example #8
0
        public static void ReloadData()
        {
            if (DataLoading != null)
            {
                DataLoading(null, null);
            }

            BTProgressHUD.Show("Loading data", -1, BTProgressHUD.MaskType.Black);

            try {
                var client  = new RestClient("http://api.twitter.com/1/");
                var request = new RestRequest("statuses/user_timeline.json?screen_name={name}&count=200", Method.GET);
                request.AddUrlSegment("name", "MarsWxReport");
                client.ExecuteAsync(request, response => {
                    try {
                        var arr = JArray.Parse(response.Content);
                        foreach (var item in arr)
                        {
                            if (ProfilePic == null)
                            {
                                LoadImage(item["user"]["profile_image_url"].Value <string>());
                            }
                            ReadTweet(item["text"].Value <string>(), item["id_str"].Value <string>(), DateTime.ParseExact(item["created_at"].Value <string>(), "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture));
                        }

                        if (DataLoaded != null)
                        {
                            DataLoaded(null, new BoolEventArgs(true));
                        }
                        BTProgressHUD.ShowSuccessWithStatus("Data loaded!");
                        Sys.Timeout(1, () => BTProgressHUD.Dismiss());
                    } catch {
                        if (DataLoaded != null)
                        {
                            DataLoaded(null, new BoolEventArgs(false));
                        }
                        BTProgressHUD.ShowErrorWithStatus("Something went wrong :(\nTry again after a while!");
                        Sys.Timeout(1, () => BTProgressHUD.Dismiss());
                    }
                });
            } catch (Exception ex) {
                if (DataLoaded != null)
                {
                    DataLoaded(null, new BoolEventArgs(false));
                }
                BTProgressHUD.ShowErrorWithStatus("Something went wrong :(\nTry again after a while!");
                Sys.Timeout(1, () => BTProgressHUD.Dismiss());
            }
        }
Example #9
0
 public override void ViewDidLoad()
 {
     base.View              = new UIWebView();
     this.View.LoadStarted += delegate {
         UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
     };
     this.View.LoadFinished += delegate {
         UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
         BTProgressHUD.Dismiss();
     };
     this.View.LoadError += delegate {
         BTProgressHUD.ShowErrorWithStatus("An error occurred loading the web page. Please ensure you're connected to the internet and try again later.", 3000);
     };
     base.ViewDidLoad();
     Theme.Configure(View);
 }
        public void SendInvites()
        {
            try
            {
                var lstContactNumbers = new List <string>();
                lstContactNumbers.Add(_PhoneContactIOSModel.PhoneNumbers);
                BTProgressHUD.Show("Sending Invite", maskType: ProgressHUD.MaskType.Black);

                if (lstContactNumbers.Count == 0)
                {
                    new UIAlertView("Alert", "Contact Number Not Available", null, "OK", null).Show();
                    return;
                }

                var smsController = new MFMessageComposeViewController();
                if (MFMessageComposeViewController.CanSendText)
                {
                    smsController.Body       = "Hey! I just installed InPower, with  messaging & all of my favorite Book Intrest on one app. Download it now at https://play.google.com/store/apps/details?id=thethiinker.inPower.app";
                    smsController.Recipients = lstContactNumbers.ToArray();
                    smsController.Finished  += (object sender, MFMessageComposeResultEventArgs e) =>
                    {
                        if (e.Result == MessageComposeResult.Sent)
                        {
                            BTProgressHUD.ShowSuccessWithStatus("Invite has been sent", 2000);
                        }
                        else
                        {
                            new UIAlertView("Alert", e.Result.ToString(), null, "OK", null).Show();
                        }
                        this.uIViewController.DismissViewController(false, HandleAction);
                    };
                    this.uIViewController.PresentViewController(smsController, true, null);
                }
                BTProgressHUD.Dismiss();
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                CommonHelper.PrintException("Err sending social invite", ex);
                BTProgressHUD.Dismiss();
                BTProgressHUD.ShowErrorWithStatus("Unable to send Invites.", 1500);
            }
        }
        private async void PaymentSuccess(string nonce)
        {
            try
            {
                int?i = null;
                Console.WriteLine(i.Value.ToString());
            }
            catch (Exception ex)
            {
                Insights.Report(ex);
            }


            BTProgressHUD.Show("Contacting server!");
            this.PresentedViewController.DismissViewController(true, null);

            var endpoint = string.Format("{0}/payment/purchase", Constants.ServerApiAddress);
            var payload  = new PaymentRequest
            {
                Amount = 1,
                Price  = 10,
                Email  = this.UserEmail,
                Nonce  = nonce
            };

            var response = await HttpRequestHelper.Post <PaymentResponse>(endpoint, payload);

            if (response.IsSuccess)
            {
                BTProgressHUD.ShowSuccessWithStatus("Payment success!");
                LeanplumBindings.Leanplum.Track("Purchase success", 10);
            }
            else
            {
                BTProgressHUD.ShowErrorWithStatus("Oh noez!");
            }
        }
Example #12
0
        public override void LoadView()
        {
            base.LoadView();
            View.BackgroundColor = UIColor.LightGray;

            MakeButton("Run first - off main thread", () =>
            {
                //this must be the first one to run.
                // once BTProgressHUD.ANTYTHING has been called once on the UI thread,
                // it'll be setup. So this is an initial call OFF the main thread.
                // Should except in debug.
                var task = Task.Factory.StartNew(() =>
                {
                    try
                    {
                        BTProgressHUD.Show();
                        KillAfter();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                });
            });

            MakeButton("Show", () =>
            {
                BTProgressHUD.Show();
                KillAfter();
            });

            MakeButton("Cancel problem 3", () =>
                       BTProgressHUD.Show("Cancel", () => KillAfter(), "Cancel and text")
                       );

            MakeButton("Cancel problem 2", () =>
                       BTProgressHUD.Show("Cancel", () => KillAfter())
                       );

            MakeButton("Cancel problem", () =>
                       BTProgressHUD.Show("Cancel", () => KillAfter(), "This is a multilinetext\nSome more text\n more text\n and again more text")
                       );

            MakeButton("Show Message", () =>
            {
                BTProgressHUD.Show("Processing your image", -1, ProgressHUD.MaskType.Black);
                KillAfter();
            });

            MakeButton("Show Success", () =>
            {
                BTProgressHUD.ShowSuccessWithStatus("Great success!");
            });

            MakeButton("Show Fail", () =>
            {
                BTProgressHUD.ShowErrorWithStatus("Oh, thats bad");
            });

            MakeButton("Toast", () =>
            {
                BTProgressHUD.ShowToast("Hello from the toast", showToastCentered: false, timeoutMs: 1000);
            });


            MakeButton("Dismiss", () =>
            {
                BTProgressHUD.Dismiss();
            });

            MakeButton("Progress", () =>
            {
                progress = 0;
                BTProgressHUD.Show("Hello!", progress);
                if (timer != null)
                {
                    timer.Invalidate();
                }
                timer = NSTimer.CreateRepeatingTimer(0.5f, delegate
                {
                    progress += 0.1f;
                    if (progress > 1)
                    {
                        timer.Invalidate();
                        timer = null;
                        BTProgressHUD.Dismiss();
                    }
                    else
                    {
                        BTProgressHUD.Show("Hello!", progress);
                    }
                });
                NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
            });

            MakeButton("Dismiss", () =>
            {
                BTProgressHUD.Dismiss();
            });
        }
Example #13
0
 public override void ShowError(string message, int timeoutMillis)
 => BTProgressHUD.ShowErrorWithStatus(message, timeoutMillis);
Example #14
0
		public async void EmailVerification(Boolean start)
		{
			try
			{
				DeviceToken Dt = new DeviceToken();
				if (CurrentUser.GetId() != null)
				{
					Dt = await svc.VerifyMail(CurrentUser.GetId());
					try
					{
						if (cr.customer == null)
						{
							cr = await svc.GetCustomerDetails(Convert.ToInt32(CurrentUser.GetId()));
						}
					}
					catch (Exception exe)
					{
						//LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
					}
				}
				if (Dt.VerificationStatus == 1)
				{
					CurrentUser.Store(cr.customer.CustomerID.ToString(), cr.customer.FirstName + cr.customer.LastName);
					CurrentUser.PutStore(cr.customer.PreferredStore);
					if (RootTabs == null || _window == null)
					{
						RootTabs = CurrentUser.RootTabs;
						_window = CurrentUser.window;
						nav = new UINavigationController(RootTabs);
						AddNavigationButtons(nav);
						_window.RootViewController = nav;
						LoggingClass.LogInfo("The User logged in with user id: " + CurrentUser.RetreiveUserId(), screenid);
					}
					else
					{
						nav = new UINavigationController(RootTabs);
						AddNavigationButtons(nav);
						_window.RootViewController = nav;
						LoggingClass.LogInfo("The User logged in with user id: " + CurrentUser.RetreiveUserId(), screenid);
					}
					BTProgressHUD.Dismiss();
				}
				else
				{
					if (start == false)
					{
						try
						{
							BTProgressHUD.ShowErrorWithStatus("Your email is not verified plesase check email and verify.", 5000);
							View.AddSubview(btnResend);
						}
						catch (Exception ex)
						{
							//LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
						}
					}
				}
			}
			catch (Exception Exe)
			{
					//UIAlertView alert = new UIAlertView()
					//{
					//Title = Exe.Message+"\n"+Exe.StackTrace,
					//	//Message = "Coming Soon..."
					//};

					//alert.AddButton("OK");
					//alert.Show();
				LoggingClass.LogError(Exe.Message, screenid, Exe.StackTrace);
			}
		}
Example #15
0
 public static void ShowFailure(string text)
 {
     ProgressHUD.Shared.HudBackgroundColour = BackgroundTint;
     BTProgressHUD.ShowErrorWithStatus(text);
 }
Example #16
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);
            }
        }
        private async void BtnSend_TouchUpInside(object sender, EventArgs e)
        {
            if (string.Empty.Equals(txtCode.Text))
            {
                Utils.ShowToast("Please fill in the code", 3000);
            }
            else if (txtCode.Text.Length != 4)
            {
                Utils.ShowToast("Please fill in the 4-digit code", 3000);
            }
            else if (string.Empty.Equals(txtPassword.Text))
            {
                Utils.ShowToast("Please fill in the new password", 3000);
            }
            else if (string.Empty.Equals(txtConfirmPassword.Text))
            {
                Utils.ShowToast("Please fill in the password confirmation", 3000);
            }
            else if (!txtPassword.Text.Equals(txtConfirmPassword.Text))
            {
                Utils.ShowToast("Passwords must match", 3000);
            }
            else
            {
                try
                {
                    BTProgressHUD.Show("Validating...", -1, ProgressHUD.MaskType.Clear);

                    DateTime dt  = DateTime.ParseExact(NSUserDefaults.StandardUserDefaults.StringForKey("AskkerPwdTimeStamp"), "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
                    DateTime now = DateTime.Now;

                    TimeSpan span = now.Subtract(dt);

                    if (!txtCode.Text.Equals(NSUserDefaults.StandardUserDefaults.StringForKey("AskkerPwdCode")))
                    {
                        BTProgressHUD.ShowErrorWithStatus("Invalid code", 3000);
                    }
                    else if (span.Seconds > 300)
                    {
                        BTProgressHUD.ShowErrorWithStatus("Code expired, please request another code.", 3000);
                    }

                    SetPasswordModel model = new SetPasswordModel(Email, txtPassword.Text, txtConfirmPassword.Text);

                    await new LoginManager().SetPasswordFromApp(model);

                    BTProgressHUD.ShowSuccessWithStatus("Everything OK!\nPlease login");

                    NSUserDefaults.StandardUserDefaults.RemoveObject("AskkerPwdCode");
                    NSUserDefaults.StandardUserDefaults.RemoveObject("AskkerPwdTimeStamp");

                    var loginController = this.Storyboard.InstantiateViewController("LoginController");
                    if (loginController != null)
                    {
                        this.NavigationController.PushViewController(loginController, true);
                    }
                }
                catch (Exception ex)
                {
                    BTProgressHUD.Dismiss();

                    Utils.ShowAlertOk("Something went wrong", ex.Message);
                }
            }
        }
 public override void ShowError(string message, int timeoutMillis)
 {
     UIApplication.SharedApplication.InvokeOnMainThread(() =>
                                                        BTProgressHUD.ShowErrorWithStatus(message, timeoutMillis)
                                                        );
 }
Example #19
0
 public void ShowError()
 {
     BTProgressHUD.ShowErrorWithStatus("");
 }
        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);
            }
        }
Example #21
0
 public void ShowErrorMessage(string message)
 {
     BTProgressHUD.ShowErrorWithStatus(message);
 }
Example #22
0
 public void ShowError(string text)
 {
     BTProgressHUD.ShowErrorWithStatus(text);
 }
 public override void ShowError(string message, int timeoutMillis)
 {
     BTProgressHUD.ShowErrorWithStatus(message, timeoutMillis);
     //this.ShowWithOverlay(timeoutMillis, () => BTProgressHUD.ShowErrorWithStatus(message, timeoutMillis));
     //this.ShowWithOverlay(timeoutMillis, () => BTProgressHUD.ShowImage(UIImage.FromBundle("icon-error"), message, timeoutMillis));
 }
Example #24
0
        //TODO: ShowContinuousProgress

        public override void ShowError(string message = null, MaskType mask = MaskType.None, TimeSpan?timeout = default(TimeSpan?), Action clickCallback = null, string cancelCaption = null, Action cancelCallback = null)
        {
            BTProgressHUD.ShowErrorWithStatus(message, timeout.HasValue ? timeout.Value.TotalMilliseconds : 1000);
        }
Example #25
0
 public void DisplayError(string message)
 {
     BTProgressHUD.ShowErrorWithStatus(message);
 }
Example #26
0
 public static void ShowErrorWithStatus(string status, double timeoutMs)
 {
     BTProgressHUD.ShowErrorWithStatus(status, timeoutMs);
 }
Example #27
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (ViewModel.LoadingIdentityProviders)
            {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                BTProgressHUD.Show("Loading Providers...");
            }

            var bindings = this.CreateInlineBindingTarget <DefaultIdentityProviderCollectionViewModel>();

            if (_loginDetailSection == null)
            {
                _loginDetailSection = new Section("Log in details")
                {
                    new StringElement("Logged in with: ")
                    .Bind(bindings, element => element.Value, vm => vm.LoggedInProvider),
                    new StringElement("Log out")
                    {
                        ShouldDeselectAfterTouch = true
                    }.Bind(bindings, element => element.SelectedCommand, vm => vm.LogOutCommand)
                };
            }

            Root = new RootElement("Log in")
            {
                new BindableSection <CustomStringElement>("Log in using")
                .Bind(bindings, element => element.SelectedCommand, vm => vm.LoginSelectedIdentityProviderCommand)
                .Bind(bindings, element => element.ItemsSource, vm => vm.IdentityProviders),
            };

            //Section Visible is not bindable :'(
            if (ViewModel.IsLoggedIn)
            {
                if (!Root.Sections.Contains(_loginDetailSection))
                {
                    Root.Add(_loginDetailSection);
                }
            }

            _loggedInToken = ViewModel.WeakSubscribe(() => ViewModel.IsLoggedIn, (s, e) =>
            {
                if (ViewModel.IsLoggedIn)
                {
                    if (!Root.Sections.Contains(_loginDetailSection))
                    {
                        Root.Add(_loginDetailSection);
                    }
                }
                else if (Root.Sections.Contains(_loginDetailSection))
                {
                    Root.Remove(_loginDetailSection);
                }
            });

            _loadingToken = ViewModel.WeakSubscribe(() => ViewModel.LoadingIdentityProviders,
                                                    (sender, args) => InvokeOnMainThread(() =>
            {
                if (ViewModel.LoadingIdentityProviders)
                {
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                    if (BTProgressHUD.IsVisible)
                    {
                        BTProgressHUD.Dismiss();
                    }
                    BTProgressHUD.Show("Loading Providers...");
                }
                else
                {
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                    if (BTProgressHUD.IsVisible)
                    {
                        BTProgressHUD.Dismiss();
                    }

                    if (!_manualRefresh)
                    {
                        LoginDefaultProvider();
                    }

                    _manualRefresh = false;
                }
            }));

            ViewModel.LoginError += (s, e) =>
            {
                if (BTProgressHUD.IsVisible)
                {
                    BTProgressHUD.Dismiss();
                }
                BTProgressHUD.ShowErrorWithStatus(e.Message, 4000);
            };

            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Refresh", UIBarButtonItemStyle.Plain,
                                                                    (s, e) =>
            {
                ViewModel.RefreshIdentityProvidersCommand.Execute(null);
                _manualRefresh = true;
            });
        }
Example #28
0
 public static void ShowFailure(string text)
 {
     BTProgressHUD.ShowErrorWithStatus(text);
 }
Example #29
0
 public override void ShowError(string message)
 {
     BTProgressHUD.ShowErrorWithStatus(message, DisplayTime * 1000);     // sec * ms
 }