From 7ce1eec96de6b47b7664bf453675038b7663082c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 23 May 2016 21:56:38 -0400 Subject: [PATCH] ios extended entry options. next button actions for add site page --- src/App/App.csproj | 5 ++-- src/App/Controls/ExtendedEntry.cs | 7 ++++- src/App/Controls/FormEntryCell.cs | 15 ++++++++-- src/App/Enums/ReturnType.cs | 11 ++++++++ src/App/Pages/VaultAddSitePage.cs | 13 +++++---- src/iOS/Controls/ExtendedEntryRenderer.cs | 34 +++++++++++++++++++++++ 6 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 src/App/Enums/ReturnType.cs diff --git a/src/App/App.csproj b/src/App/App.csproj index b4624b49d..5d1dcde99 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -60,6 +60,7 @@ + @@ -221,9 +222,7 @@ AppResources.Designer.cs - - - + diff --git a/src/App/Controls/ExtendedEntry.cs b/src/App/Controls/ExtendedEntry.cs index 600f6bdbe..53d229cd2 100644 --- a/src/App/Controls/ExtendedEntry.cs +++ b/src/App/Controls/ExtendedEntry.cs @@ -1,4 +1,5 @@ -using System; +using Bit.App.Enums; +using System; using Xamarin.Forms; namespace Bit.App.Controls @@ -40,5 +41,9 @@ namespace Bit.App.Controls get { return (int)GetValue(MaxLengthProperty); } set { SetValue(MaxLengthProperty, value); } } + + public ReturnType? ReturnType { get; set; } + public bool? Autocorrect { get; set; } + public bool DisableAutocapitalize { get; set; } } } diff --git a/src/App/Controls/FormEntryCell.cs b/src/App/Controls/FormEntryCell.cs index c1c3e4b4d..04c23457c 100644 --- a/src/App/Controls/FormEntryCell.cs +++ b/src/App/Controls/FormEntryCell.cs @@ -1,10 +1,11 @@ -using Xamarin.Forms; +using System; +using Xamarin.Forms; namespace Bit.App.Controls { public class FormEntryCell : ExtendedViewCell { - public FormEntryCell(string labelText, Keyboard entryKeyboard = null, bool IsPassword = false) + public FormEntryCell(string labelText, Keyboard entryKeyboard = null, bool IsPassword = false, VisualElement nextElement = null) { Label = new Label { @@ -18,9 +19,17 @@ namespace Bit.App.Controls { Keyboard = entryKeyboard, HasBorder = false, - VerticalOptions = LayoutOptions.CenterAndExpand + VerticalOptions = LayoutOptions.CenterAndExpand, + IsPassword = IsPassword, + TextColor = Color.FromHex("333333") }; + if(nextElement != null) + { + Entry.ReturnType = Enums.ReturnType.Next; + Entry.Completed += (object sender, EventArgs e) => { nextElement.Focus(); }; + } + var stackLayout = new StackLayout { Padding = new Thickness(15) diff --git a/src/App/Enums/ReturnType.cs b/src/App/Enums/ReturnType.cs new file mode 100644 index 000000000..fef8f25ff --- /dev/null +++ b/src/App/Enums/ReturnType.cs @@ -0,0 +1,11 @@ +namespace Bit.App.Enums +{ + public enum ReturnType + { + Return, + Done, + Go, + Next, + Search + } +} diff --git a/src/App/Pages/VaultAddSitePage.cs b/src/App/Pages/VaultAddSitePage.cs index d79c6527d..f68a8bba8 100644 --- a/src/App/Pages/VaultAddSitePage.cs +++ b/src/App/Pages/VaultAddSitePage.cs @@ -31,10 +31,13 @@ namespace Bit.App.Pages private void Init() { - var uriCell = new FormEntryCell(AppResources.URI, Keyboard.Url); - var nameCell = new FormEntryCell(AppResources.Name); - var usernameCell = new FormEntryCell(AppResources.Username); - var passwordCell = new FormEntryCell(AppResources.Password, IsPassword: true); + var notesCell = new FormEditorCell(height: 90); + var passwordCell = new FormEntryCell(AppResources.Password, IsPassword: true, nextElement: notesCell.Editor); + var usernameCell = new FormEntryCell(AppResources.Username, nextElement: passwordCell.Entry); + usernameCell.Entry.DisableAutocapitalize = true; + usernameCell.Entry.Autocorrect = false; + var uriCell = new FormEntryCell(AppResources.URI, Keyboard.Url, nextElement: usernameCell.Entry); + var nameCell = new FormEntryCell(AppResources.Name, nextElement: uriCell.Entry); var folderOptions = new List { AppResources.FolderNone }; var folders = _folderService.GetAllAsync().GetAwaiter().GetResult().OrderBy(f => f.Name?.Decrypt()); @@ -44,8 +47,6 @@ namespace Bit.App.Pages } var folderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); - var notesCell = new FormEditorCell(height: 90); - var mainTable = new ExtendedTableView { Intent = TableIntent.Settings, diff --git a/src/iOS/Controls/ExtendedEntryRenderer.cs b/src/iOS/Controls/ExtendedEntryRenderer.cs index b4511a96f..8d50ab60c 100644 --- a/src/iOS/Controls/ExtendedEntryRenderer.cs +++ b/src/iOS/Controls/ExtendedEntryRenderer.cs @@ -23,6 +23,40 @@ namespace Bit.iOS.Controls { SetBorder(view); SetMaxLength(view); + + if(view.DisableAutocapitalize) + { + Control.AutocapitalizationType = UITextAutocapitalizationType.None; + } + + if(view.Autocorrect.HasValue) + { + Control.AutocorrectionType = view.Autocorrect.Value ? UITextAutocorrectionType.Yes : UITextAutocorrectionType.No; + } + + if(view.ReturnType.HasValue) + { + switch(view.ReturnType.Value) + { + case App.Enums.ReturnType.Return: + Control.ReturnKeyType = UIReturnKeyType.Default; + break; + case App.Enums.ReturnType.Done: + Control.ReturnKeyType = UIReturnKeyType.Done; + break; + case App.Enums.ReturnType.Go: + Control.ReturnKeyType = UIReturnKeyType.Go; + break; + case App.Enums.ReturnType.Next: + Control.ReturnKeyType = UIReturnKeyType.Next; + break; + case App.Enums.ReturnType.Search: + Control.ReturnKeyType = UIReturnKeyType.Search; + break; + default: + break; + } + } } }