2016-05-24 04:56:38 +03:00
|
|
|
|
using Bit.App.Enums;
|
|
|
|
|
using System;
|
2016-05-10 06:25:37 +03:00
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Controls
|
|
|
|
|
{
|
|
|
|
|
public class ExtendedEntry : Entry
|
|
|
|
|
{
|
2016-08-14 04:43:15 +03:00
|
|
|
|
public ExtendedEntry()
|
|
|
|
|
{
|
|
|
|
|
if(Device.OS == TargetPlatform.Android)
|
|
|
|
|
{
|
|
|
|
|
PlaceholderColor = Color.FromHex("c7c7cd");
|
|
|
|
|
}
|
2016-11-08 06:07:33 +03:00
|
|
|
|
|
|
|
|
|
IsPasswordFromToggled = IsPassword;
|
2016-08-14 04:43:15 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-10 06:25:37 +03:00
|
|
|
|
public static readonly BindableProperty HasBorderProperty =
|
|
|
|
|
BindableProperty.Create(nameof(HasBorder), typeof(bool), typeof(ExtendedEntry), true);
|
|
|
|
|
|
|
|
|
|
public static readonly BindableProperty HasOnlyBottomBorderProperty =
|
|
|
|
|
BindableProperty.Create(nameof(HasOnlyBottomBorder), typeof(bool), typeof(ExtendedEntry), false);
|
|
|
|
|
|
2016-05-11 05:53:34 +03:00
|
|
|
|
public static readonly BindableProperty BottomBorderColorProperty =
|
|
|
|
|
BindableProperty.Create(nameof(BottomBorderColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
2016-05-10 06:25:37 +03:00
|
|
|
|
|
|
|
|
|
public static readonly BindableProperty MaxLengthProperty =
|
|
|
|
|
BindableProperty.Create(nameof(MaxLength), typeof(int), typeof(ExtendedEntry), int.MaxValue);
|
|
|
|
|
|
|
|
|
|
public bool HasBorder
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)GetValue(HasBorderProperty); }
|
|
|
|
|
set { SetValue(HasBorderProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasOnlyBottomBorder
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)GetValue(HasOnlyBottomBorderProperty); }
|
|
|
|
|
set { SetValue(HasOnlyBottomBorderProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 05:53:34 +03:00
|
|
|
|
public Color BottomBorderColor
|
2016-05-10 06:25:37 +03:00
|
|
|
|
{
|
2016-05-11 05:53:34 +03:00
|
|
|
|
get { return (Color)GetValue(BottomBorderColorProperty); }
|
|
|
|
|
set { SetValue(BottomBorderColorProperty, value); }
|
2016-05-10 06:25:37 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int MaxLength
|
|
|
|
|
{
|
|
|
|
|
get { return (int)GetValue(MaxLengthProperty); }
|
|
|
|
|
set { SetValue(MaxLengthProperty, value); }
|
|
|
|
|
}
|
2016-05-24 04:56:38 +03:00
|
|
|
|
|
|
|
|
|
public ReturnType? ReturnType { get; set; }
|
|
|
|
|
public bool? Autocorrect { get; set; }
|
|
|
|
|
public bool DisableAutocapitalize { get; set; }
|
2016-06-28 05:17:49 +03:00
|
|
|
|
public bool AllowClear { get; set; }
|
2016-05-24 05:50:32 +03:00
|
|
|
|
|
|
|
|
|
// Need to overwrite default handler because we cant Invoke otherwise
|
|
|
|
|
public new event EventHandler Completed;
|
|
|
|
|
|
|
|
|
|
public void InvokeCompleted()
|
|
|
|
|
{
|
2016-05-25 02:06:19 +03:00
|
|
|
|
Completed?.Invoke(this, null);
|
2016-05-24 05:50:32 +03:00
|
|
|
|
}
|
2016-11-08 06:07:33 +03:00
|
|
|
|
|
|
|
|
|
public virtual void InvokeToggleIsPassword()
|
|
|
|
|
{
|
|
|
|
|
if(ToggleIsPassword == null)
|
|
|
|
|
{
|
|
|
|
|
IsPassword = IsPasswordFromToggled = !IsPassword;
|
2016-11-08 06:46:15 +03:00
|
|
|
|
Focus();
|
2016-11-08 06:07:33 +03:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ToggleIsPassword.Invoke(this, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event EventHandler ToggleIsPassword;
|
|
|
|
|
public bool IsPasswordFromToggled { get; set; } = false;
|
2016-05-10 06:25:37 +03:00
|
|
|
|
}
|
|
|
|
|
}
|