added image option to form entry cell. Added clear option to extended entry

This commit is contained in:
Kyle Spearrin 2016-06-27 22:17:49 -04:00
parent 54da129887
commit 0cbda0b574
18 changed files with 104 additions and 17 deletions

View file

@ -45,6 +45,7 @@ namespace Bit.App.Controls
public ReturnType? ReturnType { get; set; } public ReturnType? ReturnType { get; set; }
public bool? Autocorrect { get; set; } public bool? Autocorrect { get; set; }
public bool DisableAutocapitalize { get; set; } public bool DisableAutocapitalize { get; set; }
public bool AllowClear { get; set; }
// Need to overwrite default handler because we cant Invoke otherwise // Need to overwrite default handler because we cant Invoke otherwise
public new event EventHandler Completed; public new event EventHandler Completed;

View file

@ -5,7 +5,13 @@ namespace Bit.App.Controls
{ {
public class FormEntryCell : ExtendedViewCell public class FormEntryCell : ExtendedViewCell
{ {
public FormEntryCell(string labelText, Keyboard entryKeyboard = null, bool IsPassword = false, VisualElement nextElement = null, bool useLabelAsPlaceholder = false) public FormEntryCell(
string labelText,
Keyboard entryKeyboard = null,
bool IsPassword = false,
VisualElement nextElement = null,
bool useLabelAsPlaceholder = false,
string imageSource = null)
{ {
if(!useLabelAsPlaceholder) if(!useLabelAsPlaceholder)
{ {
@ -14,7 +20,8 @@ namespace Bit.App.Controls
Text = labelText, Text = labelText,
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
VerticalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start,
Style = (Style)Application.Current.Resources["text-muted"] Style = (Style)Application.Current.Resources["text-muted"],
HorizontalOptions = LayoutOptions.FillAndExpand
}; };
} }
@ -23,7 +30,9 @@ namespace Bit.App.Controls
Keyboard = entryKeyboard, Keyboard = entryKeyboard,
HasBorder = false, HasBorder = false,
VerticalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand,
IsPassword = IsPassword IsPassword = IsPassword,
AllowClear = true,
HorizontalOptions = LayoutOptions.FillAndExpand
}; };
if(useLabelAsPlaceholder) if(useLabelAsPlaceholder)
@ -37,22 +46,53 @@ namespace Bit.App.Controls
Entry.Completed += (object sender, EventArgs e) => { nextElement.Focus(); }; Entry.Completed += (object sender, EventArgs e) => { nextElement.Focus(); };
} }
var stackLayout = new StackLayout var imageStackLayout = new StackLayout
{ {
Padding = new Thickness(15, 10) Padding = new Thickness(15, 10),
Orientation = StackOrientation.Horizontal,
Spacing = 10,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
}; };
if(!useLabelAsPlaceholder) if(imageSource != null)
{ {
stackLayout.Children.Add(Label); var tgr = new TapGestureRecognizer();
tgr.Tapped += Tgr_Tapped;
var theImage = new Image
{
Source = imageSource,
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Center
};
theImage.GestureRecognizers.Add(tgr);
imageStackLayout.Children.Add(theImage);
} }
stackLayout.Children.Add(Entry); var formStackLayout = new StackLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
if(!useLabelAsPlaceholder)
{
formStackLayout.Children.Add(Label);
}
View = stackLayout; formStackLayout.Children.Add(Entry);
imageStackLayout.Children.Add(formStackLayout);
View = imageStackLayout;
} }
public Label Label { get; private set; } public Label Label { get; private set; }
public ExtendedEntry Entry { get; private set; } public ExtendedEntry Entry { get; private set; }
private void Tgr_Tapped(object sender, EventArgs e)
{
Entry.Focus();
}
} }
} }

View file

@ -36,8 +36,10 @@ namespace Bit.App.Pages
private void Init() private void Init()
{ {
PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, useLabelAsPlaceholder: true); PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true,
EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true); useLabelAsPlaceholder: true, imageSource: "lock");
EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry,
entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope");
PasswordCell.Entry.ReturnType = Enums.ReturnType.Go; PasswordCell.Entry.ReturnType = Enums.ReturnType.Go;
PasswordCell.Entry.Completed += Entry_Completed; PasswordCell.Entry.Completed += Entry_Completed;

View file

@ -34,11 +34,11 @@ namespace Bit.App.Pages
private void Init() private void Init()
{ {
PasswordHintCell = new FormEntryCell("Master Password Hint (optional)", useLabelAsPlaceholder: true); PasswordHintCell = new FormEntryCell("Master Password Hint (optional)", useLabelAsPlaceholder: true, imageSource: "lightbulb-o");
ConfirmPasswordCell = new FormEntryCell("Re-type Master Password", IsPassword: true, nextElement: PasswordHintCell.Entry, useLabelAsPlaceholder: true); ConfirmPasswordCell = new FormEntryCell("Re-type Master Password", IsPassword: true, nextElement: PasswordHintCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock");
PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, nextElement: ConfirmPasswordCell.Entry, useLabelAsPlaceholder: true); PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, nextElement: ConfirmPasswordCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock");
NameCell = new FormEntryCell("Your Name", nextElement: PasswordCell.Entry, useLabelAsPlaceholder: true); NameCell = new FormEntryCell("Your Name", nextElement: PasswordCell.Entry, useLabelAsPlaceholder: true, imageSource: "user");
EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: NameCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true); EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: NameCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope");
PasswordHintCell.Entry.ReturnType = Enums.ReturnType.Done; PasswordHintCell.Entry.ReturnType = Enums.ReturnType.Done;
PasswordHintCell.Entry.Completed += Entry_Completed; PasswordHintCell.Entry.Completed += Entry_Completed;
@ -54,7 +54,10 @@ namespace Bit.App.Pages
new TableSection() new TableSection()
{ {
EmailCell, EmailCell,
NameCell, NameCell
},
new TableSection()
{
PasswordCell, PasswordCell,
ConfirmPasswordCell, ConfirmPasswordCell,
PasswordHintCell PasswordHintCell

View file

@ -25,6 +25,11 @@ namespace Bit.iOS.Controls
SetMaxLength(view); SetMaxLength(view);
UpdateKeyboard(); UpdateKeyboard();
if(view.AllowClear)
{
Control.ClearButtonMode = UITextFieldViewMode.WhileEditing;
}
if(view.DisableAutocapitalize) if(view.DisableAutocapitalize)
{ {
Control.AutocapitalizationType = UITextAutocapitalizationType.None; Control.AutocapitalizationType = UITextAutocapitalizationType.None;

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/iOS/Resources/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

BIN
src/iOS/Resources/user.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

View file

@ -400,6 +400,42 @@
<ItemGroup> <ItemGroup>
<BundleResource Include="Resources\eye_slash%402x.png" /> <BundleResource Include="Resources\eye_slash%402x.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\envelope.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\envelope%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\envelope%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\lock%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\lock%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\lock.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\lightbulb-o.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\lightbulb-o%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\lightbulb-o%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\user.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\user%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\user%403x.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>