MobileSearchBar.xaml.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Xamarin.Forms;
  7. using Xamarin.Forms.Xaml;
  8. using XF.Material.Forms.Resources.Typography;
  9. namespace comal.timesheets
  10. {
  11. public class MobileSearchBarTextChangedArgs : EventArgs
  12. {
  13. public string Text { get; private set; }
  14. public MobileSearchBarTextChangedArgs(String text)
  15. {
  16. Text = text;
  17. }
  18. }
  19. public delegate void MobileSearchBatTextChanged(object sender, MobileSearchBarTextChangedArgs args);
  20. [XamlCompilation(XamlCompilationOptions.Compile)]
  21. public partial class MobileSearchBar
  22. {
  23. private static readonly BindableProperty TextBackgroundColorProperty = BindableProperty.Create(
  24. nameof(TextBackgroundColor),
  25. typeof(Color),
  26. typeof(MobileSearchBar),
  27. XF.Material.Forms.Material.Color.Surface);
  28. public Color TextBackgroundColor
  29. {
  30. get => (Color)GetValue(TextBackgroundColorProperty);
  31. set => SetValue(TextBackgroundColorProperty, value);
  32. }
  33. private static readonly BindableProperty TextColorProperty = BindableProperty.Create(
  34. nameof(TextColor),
  35. typeof(Color),
  36. typeof(MobileSearchBar),
  37. XF.Material.Forms.Material.Color.OnSurface);
  38. public Color TextColor
  39. {
  40. get => (Color)GetValue(TextColorProperty);
  41. set => SetValue(TextColorProperty, value);
  42. }
  43. private static readonly BindableProperty TextSizeProperty = BindableProperty.Create(
  44. nameof(TextSize),
  45. typeof(double),
  46. typeof(MobileSearchBar),
  47. 14D);
  48. public double TextSize
  49. {
  50. get => (double)GetValue(TextSizeProperty);
  51. set => SetValue(TextSizeProperty, value);
  52. }
  53. private static readonly BindableProperty PlaceHolderProperty = BindableProperty.Create(
  54. nameof(PlaceHolder),
  55. typeof(String),
  56. typeof(MobileSearchBar)
  57. );
  58. public String PlaceHolder
  59. {
  60. get => (String)GetValue(PlaceHolderProperty);
  61. set => SetValue(PlaceHolderProperty, value);
  62. }
  63. public event MobileSearchBatTextChanged TextChanged;
  64. public MobileSearchBar()
  65. {
  66. InitializeComponent();
  67. }
  68. private void _search_OnTextChanged(object sender, TextChangedEventArgs e)
  69. {
  70. TextChanged?.Invoke(this,new MobileSearchBarTextChangedArgs(e.NewTextValue));
  71. }
  72. }
  73. }