public override void ViewDidLoad() { base.ViewDidLoad(); _restActions = new RestActions(); SignUpButton.TouchUpInside += async(e, s) => { var bounds = UIScreen.MainScreen.Bounds; // show the loading overlay on the UI thread using the correct orientation sizing _loadingOverlay = new LoadingOverlay(bounds, "Signing you up..."); // using field from step 2 View.Add(_loadingOverlay); var canregister = CanRegister(); if (canregister) { //proceed to the registration logic var user = await RegisterUserRest(); if (user?.USER_NAME != null) { _loadingOverlay.Hide(); MessagingActions.ShowAlert("Registration Successfull", "Welcome " + user.SURNAME + " Please login and begin ordering"); DismissViewController(true, null); //close the view controller return; } _loadingOverlay.Hide(); //MessagingActions.ShowAlert("Registration not Successfull", "Unable to register, please try again"); } _loadingOverlay.Hide(); }; CancelButton.TouchUpInside += (e, s) => { DismissViewController(true, null); }; #region handle the return actions to clear the on screen keyboard properly //responders to handle keyboard clearing on textfields UserNameTextView.EditingDidEnd += HandleEditingDidEnd; UserNameTextView.Delegate = new CatchEnterDelegate(); SurNameTextView.EditingDidEnd += HandleEditingDidEnd; SurNameTextView.Delegate = new CatchEnterDelegate(); OtherNamesTextView.EditingDidEnd += HandleEditingDidEnd; OtherNamesTextView.Delegate = new CatchEnterDelegate(); EmailTextView.EditingDidEnd += HandleEditingDidEnd; EmailTextView.Delegate = new CatchEnterDelegate(); PhoneTextView.EditingDidEnd += HandleEditingDidEnd; PhoneTextView.Delegate = new CatchEnterDelegate(); PasswordTextField.EditingDidEnd += HandleEditingDidEnd; PasswordTextField.Delegate = new CatchEnterDelegate(); ConfirmPasswordTextField.EditingDidEnd += HandleEditingDidEnd; ConfirmPasswordTextField.Delegate = new CatchEnterDelegate(); #endregion }
public override void RowSelected(UITableView tableView, Foundation.NSIndexPath indexPath) { Order order = GetItem(indexPath.Row); tableView.DeselectRow(indexPath, true); // create the view controller for your initial view - using storyboard, code, etc if (order.PAY_ORDER) { MyCartViewController myCartViewController = _owner.Storyboard.InstantiateViewController("MyCartViewController") as MyCartViewController; //Here you pass the data from the registerViewController to the secondViewController if (myCartViewController == null) { return; } myCartViewController.SetOrderItems(order: order, unpaidOrder: true); _owner.NavigationController.PushViewController(myCartViewController, true); } else { //show the items in the order MessagingActions.ShowAlert("Order Confirmed", "This order has been confirmed, please await delivery from vendor"); } }
private async Task BtnLogin_TouchUpInside(object sender) { //Validate our Username & Password. //This is usually a web service call. try { var bounds = UIScreen.MainScreen.Bounds; // show the loading overlay on the UI thread using the correct orientation sizing _loadPop = new LoadingOverlay(bounds, "Logging you in..."); // using field from step 2 View.Add(_loadPop); if (IsUserNameValid() && IsPasswordValid()) { username = UserNameTextView.Text.Trim(); password = PasswordTextView.Text.Trim(); //We have successfully authenticated a the user, //Now fire our OnLoginSuccess Event. _userModel = await _restActions.LoginUser(username, password); if (_userModel != null) { UserSession.SetUserSession(_userModel); if (UserSession.IsLoggedIn()) { _loadPop.Hide(); OnLoginSuccess?.Invoke(sender, new EventArgs()); } else { var message = "Unable to log you in, please try again"; if (_userModel.message != null) { message = _userModel.message; } _loadPop.Hide(); MessagingActions.ShowAlert("Unable to login", message); } } else { _loadPop.Hide(); MessagingActions.ShowAlert("Login Error", "Incorrect user name or password"); } } else { _loadPop.Hide(); MessagingActions.ShowAlert("Unable to login", "Incorrect user name or password"); } } catch (Exception ex) { Crashes.TrackError(ex); _loadPop.Hide(0); //hide immediatelly } }
//This assumes we have successfully create a new user account //Naturally, you'll add your logic here, but we're ignoring //that for simplicity. private bool CanRegister() { //let us initate the sign up process if (!IsUserNameValid()) { MessagingActions.ShowAlert("Invalid User Name", "Invalid User Name"); return(false); } if (!IsSurnameValid()) { MessagingActions.ShowAlert("Invalid Surname", "Please provide a valid surname"); return(false); } if (!IsOtherNamesValid()) { MessagingActions.ShowAlert("Empty Other Names", "Please provide you other names"); return(false); } if (!IsEmailValid()) { MessagingActions.ShowAlert("Invalid Email", "Please enter correct email address"); return(false); } if (!IsPhoneValid()) { MessagingActions.ShowAlert("Invalid Phone Number", "PLease provide a valid phone number"); return(false); } if (!IsPasswordValid()) { MessagingActions.ShowAlert("Empty Password", "Empty Passwords are not allowed"); return(false); } if (!IsPasswordConfirmed()) { MessagingActions.ShowAlert("Password Do Not Match", "The Passwords do not match, please try again"); return(false); } return(true); }
//Override FinishedLaunching. This executes after the app has started. public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { //set the crash analytics AppCenter.Start("cfa8f1ba-443f-4136-a786-1b8ceabf07d8", typeof(Analytics), typeof(Crashes)); //AppCenter.LogLevel = LogLevel.Verbose; MSAnalytics.SetEnabled(true); //isAuthenticated can be used for an auto-login feature, you'll have to implement this //as you see fit or get rid of the if statement if you want. //first we will check if internet is available if (!AppHelper.HasInternetConnection()) { MessagingActions.ShowAlert("No Internet Connection", "This app requires an active intenet connection to function"); } else { if (!AppHelper.IsNetworkAvailable()) { MessagingActions.ShowAlert("Unstable Network", "Your Network appears to be unstable, app perfomance will be impaired"); } } _isAuthenticated = UserSession.IsLoggedIn(); if (_isAuthenticated) { //We are already authenticated, so go to the main tab bar controller; var tabBarController = GetViewController(MainStoryboard, "MainTabBarController"); SetRootViewController(tabBarController, false); } else { //User needs to log in, so show the Login View Controlller var loginViewController = GetViewController(MainStoryboard, "LoginPageViewController") as LoginPageViewController; if (loginViewController != null) { loginViewController.OnLoginSuccess += LoginViewController_OnLoginSuccess; SetRootViewController(loginViewController, false); } } //Analytics.TrackEvent("Application started logged in status is "+isAuthenticated); return(true); }
public override void ViewDidLoad() { base.ViewDidLoad(); if (_order != null) { if (_totalAmount <= 0) { _totalAmount = _order.ComputeOrderTotal(); } _paymentUssd = $"{_order.USSD_NUMBER}{_totalAmount}#"; Title = "Order Payment"; TxtOrderNumber.Text = _order.ORDER_ID.ToString(); TxtOrderTotal.Text = _totalAmount.ToString("C", CultureInfo.CreateSpecificCulture("en-US")); LblOrderSummary.Text = $"Pay for order number :{_order.ORDER_ID}"; //lblHelpLine.Text = $"Call us on {UserSession.HelpLine()}"; LblUssdNumber.Text = $"Payment Number is :{_paymentUssd}"; BtnPayOrder.SetTitle($"Tap to pay for order number :{_order.ORDER_ID}", UIControlState.Normal); TxtOrderTotal.Enabled = false; TxtOrderNumber.Enabled = false; BtnPayOrder.TouchUpInside += (e, s) => { //let us launch the dialler var launched = _messagingActions.MakePhoneCall(_paymentUssd); if (!launched) { MessagingActions.ShowAlert("Dialler Not opened", "Unable to open dialling keypad on this device"); Analytics.TrackEvent($"Unable to launch dialler for user id {UserSession.GetUserId()}"); } }; BtnClose.TouchUpInside += (e, s) => { //dismiss the view controller DismissModalViewController(true); }; } }
public async Task <User> RegisterUserRest() { User userModel = null; try { var user = new User { USER_NAME = UserNameTextView.Text.Trim(), OTHER_NAMES = OtherNamesTextView.Text.Trim(), SURNAME = SurNameTextView.Text.Trim(), USER_STATUS = true, //(bool)User.ACCOUNT_STATUS.ACTIVE, //user is active or not USER_TYPE = "1", //1 indicates it is a customer LOCATION_ID = "1", //just a random location id ADDRESS = "N/A", EMAIL = EmailTextView.Text.Trim(), MOBILE = PhoneTextView.Text.Trim(), PASSWORD = PasswordTextField.Text.Trim(), RESET_TOKEN = Guid.NewGuid().ToString() //random guid }; userModel = await _restActions.RegisterUser(user); if (userModel != null) { if (userModel.HAS_ERRORS) { var error = userModel.ERROR_LIST[0]; //get only the first error //show the errors if (error.message != null) { MessagingActions.ShowAlert("Unable to register", error.message); } } } } catch (Exception ex) { Crashes.TrackError(ex); } return(userModel); }
public override async void ViewDidLoad() { base.ViewDidLoad(); Title = "My Cart"; restActions = new RestActions(); _minprice = UserSession.MinPrice(); var bounds = UIScreen.MainScreen.Bounds; if (_unpaidOrder == false) { _loadingOverlay = new LoadingOverlay(bounds, "Refreshing Cart..."); View.Add(_loadingOverlay); cartItemList = await LoadCartItems(UserSession.GetUserId()); _loadingOverlay.Hide(0); } _loadingOverlay = new LoadingOverlay(bounds, "Loading Locations and Delivery times..."); View.Add(_loadingOverlay); locationStingList = await LoadLocationList(); deliveryTimeList = await LoadDeliveryTimeList(); _loadingOverlay.Hide(); #pragma warning disable 618 _deliveryAddressActionSheet = new UIActionSheet("Select Delivery Address", null, cancelTitle: "Cancel", destroy: null, other: locationStingList); _deliveryTimeActionSheet = new UIActionSheet("Select Delivery Time", null, cancelTitle: "Cancel", destroy: null, other: deliveryTimeList); #pragma warning restore 618 //set minimum date DateTime date = DateTime.Now; currentNsDate = (NSDate)DateTime.SpecifyKind(date, DateTimeKind.Utc); deliveryDate = currentNsDate.ToString(); //set as default date if (_unpaidOrder) { deliveryDate = _order.ORDER_DATE_TIME.ToString("dd/MM/yyyy"); //"09:35:37" deliveryTime = _order.ORDER_TIME; deliveryLocation = _order.LOCATION.LOCATION_NAME; _selectedLocationId = _order.LOCATION_ID; NSDate orderNsDate = (NSDate)DateTime.SpecifyKind(_order.ORDER_DATE_TIME, DateTimeKind.Utc); ; //set the current values BtnDeliveryAddress.SetTitle(deliveryLocation, UIControlState.Normal); BtnDeliveryTime.SetTitle(deliveryTime, UIControlState.Normal); deliveryDatePicker.SetDate(orderNsDate, true); deliveryDatePicker.MaximumDate = orderNsDate; //btnViewItems.Hidden = true; } /*btnViewItems.TouchUpInside += (e, s) => * { * // create the view controller for your initial view - using storyboard, code, etc * CartItemsViewController cartItemsViewController = this.Storyboard.InstantiateViewController(controllerName) as CartItemsViewController; * if (cartItemsViewController != null) * { * cartItemsViewController.SetCartItems(cartItemList); * NavigationController.PushViewController(cartItemsViewController, true); * } * };*/ BtnDeliveryAddress.TouchUpInside += (e, s) => { _deliveryAddressActionSheet.ShowInView(View); }; BtnDeliveryTime.TouchUpInside += (e, s) => { _deliveryTimeActionSheet.ShowInView(View); }; deliveryDatePicker.ValueChanged += (e, s) => { deliveryDatePicker.MinimumDate = currentNsDate; //set minimum date to current date deliveryDate = deliveryDatePicker.Date.ToString(); }; _deliveryAddressActionSheet.Clicked += (btn_sender, args) => { try { if (args.ButtonIndex >= 0) { var selectedIndex = args.ButtonIndex; deliveryLocation = locationStingList[selectedIndex]; BtnDeliveryAddress.SetTitle(deliveryLocation, UIControlState.Normal); _selectedLocationId = GetLocationId(locationList, deliveryLocation); } Console.WriteLine("{0} Clicked", args.ButtonIndex); } catch (Exception e) { AppCenterLog.Error("ERROR", e.Message, e); } }; _deliveryTimeActionSheet.Clicked += (btn_sender, args) => { try { if (args.ButtonIndex >= 0) { var selectedIndex = args.ButtonIndex; deliveryTime = deliveryTimeList[selectedIndex]; BtnDeliveryTime.SetTitle(deliveryTime, UIControlState.Normal); } Console.WriteLine("{0} Clicked", args.ButtonIndex); } catch (Exception e) { AppCenterLog.Error("ERROR", e.Message, e); } }; BtnPay.TouchUpInside += async(e, s) => { //let us validate the data if (IsLocationSelected() && IsTimeSelected() && IsDateSelected()) { //check minimum purchase price if (_total >= _minprice) { //create new order if (_unpaidOrder) { //let us update the order and proceed OpenCheckout(_order); } else { await CreateOrderFromCart(); } } else { var least = _minprice.ToString("C", CultureInfo.CreateSpecificCulture("en-US")); MessagingActions.ShowAlert("Minimum Price", $"Please make a purchase of at least {least} to be eligible for delivery"); } } else { MessagingActions.ShowAlert("Incomplete Info", "Ensure delivery location,date and time are specified"); } }; }