bitwarden-android/src/App/Controls/FormEntryCell.cs

59 lines
1.7 KiB
C#
Raw Normal View History

using System;
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class FormEntryCell : ExtendedViewCell
{
2016-06-28 03:56:59 +03:00
public FormEntryCell(string labelText, Keyboard entryKeyboard = null, bool IsPassword = false, VisualElement nextElement = null, bool useLabelAsPlaceholder = false)
{
2016-06-28 03:56:59 +03:00
if(!useLabelAsPlaceholder)
{
2016-06-28 03:56:59 +03:00
Label = new Label
{
Text = labelText,
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
VerticalOptions = LayoutOptions.Start,
Style = (Style)Application.Current.Resources["text-muted"]
};
}
Entry = new ExtendedEntry
{
Keyboard = entryKeyboard,
2016-05-17 06:54:24 +03:00
HasBorder = false,
VerticalOptions = LayoutOptions.CenterAndExpand,
2016-06-17 07:01:25 +03:00
IsPassword = IsPassword
};
2016-06-28 03:56:59 +03:00
if(useLabelAsPlaceholder)
{
Entry.Placeholder = labelText;
}
if(nextElement != null)
{
Entry.ReturnType = Enums.ReturnType.Next;
Entry.Completed += (object sender, EventArgs e) => { nextElement.Focus(); };
}
var stackLayout = new StackLayout
{
Padding = new Thickness(15, 10)
};
2016-06-28 03:56:59 +03:00
if(!useLabelAsPlaceholder)
{
stackLayout.Children.Add(Label);
}
stackLayout.Children.Add(Entry);
View = stackLayout;
}
public Label Label { get; private set; }
public ExtendedEntry Entry { get; private set; }
}
}