1using System.Windows.Input;
2using Microsoft.Maui.Controls.Shapes;
4using PathShape = Microsoft.Maui.Controls.Shapes.Path;
10 private readonly
Border innerBorder;
11 private readonly Grid innerGrid;
12 private readonly PathShape innerPath;
13 private readonly PathShape clickablePath;
14 private readonly
Entry innerEntry;
75 propertyChanged: (bindable, oldValue, newValue) =>
77 ((
CompositeEntry)bindable).OnClickablePathDataPropertyChanged((Geometry)oldValue, (Geometry)newValue);
97 propertyChanged: (bindable, oldValue, newValue) =>
99 ((CompositeEntry)bindable).OnKeyboardPropertyChanged((Keyboard)oldValue, (Keyboard)newValue);
119 propertyChanged: (bindable, oldValue, newValue) =>
121 ((
CompositeEntry)bindable).OnBorderStylePropertyChanged((Style)oldValue, (Style)newValue);
141 propertyChanged: (bindable, oldValue, newValue) =>
143 ((
CompositeEntry)bindable).OnStackSpacingPropertyChanged((
double)oldValue, (double)newValue);
163 propertyChanged: (bindable, oldValue, newValue) =>
165 ((
CompositeEntry)bindable).OnPathDataPropertyChanged((Geometry)oldValue, (Geometry)newValue);
185 propertyChanged: (bindable, oldValue, newValue) =>
187 ((
CompositeEntry)bindable).OnPathStylePropertyChanged((Style)oldValue, (Style)newValue);
206 defaultValue:
string.Empty,
207 defaultBindingMode: BindingMode.TwoWay);
225 defaultValue:
string.Empty,
226 propertyChanged: (bindable, oldValue, newValue) =>
228 ((
CompositeEntry)bindable).OnEntryHintPropertyChanged((
string)oldValue, (string)newValue);
248 propertyChanged: (bindable, oldValue, newValue) =>
250 ((
CompositeEntry)bindable).OnEntryStylePropertyChanged((Style)oldValue, (Style)newValue);
270 propertyChanged: (bindable, oldValue, newValue) =>
272 ((
CompositeEntry)bindable).OnReturnCommandPropertyChanged((ICommand)oldValue, (ICommand)newValue);
292 propertyChanged: (bindable, oldValue, newValue) =>
294 ((
CompositeEntry)bindable).OnIsPasswordPropertyChanged((
bool)oldValue, (bool)newValue);
314 propertyChanged: (bindable, oldValue, newValue) =>
316 ((
CompositeEntry)bindable).OnIsReadOnlyPropertyChanged((
bool)oldValue, (bool)newValue);
335 defaultValue:
string.Empty,
336 propertyChanged: (bindable, oldValue, newValue) =>
338 ((
CompositeEntry)bindable).OnPlaceholderPropertyChanged((
string)oldValue, (string)newValue);
357 defaultValue: Colors.Black,
358 propertyChanged: (bindable, oldValue, newValue) =>
360 ((CompositeEntry)bindable).OnTextColorPropertyChanged((Color)oldValue, (Color)newValue);
392 this.innerPath =
new PathShape
394 VerticalOptions = LayoutOptions.Center,
395 IsVisible = this.PathData !=
null,
398 Aspect = Stretch.Uniform
401 this.clickablePath =
new PathShape
403 VerticalOptions = LayoutOptions.Center,
404 IsVisible = this.ClickablePathData !=
null,
407 Aspect = Stretch.Uniform
410 TapGestureRecognizer tapGestureRecognizer =
new TapGestureRecognizer();
411 tapGestureRecognizer.Tapped += (s, e) =>
416 this.clickablePath.GestureRecognizers.Add(tapGestureRecognizer);
418 this.innerEntry =
new Entry
420 VerticalOptions = LayoutOptions.Center,
421 HorizontalOptions = LayoutOptions.Fill,
422 BackgroundColor = this.BackgroundColor,
426 this.innerEntry.Completed += this.InnerEntry_Completed;
428 this.innerGrid =
new Grid
430 HorizontalOptions = LayoutOptions.Fill,
433 new ColumnDefinition { Width = GridLength.Auto },
434 new ColumnDefinition { Width = GridLength.Star },
435 new ColumnDefinition { Width = GridLength.Auto },
439 new RowDefinition { Height = GridLength.Auto },
443 this.innerGrid.Add(this.innerPath, 0, 0);
444 this.innerGrid.Add(this.innerEntry, 1, 0);
445 this.innerGrid.Add(this.clickablePath, 2, 0);
447 this.innerBorder =
new Border
450 Content = this.innerGrid,
451 BackgroundColor = this.BackgroundColor
454 this.Content = this.innerBorder;
457 this.innerEntry.SetBinding(
Entry.TextProperty,
new Binding(nameof(this.
EntryData), source:
this, mode: BindingMode.TwoWay));
458 this.innerEntry.SetBinding(
Entry.KeyboardProperty,
new Binding(nameof(this.
Keyboard), source:
this));
459 this.innerEntry.SetBinding(
Entry.PlaceholderProperty,
new Binding(nameof(this.
Placeholder), source:
this));
460 this.innerEntry.SetBinding(
Entry.IsPasswordProperty,
new Binding(nameof(this.
IsPassword), source:
this));
461 this.innerEntry.SetBinding(
Entry.IsReadOnlyProperty,
new Binding(nameof(this.
IsReadOnly), source:
this));
462 this.innerEntry.SetBinding(
Entry.ReturnCommandProperty,
new Binding(nameof(this.
ReturnCommand), source:
this));
463 this.innerEntry.SetBinding(
Entry.StyleProperty,
new Binding(nameof(this.
EntryStyle), source:
this));
464 this.innerEntry.SetBinding(
Entry.TextColorProperty,
new Binding(nameof(this.
TextColor), source:
this));
467 this.innerEntry.Focused += this.OnEntryFocused;
468 this.innerEntry.Unfocused += this.OnEntryUnfocused;
471 private void OnKeyboardPropertyChanged(
Keyboard oldValue,
Keyboard newValue)
473 this.innerEntry.Keyboard = newValue;
476 private void OnBorderStylePropertyChanged(Style oldValue, Style newValue)
478 this.innerBorder.Style = newValue;
481 private void OnStackSpacingPropertyChanged(
double oldValue,
double newValue)
483 this.innerGrid.ColumnSpacing = (this.innerPath.IsVisible || this.clickablePath.IsVisible) ? newValue : 0;
486 private void OnPathDataPropertyChanged(Geometry oldValue, Geometry newValue)
488 this.innerPath.Data = newValue;
489 this.innerPath.IsVisible = newValue !=
null;
490 this.innerGrid.ColumnSpacing = (this.innerPath.IsVisible || this.clickablePath.IsVisible) ? this.
StackSpacing : 0;
493 private void OnClickablePathDataPropertyChanged(Geometry oldValue, Geometry newValue)
495 this.clickablePath.Data = newValue;
496 this.clickablePath.IsVisible = newValue !=
null;
497 this.innerGrid.ColumnSpacing = (this.innerPath.IsVisible || this.clickablePath.IsVisible) ? this.
StackSpacing : 0;
500 private void OnPathStylePropertyChanged(Style oldValue, Style newValue)
502 this.innerPath.Style = newValue;
503 this.clickablePath.Style = newValue;
506 private void OnEntryHintPropertyChanged(
string oldValue,
string newValue)
508 this.innerEntry.Placeholder = newValue;
511 private void OnEntryStylePropertyChanged(Style oldValue, Style newValue)
513 this.innerEntry.Style = newValue;
516 private void OnReturnCommandPropertyChanged(ICommand oldValue, ICommand newValue)
518 this.innerEntry.ReturnCommand = newValue;
521 private void OnIsPasswordPropertyChanged(
bool oldValue,
bool newValue)
523 this.innerEntry.IsPassword = newValue;
526 private void OnIsReadOnlyPropertyChanged(
bool oldValue,
bool newValue)
528 this.innerEntry.IsReadOnly = newValue;
531 private void OnPlaceholderPropertyChanged(
string oldValue,
string newValue)
533 this.innerEntry.Placeholder = newValue;
536 private void OnTextColorPropertyChanged(Color oldValue, Color newValue)
538 this.innerEntry.TextColor = newValue;
541 private void OnEntryFocused(
object sender, FocusEventArgs e)
549 private void OnEntryUnfocused(
object sender, FocusEventArgs e)
557 private void InnerEntry_Completed(
object sender, EventArgs e)
561 this.Completed?.Invoke(sender, e);
569 public override string ToString()
571 return this.innerEntry.Text;
Base class that references services in the app.
static ILogService LogService
Log service.
static readonly BindableProperty PathClickedCommandProperty
Bindable property for the command to be executed when the clickable PathData is tapped.
string EntryData
Gets or sets the data for the Entry.
static readonly BindableProperty PathDataProperty
Bindable property for the PathData to be displayed.
Geometry ClickablePathData
Gets or sets the clickable PathData to be displayed.
Keyboard Keyboard
Gets or sets the Keyboard type for the Entry.
bool IsReadOnly
Gets or sets whether the Entry is read-only.
double StackSpacing
Gets or sets the spacing between elements in the stack.
string Placeholder
Gets or sets the placeholder text for the Entry.
Style BorderStyle
Gets or sets the style for the Border.
string EntryHint
Gets or sets the hint (placeholder) for the Entry.
static readonly BindableProperty FocusedCommandProperty
Bindable property for the command to be executed when the Entry gains focus.
static readonly BindableProperty EntryDataProperty
Bindable property for the Entry data.
ICommand ReturnCommand
Gets or sets the command executed when the return key is pressed.
static readonly BindableProperty IsPasswordProperty
Bindable property for IsPassword.
ICommand UnfocusedCommand
Gets or sets the command to be executed when the Entry loses focus.
Entry Entry
Embedded Entry control.
Style EntryStyle
Gets or sets the style for the Entry.
static readonly BindableProperty ReturnCommandProperty
Bindable property for the return command.
static readonly BindableProperty EntryStyleProperty
Bindable property for the Entry style.
CompositeEntry()
Initializes a new instance of the CompositeEntry class.
ICommand PathClickedCommand
Gets or sets the command to be executed when the clickable PathData is tapped.
Border Border
Embedded Border encapsulating the Entry.
Color TextColor
Gets or sets the text color for the Entry.
static readonly BindableProperty ClickablePathDataProperty
Bindable property for the clickable PathData to be displayed.
ICommand FocusedCommand
Gets or sets the command to be executed when the Entry gains focus.
static readonly BindableProperty PlaceholderProperty
Bindable property for the Entry placeholder.
EventHandler Completed
Occurs when the user finalizes the text in an entry with the return key.
static readonly BindableProperty UnfocusedCommandProperty
Bindable property for the command to be executed when the Entry loses focus.
Geometry PathData
Gets or sets the PathData to be displayed.
static readonly BindableProperty StackSpacingProperty
Bindable property for the spacing between elements in the stack.
bool IsPassword
Gets or sets whether the Entry should mask the input.
Style PathStyle
Gets or sets the style for the Path.
static readonly BindableProperty PathStyleProperty
Bindable property for the Path style.
static readonly BindableProperty EntryHintProperty
Bindable property for the Entry hint (placeholder).
static readonly BindableProperty BorderStyleProperty
Bindable property for the border style.
static readonly BindableProperty IsReadOnlyProperty
Bindable property for IsReadOnly.
static readonly BindableProperty KeyboardProperty
Bindable property for the Keyboard type.
static readonly BindableProperty TextColorProperty
Bindable property for the Entry text color.