MobileEditorRenderer.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.ComponentModel;
  2. using InABox.Mobile;
  3. using InABox.Mobile.iOS;
  4. using UIKit;
  5. using Xamarin.Forms;
  6. using Xamarin.Forms.Platform.iOS;
  7. [assembly: ExportRenderer(typeof(MobileEditor), typeof(MobileEditorRenderer))]
  8. namespace InABox.Mobile.iOS
  9. {
  10. class MobileEditorRenderer : EditorRenderer
  11. {
  12. public MobileEditorRenderer()
  13. {
  14. UIKeyboard.Notifications.ObserveWillShow((sender, args) =>
  15. {
  16. if (Element != null)
  17. {
  18. Element.Margin = new Thickness(0, 0, 0, args.FrameEnd.Height); //push the entry up to keyboard height when keyboard is activated
  19. }
  20. });
  21. UIKeyboard.Notifications.ObserveWillHide((sender, args) =>
  22. {
  23. if (Element != null)
  24. {
  25. Element.Margin = new Thickness(0); //set the margins to zero when keyboard is dismissed
  26. }
  27. });
  28. }
  29. protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
  30. {
  31. base.OnElementChanged(e);
  32. if (Control != null)
  33. {
  34. Control.Layer.CornerRadius = 5;
  35. Control.TextColor = UIColor.Black;
  36. }
  37. }
  38. // protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
  39. // {
  40. // base.OnElementPropertyChanged(sender, e);
  41. // if (Control != null)
  42. // {
  43. // // just change this statement to the one that works.
  44. // Control.SelectedTextRange = Control.GetTextRange(fromPosition: Control.BeginningOfDocument, toPosition: Control.BeginningOfDocument);
  45. // }
  46. // }
  47. }
  48. }