public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); if (ViewModel == null) { ViewModel = new DetailsViewModel(); NavigationItem.RightBarButtonItem = save; } else { this.Title = ViewModel.FirstName; TextEmail.Text = ViewModel.Email; TextFirst.Text = ViewModel.FirstName; TextLast.Text = ViewModel.LastName; TextPhone.Text = ViewModel.Phone; ImagePhoto.SetImage( url: new NSUrl(Gravatar.GetURL(ViewModel.Contact.EmailAddresses[0].Address, 172)), placeholder: UIImage.FromBundle("missing.png") ); NavigationItem.RightBarButtonItem = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationController.NavigationBar.BarStyle = UIBarStyle.Black; save = new UIBarButtonItem(UIBarButtonSystemItem.Save, async(sender, args) => { ViewModel.FirstName = TextFirst.Text.Trim(); ViewModel.LastName = TextLast.Text.Trim(); ViewModel.Email = TextEmail.Text.Trim(); ViewModel.Phone = TextPhone.Text.Trim(); BigTed.BTProgressHUD.Show("Saving contact..."); await ViewModel.SaveContact(); BigTed.BTProgressHUD.Dismiss(); NavigationController.PopToRootViewController(true); }); TextEmail.ShouldReturn += ShouldReturn; TextFirst.ShouldReturn += ShouldReturn; TextPhone.ShouldReturn += ShouldReturn; TextLast.ShouldReturn += ShouldReturn; TextEmail.ValueChanged += (sender, args) => { ImagePhoto.SetImage( url: new NSUrl(Gravatar.GetURL(TextEmail.Text, 172)), placeholder: UIImage.FromBundle("missing.png") ); }; var color = new CGColor(17.0F / 255.0F, 113.0F / 255.0F, 197.0F / 255F); TextEmail.Layer.BorderColor = color; TextFirst.Layer.BorderColor = color; TextPhone.Layer.BorderColor = color; TextLast.Layer.BorderColor = color; ButtonCall.Clicked += (sender, args) => PlaceCall(); NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.DidShowNotification, KeyBoardUpNotification); // Keyboard Down NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification, KeyBoardDownNotification); double min = Math.Min((float)ImagePhoto.Frame.Width, (float)ImagePhoto.Frame.Height); ImagePhoto.Layer.CornerRadius = (float)(min / 2.0); ImagePhoto.Layer.MasksToBounds = false; ImagePhoto.Layer.BorderColor = new CGColor(1, 1, 1); ImagePhoto.Layer.BorderWidth = 3; ImagePhoto.ClipsToBounds = true; }