public override void ViewDidLoad() {
            base.ViewDidLoad();
            
            _MainSection = new Section() {
                new ActivityElement()
            };
            Root = new RootElement("Markers") {
                _MainSection
            };

            // Simple demo of a progress HUD. Doesn't actually do anything useful.
            // Added after question from audience.
            MTMBProgressHUD progress = new MTMBProgressHUD() {
                DimBackground = true,
                LabelText = "Doing something.",
            };
            View.Add(progress);
            progress.Show(animated: true);
            Task.Factory.StartNew(() => {
                Thread.Sleep(2000);
                InvokeOnMainThread(() => {
                    progress.Hide(animated: true);
                });
            });

            mapController = new MapViewController();
            mapController.NewMarkerCreated += (object sender, MarkerAddedEventArgs e) => {
                InvokeOnMainThread(() => {
                    _Database.SaveMarker(e.MarkerInfo);
                    RefreshMarkers();
                });
            };
            RefreshMarkers();
        }
        private async Task ConnectToRelay()
        {
            bool connected = false;

            var waitIndicator = new MTMBProgressHUD (View) 
            {
                LabelText = "Connecting...",
                DimBackground = true,
                AnimationType = MBProgressHUDAnimation.MBProgressHUDAnimationZoomIn,
                Mode = MBProgressHUDMode.Indeterminate,
                MinShowTime = 0,
                RemoveFromSuperViewOnHide = true
            };
            View.AddSubview(waitIndicator);
            waitIndicator.Show(animated: true);

            try
            {
                var prefs = NSUserDefaults.StandardUserDefaults;
                
				connected = await _remote.Connect(prefs.StringForKey("RelayServerUrl"), 
				                                  prefs.StringForKey("RemoteGroup"), 
				                                  prefs.StringForKey("HubName"));
            }
            catch (Exception)
            {
            }
            finally
            {
                waitIndicator.Hide(animated: true);
            }

            ShowMessage(connected ? "Connected!" : "Unable to connect");
        }
		public override async void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			View.BackgroundColor = UIColor.White;
			Title = "Qualifications";

			if (_apiController == null) {
				_apiController = new ApiController ();
			}
				
			var hud = new MTMBProgressHUD (View) {
				LabelText = "Loading...",
				RemoveFromSuperViewOnHide = true
			};

			View.AddSubview (hud);
			hud.Show (animated: true);


			// Retrieve list of Qualifications
			List<string> listOfQualifications = await _apiController.GetQualifications ();


			hud.Hide (animated: true, delay: 0);

			TableView.Source = new TableSource (listOfQualifications.ToArray(), this);

			// Remove extraneous blank rows 
			TableView.TableFooterView = new UIView ();

			// Shorten separator line
			TableView.SeparatorInset = new UIEdgeInsets(0, 3, 0, 20);

		}
		async partial void LoginButtonClicked (Foundation.NSObject sender){
			View.EndEditing(true);
			string username = StringUtils.TrimWhiteSpaceAndNewLine(UsernameTextField.Text);
			string password = StringUtils.TrimWhiteSpaceAndNewLine(PasswordTextField.Text);

			if(!StringUtils.IsValidUsername(username) || !StringUtils.IsValidPassword(password)){
				FailBecuaseInvalidInput();
				return;
			}

			var hud = new MTMBProgressHUD (View) {
				LabelText = Strings.signing_in,
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview (hud);
			hud.Show (true);


			try{
				bool result = await TenServices.Login(username, password);

				if(!result){
					UIAlertController AlertController = UIAlertController.Create(Strings.invalid_login, Strings.invalid_login, UIAlertControllerStyle.Alert);
					AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
					PresentViewController(AlertController, true, null);
					return;
				}

				NSUserDefaults.StandardUserDefaults.SetInt((nint)Globe.SharedInstance.User.idUser, "iduser");
				NSUserDefaults.StandardUserDefaults.SetString(Globe.SharedInstance.User.username, "username");
				NSUserDefaults.StandardUserDefaults.SetString(Globe.SharedInstance.User.password, "password");
				((AppDelegate)UIApplication.SharedApplication.Delegate).createTabBarController();
				((AppDelegate)UIApplication.SharedApplication.Delegate).Window.RootViewController = ((AppDelegate)UIApplication.SharedApplication.Delegate).TabBarController;
				((AppDelegate)UIApplication.SharedApplication.Delegate).Window.MakeKeyAndVisible();
			}
			catch(RESTError error){
				Console.WriteLine(error.Message);
				if(error.StatusCode == 400 || error.StatusCode == -1){
					UIAlertController AlertController = UIAlertController.Create(Strings.invalid_login, error.Message, UIAlertControllerStyle.Alert);
					AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
					PresentViewController(AlertController, true, null);
					return;
				}

				UIAlertController AlertController2 = UIAlertController.Create(Strings.invalid_login, Strings.invalid_login, UIAlertControllerStyle.Alert);
				AlertController2.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
				PresentViewController(AlertController2, true, null);
				return;
			} finally {
				hud.Hide(true);
			}
		}
        private void Foo()
        {
            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Waiting...",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(hud);

            hud.Show(animated: true);
            hud.Hide(animated: true, delay: 5);
        }
Example #6
0
        public static void ShowMessage(this UIView parentView, string message)
        {
            var hud = new MTMBProgressHUD (parentView)
            {
                DetailsLabelText = message,
                RemoveFromSuperViewOnHide = true,
                DimBackground = false,
                AnimationType = MBProgressHUDAnimation.MBProgressHUDAnimationZoomIn,
                Mode = MBProgressHUDMode.Text,
                UserInteractionEnabled = true
            };
            parentView.AddSubview (hud);

            hud.Show (true);
            hud.Hide (true, 1.5);
        }
        public static void ShowMessage(UIView view , string message)
        {
            hud = new MTMBProgressHUD (view){ LabelText = message};
            view.AddSubview  (hud);
            hud.Mode = MBProgressHUDMode.CustomView;
            hud.CustomView = new UIImageView (UIImage.FromBundle ("37x-Checkmark.png"));

            // Register for DidHide Event so we can remove it from the window at the right time
            hud.DidHide += HandleDidHide;

            // Add information to your HUD
            hud.LabelText = message;

            // Show the HUD
            hud.Show(true);

            // Hide the HUD after 2 seconds
            hud.Hide (true,2);

        }
		private async Task ReloadMovieTable()
		{
			string url = this.TabBarItem.Title == "Movie" ? $"http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?apikey={apikey}&limit=20" 
				: $"http://api.rottentomatoes.com/api/public/v1.0/lists/dvds/top_rentals.json?apikey={apikey}&limit=20";
			
			var hud = new MTMBProgressHUD (View) {
				LabelText = "Loading...",
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview (hud);
			hud.Show (true);

			List<Movie> movies = await Utility.GetMovieData (url);
			this.MovieTable.Source = new MovieTableController(movies, this);

			this.MovieTable.ReloadData ();
			SearchCollectionView searchview = (SearchCollectionView)this.TabBarController.ViewControllers [2];
			searchview.allData = movies;
			hud.Hide (true);
		}
		async partial void sendButtonClicked (Foundation.NSObject sender)
		{
			if (String.IsNullOrEmpty (codeTextField.Text) || String.IsNullOrEmpty (passwordTextField.Text) || String.IsNullOrEmpty (confirmPasswordTextField.Text) || passwordImageView.Tag != 1 || confirmPasswordImageView.Tag != 1) {
				return;
			}

			var hud = new MTMBProgressHUD (View) {
				LabelText = Strings.loading,
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview (hud);
			hud.Show (true);

			try {
				bool result = await TenServices.ResetPassword (email, codeTextField.Text, passwordTextField.Text);


				if (!result) {
					UIAlertController AlertController = UIAlertController.Create (Strings.error, Strings.invalid_email, UIAlertControllerStyle.Alert);
					AlertController.AddAction (UIAlertAction.Create (Strings.ok, UIAlertActionStyle.Default, null));
					PresentViewController (AlertController, true, null);
					return;
				}


				NSUserDefaults.StandardUserDefaults.SetInt ((nint)Globe.SharedInstance.User.idUser, "iduser");
				NSUserDefaults.StandardUserDefaults.SetString (Globe.SharedInstance.User.username, "username");
				NSUserDefaults.StandardUserDefaults.SetString (Globe.SharedInstance.User.password, "password");//todo wtf
				((AppDelegate)UIApplication.SharedApplication.Delegate).createTabBarController ();
				((AppDelegate)UIApplication.SharedApplication.Delegate).Window.RootViewController = ((AppDelegate)UIApplication.SharedApplication.Delegate).TabBarController;
				((AppDelegate)UIApplication.SharedApplication.Delegate).Window.MakeKeyAndVisible ();
			} catch (RESTError error) {
				if (error.StatusCode == 400 || error.StatusCode == -1) {
					UIAlertController AlertController = UIAlertController.Create (error.Message, null, UIAlertControllerStyle.Alert);
					AlertController.AddAction (UIAlertAction.Create (Strings.ok, UIAlertActionStyle.Default, null));
					PresentViewController (AlertController, true, null);
				}
			} finally {
				hud.Hide (true);
			}
		}
		void ShowTextOnly ()
		{
			// Show the hud on top most view
			hud = MTMBProgressHUD.ShowHUD(this.navController.View, true);

			// Configure for text only and offset down
			hud.Mode = MBProgressHUDMode.Text;
			hud.LabelText = "Some message...";
			hud.Margin = 10f;
			hud.YOffset = 150f;
			hud.RemoveFromSuperViewOnHide = true;

			hud.Hide(true, 3);
		}
		void ShowWithCustomView ()
		{
			// The hud will dispable all input on the view (use the higest view possible in the view hierarchy)
			hud = new MTMBProgressHUD (this.navController.View);
			navController.View.AddSubview (hud);

			// Set custom view mode
			hud.Mode = MBProgressHUDMode.CustomView;

			// The sample image is based on the work by http://www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/
			// Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators)
			hud.CustomView = new UIImageView (UIImage.FromBundle ("37x-Checkmark.png"));

			// Regiser for DidHide Event so we can remove it from the window at the right time
			hud.DidHide += HandleDidHide;
			
			// Add information to your HUD
			hud.LabelText = "Completed";
			
			// Show the HUD
			hud.Show(true);

			// Hide the HUD after 3 seconds
			hud.Hide (true, 3);
		}
		partial void UserImageButtonClicked (Foundation.NSObject sender)
		{
			ImagePickerViewController imagePicker = new ImagePickerViewController ();
			imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
			imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);
			imagePicker.AllowsEditing = true;
			imagePicker.NavigationBar.TintColor = UIColor.White;
			imagePicker.Canceled += (object se, EventArgs ea) => {
				imagePicker.DismissModalViewController (true);
			};
			imagePicker.FinishedPickingMedia += async (object s, UIImagePickerMediaPickedEventArgs e) => {
				imagePicker.DismissModalViewController(true);

				if (!HasInternet())
				{
					return;
				}

				if (e.Info [UIImagePickerController.MediaType].ToString () == "public.image") {
					newUserImage = e.Info [UIImagePickerController.EditedImage] as UIImage;
					newUserImage = ImageUtils.ReduceSizeIfNeededByWidth(newUserImage, 700);
				}


				if (e.Info [UIImagePickerController.MediaType].ToString () == "public.image") {

					var hud = new MTMBProgressHUD (View) {
						LabelText = Strings.updating_profile,
						RemoveFromSuperViewOnHide = true
					};
					View.AddSubview (hud);
					hud.Show (true);


					try {
						bool result = await TenServices.UpdateUserImage (ImageUtils.ByteArrayFromImage (newUserImage));
						if (result) {
							
							SDImageCache.SharedImageCache.ClearMemory ();
							SDImageCache.SharedImageCache.ClearDisk ();

							await System.Threading.Tasks.Task.Delay (TimeSpan.FromSeconds (2));
							UserImageButton.SetUserImageWithCallback(Globe.SharedInstance.User, delegate {
								hud.Hide(true);
							});

						}
					} catch (RESTError er) {
						Console.WriteLine (er.Message);
						hud.Hide (true);
					}
				}
			};
			NavigationController.PresentModalViewController (imagePicker, true);
		}
        private void ShowMessage(string message) 
        {
            var hud = new MTMBProgressHUD (View) 
            {
                DetailsLabelText = message,
                RemoveFromSuperViewOnHide = true,
                DimBackground = false,
                AnimationType = MBProgressHUDAnimation.MBProgressHUDAnimationZoomIn,
                Mode = MBProgressHUDMode.Text
            };
            View.AddSubview (hud);

            hud.Show (animated: true);
            hud.Hide (animated: true, delay: 1.5);
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			BioTextView.Layer.BorderColor = UIColor.FromRGB (204, 204, 204).CGColor;
			BioTextView.Layer.BorderWidth = 1;
			BioTextView.Layer.CornerRadius = 8;
			BioTextView.ClipsToBounds = true;

			NicknameBackground.Layer.CornerRadius = 8;
			NicknameBackground.ClipsToBounds = true;

			NavigationItem.SetRightBarButtonItem (
				new UIBarButtonItem ("Save", UIBarButtonItemStyle.Plain, async (sender, args) => {
					
					newBio = StringUtils.TrimWhiteSpaceAndNewLine (BioTextView.Text);
					newWebsite = StringUtils.TrimWhiteSpaceAndNewLine (WebsiteTextField.Text);
					newPrivacy = PrivateToggleButton.On;


					var hud = new MTMBProgressHUD (View) {
						LabelText = Strings.updating_profile,
						RemoveFromSuperViewOnHide = true
					};
					View.AddSubview (hud);
					hud.Show (true);

					try {
						bool profileUpdated = await TenServices.UpdateProfile (Globe.SharedInstance.User.username, Globe.SharedInstance.User.password, newBio, newWebsite, newPrivacy);
						if (profileUpdated) {

							Globe.SharedInstance.User.website = newWebsite;
							Globe.SharedInstance.User.description = newBio;
							Globe.SharedInstance.User.isprivate = newPrivacy;

							NSUserDefaults.StandardUserDefaults.SetString (Globe.SharedInstance.User.username, "username");

							UIAlertController AlertController = UIAlertController.Create (Strings.sucess, Strings.sucess_update_profile, UIAlertControllerStyle.Alert);
							AlertController.AddAction (UIAlertAction.Create (Strings.ok, UIAlertActionStyle.Default, delegate {
								NavigationController.PopToRootViewController (true);
							}));
							PresentViewController (AlertController, true, null);
						} else {
							UIAlertController AlertController = UIAlertController.Create (Strings.error, Strings.failed_update_profile, UIAlertControllerStyle.Alert);
							AlertController.AddAction (UIAlertAction.Create (Strings.ok, UIAlertActionStyle.Default, null));
							PresentViewController (AlertController, true, null);
						}
					} catch (RESTError e) {
						if (e.StatusCode == 403) {
							UIAlertController AlertController = UIAlertController.Create (Strings.error, e.Message, UIAlertControllerStyle.Alert);
							AlertController.AddAction (UIAlertAction.Create (Strings.ok, UIAlertActionStyle.Default, null));
							PresentViewController (AlertController, true, null);
						} else {
							UIAlertController AlertController = UIAlertController.Create (Strings.error, Strings.failed_update_profile, UIAlertControllerStyle.Alert);
							AlertController.AddAction (UIAlertAction.Create (Strings.ok, UIAlertActionStyle.Default, null));
							PresentViewController (AlertController, true, null);
						}
					} finally {
						hud.Hide (true);
						SetPageVariables ();
					}
				})
			, true);

			SetPageVariables ();
		}
		async private void BlockOrUnblockUser()
		{
			var hud = new MTMBProgressHUD(View)
			{
				LabelText = (Guest.blocked) ? "Unblocking" : "Blocking",
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview(hud);
			hud.Show(true);

			if (Guest.blocked)
			{
				try
				{
					bool unblocked = await TenServices.UnblockUser(Guest);
					if (unblocked)
					{
						Guest.blocked = false;
						await HeaderViewController.FetchHeaderData();
						await postFeedTableViewController.FetchTableData();
					}
					else {

					}
				}
				catch (RESTError)
				{

				}
			}
			else {
				try
				{
					bool blocked = await TenServices.BlockUser(Guest);
					if (blocked)
					{
						Guest.blocked = true;
						HeaderViewController.TopTimersUserFeedCollectionViewController.CollectionItems = null;
						HeaderViewController.TopTimersUserFeedCollectionViewController.CollectionView.ReloadData();
						await HeaderViewController.FetchHeaderData();
						await postFeedTableViewController.FetchTableData();
					}
				}
				catch (RESTError)
				{

				}

			}

			hud.Hide(true);
		}
		private void ShowClearButton()
		{
			if (NavigationItem.LeftBarButtonItem == null)
			{
				NavigationItem.SetLeftBarButtonItem(
					new UIBarButtonItem(UIBarButtonSystemItem.Trash, (sender, args) =>
					{
						UIAlertController AlertController = UIAlertController.Create(Strings.clear_notificaitons, Strings.clear_notificaions_confirm, UIAlertControllerStyle.Alert);
						AlertController.AddAction(UIAlertAction.Create(Strings.yes, UIAlertActionStyle.Cancel, async delegate (UIAlertAction obj)
						{


							var hud = new MTMBProgressHUD(View)
							{
								LabelText = Strings.clearing_notifications,
								RemoveFromSuperViewOnHide = true
							};
							View.AddSubview(hud);
							hud.Show(true);

							bool result = false;
							try
							{
								await System.Threading.Tasks.Task.Run(() =>
								{
									result = TenServices.MarkAllNotificatiosAsRead(new List<Notification>(notificationFeedTableViewController.TableItems)).Result;
								});
							}
							catch (Exception)
							{

							}
							finally
							{
								notificationFeedTableViewController.TableItems.Clear();
								notificationFeedTableViewController.TableView.ReloadData();
								HideClearButton();
								notificationFeedTableViewController.IfEmpty();
								await notificationFeedTableViewController.FetchTableData();
								ViewUtils.RemoveDotFromTabBarAtIndex(1);
								TenServiceHelper.CheckForNewNotifications();
								hud.Hide(true);
							}

						}));
						AlertController.AddAction(UIAlertAction.Create(Strings.cancel, UIAlertActionStyle.Default, null));
						PresentViewController(AlertController, true, null);
					})
				, true);
			}
		}
		async partial void sendButtonClicked(Foundation.NSObject sender)
		{
			email = StringUtils.TrimWhiteSpaceAndNewLine(emailTextField.Text);

			if (String.IsNullOrEmpty(email))
			{
				return;
			}

			var hud = new MTMBProgressHUD(View)
			{
				LabelText = Strings.loading,
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview(hud);
			hud.Show(true);

			try
			{
				bool result = await TenServices.ForgotPassword(email);

				if (!result)
				{
					UIAlertController AlertController = UIAlertController.Create(Strings.error, Strings.invalid_email, UIAlertControllerStyle.Alert);
					AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
					PresentViewController(AlertController, true, null);
					return;
				}


				SendCodeViewController vc = (SendCodeViewController)NavigationController.Storyboard.InstantiateViewController("SendCodeViewController");
				vc.email = email;
				NavigationController.PushViewController(vc, true);

			}
			catch (RESTError error)
			{
				UIAlertController AlertController = UIAlertController.Create(error.Message, null, UIAlertControllerStyle.Alert);
				AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
				PresentViewController(AlertController, true, null);
			}
			finally
			{
				hud.Hide(true);
			}
		}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			//create waiting hud
			var hud = new MTMBProgressHUD (View) {
				LabelText = "Loading high res image...",
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview (hud);
			hud.Show (animated: true);

			//load app content
			InitiateHttp ();

			//hide hud
			hud.Hide (animated: true, delay: 5);
		}
		//IBActions
		async partial void RegisterButtonClicked(Foundation.NSObject sender)
		{
			hideKeyboard(null);

			if (EmailImageView.Tag != 1 || UsernameImageView.Tag != 1 || PasswordImageView.Tag != 1 || ConfirmPasswordImageView.Tag != 1)
			{
				return;
			}

			string username = StringUtils.TrimWhiteSpaceAndNewLine(UsernameTextField.Text);
			string password = StringUtils.TrimWhiteSpaceAndNewLine(PasswordTextField.Text);
			string email = StringUtils.TrimWhiteSpaceAndNewLine(EmailTextField.Text);


			var hud = new MTMBProgressHUD(View)
			{
				LabelText = Strings.signing_up,
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview(hud);
			hud.Show(true);

			try
			{
				bool result = await TenServices.Register(username, password, email);

				if (!result)
				{
					UIAlertController AlertController = UIAlertController.Create(Strings.invalid_login, Strings.invalid_login, UIAlertControllerStyle.Alert);
					AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
					PresentViewController(AlertController, true, null);
					return;
				}

				NSUserDefaults.StandardUserDefaults.SetInt((nint)Globe.SharedInstance.User.idUser, "iduser");
				NSUserDefaults.StandardUserDefaults.SetString(Globe.SharedInstance.User.username, "username");
				NSUserDefaults.StandardUserDefaults.SetString(Globe.SharedInstance.User.password, "password");//todo wtf
				((AppDelegate)UIApplication.SharedApplication.Delegate).createTabBarController();
				((AppDelegate)UIApplication.SharedApplication.Delegate).Window.RootViewController = ((AppDelegate)UIApplication.SharedApplication.Delegate).TabBarController;
				((AppDelegate)UIApplication.SharedApplication.Delegate).Window.MakeKeyAndVisible();
			}
			catch (RESTError error)
			{
				UIAlertController AlertController = UIAlertController.Create(error.Message, null, UIAlertControllerStyle.Alert);
				AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
				PresentViewController(AlertController, true, null);
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
			}
			finally
			{
				hud.Hide(true);
			}
		}
		async private void ToNewsFeed()
		{

			var hud = new MTMBProgressHUD(View)
			{
				LabelText = Strings.posting,
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview(hud);
			hud.Show(true);

			try
			{
				byte[] myByteArray = null;
				if (captureImage != null)
				{
					captureImage = ImageUtils.FixOrientation(captureImage);
					captureImage = ImageUtils.ReduceSizeIfNeededByWidth(captureImage, 1000);
					myByteArray = ImageUtils.ByteArrayFromImage(captureImage);
				}




				Post result = await TenServices.Post("", myByteArray);

				hud.Hide(true);

				if (result != null)
				{

					FeedUtils.PassPostToAllFeedsIfExistsWithInclude(result, FeedTypeEnum.FeedType.HomeFeed);

					await ((HomeViewController)((UINavigationController)(TabBarController.ViewControllers[0])).ViewControllers[0]).postFeedTableViewController.FetchTableData();
					Master.ResetPostImageConstraints();
					TabBarController.SelectedIndex = 0;
					((AppDelegate)UIApplication.SharedApplication.Delegate).StartTickNotification();
					NavigationController.PopToRootViewController(false);
				}
			}
			catch (RESTError error)
			{
				hud.Hide(true);
				UIAlertController AlertController = UIAlertController.Create(Strings.error, Strings.create_new_post_failed, UIAlertControllerStyle.Alert);
				AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
				PresentViewController(AlertController, true, null);
				Console.WriteLine(error.Message);
				panGesture.Enabled = true;
			}
		}
		async private void ReportPost()
		{
			var hud = new MTMBProgressHUD(View)
			{
				LabelText = Strings.reporting,
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview(hud);
			hud.Show(animated: true);

			try
			{
				bool result = await TenServices.ReportPost(post);
				FeedUtils.DeletePostFromAllFeedsIfExists(post);

				if (result)
				{
					NavigationController.PopViewController(true);
				}
				else {
					FailForUnknownReportPost();
				}
			}
			catch (RESTError)
			{
				FailForUnknownReportPost();
			}
			finally
			{
				hud.Hide(true);
			}
		}
		async private void ReportUser()
		{
			var hud = new MTMBProgressHUD(View)
			{
				LabelText = Strings.reporting,
				RemoveFromSuperViewOnHide = true
			};
			View.AddSubview(hud);
			hud.Show(true);

			try
			{
				bool flagged = await TenServices.ReportUser(Guest);
				if (flagged)
				{
					UIAlertController AlertController = UIAlertController.Create(Strings.sucess, null, UIAlertControllerStyle.ActionSheet);
					AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, (UIAlertAction obj) =>
					{
						hud.Hide(false);
						this.NavigationController.PopViewController(true);
					}));
					PresentViewController(AlertController, true, null);
				}
			}
			catch (RESTError e)
			{

			}
			hud.Hide(true);
		}
		//IBActions
		async partial void addComment(Foundation.NSObject sender)
		{
			string text = StringUtils.TrimWhiteSpaceAndNewLine(inputField.Text);

			if (!String.IsNullOrEmpty(text) && text != Strings.add_a_comment_placeholder)
			{
				addCommentButton.Enabled = false;
				hideKeyboard();

				var hud = new MTMBProgressHUD(View)
				{
					LabelText = Strings.adding_comment,
					RemoveFromSuperViewOnHide = true
				};
				View.AddSubview(hud);
				hud.Show(animated: true);


				try
				{
					Comment res = await TenServices.AddComment(post, text);
					if (res != null)
					{
						TableItems.Add(res);
						tableView.ReloadData();
						IfEmpty();
						inputField.Text = Strings.add_a_comment_placeholder;
						View.EndEditing(true);
						HeaderViewController.HighlightCommentButton();
					}
				}
				catch (RESTError e)
				{
					if (e.Message == "Invalid comment length")
					{
						FailBecauseCommentLength();
					}
				}
				finally
				{
					addCommentButton.Enabled = true;
					hud.Hide(true);
				}
			}
		}
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			Background.Layer.CornerRadius = 8;
			Background.ClipsToBounds = true;


			NavigationItem.SetRightBarButtonItem(
				new UIBarButtonItem("Save", UIBarButtonItemStyle.Plain, async (sender, args) =>
				{

					string error = null;
					if (CurrentPasswordTextField.Text != NSUserDefaults.StandardUserDefaults.StringForKey("password"))
					{
						error = Strings.invalid_password;
					}
					else if (NewPasswordTextField.Text != ConfirmPasswordTextField.Text)
					{
						error = Strings.password_mismatch;
					}
					else if (NewPasswordTextField.Text.Length <= 5)
					{
						error = "Password must be more than 5 characters";
					}
					else if (!Regex.IsMatch(NewPasswordTextField.Text, "[A-Z]"))
					{
						error = "Password must have at least one uppercase letter";
					}
					else if (!Regex.IsMatch(NewPasswordTextField.Text, "[a-z]"))
					{
						error = "Password must have at least one lowercase latter";
					}
					else if (NewPasswordTextField.Text.IndexOfAny("!@#$%^&+=".ToCharArray()) == -1)
					{
						error = "Password must have a special character (!@#$%^&+=)";
					}

					if (!String.IsNullOrEmpty(error))
					{
						UIAlertController AlertController = UIAlertController.Create(Strings.error, error, UIAlertControllerStyle.Alert);
						AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
						PresentViewController(AlertController, true, null);
						return;
					}

					string potentialPassword = NewPasswordTextField.Text;


					var hud = new MTMBProgressHUD(View)
					{
						LabelText = Strings.updating_password,
						RemoveFromSuperViewOnHide = true
					};
					View.AddSubview(hud);
					hud.Show(true);

					try
					{
						bool result = await TenServices.UpdatePassword(Globe.SharedInstance.User.username, potentialPassword);
						if (result)
						{
							Globe.SharedInstance.User.password = potentialPassword;
							NSUserDefaults.StandardUserDefaults.SetString(Globe.SharedInstance.User.password, "password");

							UIAlertController AlertController = UIAlertController.Create(Strings.password_updated, null, UIAlertControllerStyle.Alert);
							AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, delegate
							{
								NavigationController.PopViewController(true);
							}));
							PresentViewController(AlertController, true, null);

						}
						else {
							UIAlertController AlertController = UIAlertController.Create(Strings.failed_update_password, null, UIAlertControllerStyle.Alert);
							AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
							PresentViewController(AlertController, true, null);
						}
					}
					catch (RESTError e)
					{
						UIAlertController AlertController = UIAlertController.Create(Strings.error, e.Message, UIAlertControllerStyle.Alert);
						AlertController.AddAction(UIAlertAction.Create(Strings.ok, UIAlertActionStyle.Default, null));
						PresentViewController(AlertController, true, null);
					}
					finally
					{
						hud.Hide(false);
					}


				})
				, true);
		}