From 3a82653ae5dcd2c61a1dd8f8d134aae3461e6309 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 9 Jul 2016 01:07:02 -0400 Subject: [PATCH] Moved cells from storyboard into being managed in controller code. new ios views for tableview cells. --- src/App/App.csproj | 2 +- src/App/Resources/AppResources.Designer.cs | 100 ++++----- src/iOS.Core/Views/FormEntryTableViewCell.cs | 111 ++++++++++ src/iOS.Core/Views/PickerTableViewCell.cs | 102 +++++++++ src/iOS.Core/Views/SwitchTableViewCell.cs | 17 ++ src/iOS.Core/iOS.Core.csproj | 3 + src/iOS.Extension/AddSiteViewController.cs | 148 +++++++++---- .../AddSiteViewController.designer.cs | 80 -------- src/iOS.Extension/LoadingViewController.cs | 2 +- src/iOS.Extension/MainInterface.storyboard | 194 +----------------- 10 files changed, 395 insertions(+), 364 deletions(-) create mode 100644 src/iOS.Core/Views/FormEntryTableViewCell.cs create mode 100644 src/iOS.Core/Views/PickerTableViewCell.cs create mode 100644 src/iOS.Core/Views/SwitchTableViewCell.cs diff --git a/src/App/App.csproj b/src/App/App.csproj index 0245d5165..0a55f7a75 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -279,7 +279,7 @@ - ResXFileCodeGenerator + PublicResXFileCodeGenerator AppResources.Designer.cs diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index d5236464c..9314c2bb9 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -23,7 +23,7 @@ namespace Bit.App.Resources { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class AppResources { + public class AppResources { private static global::System.Resources.ResourceManager resourceMan; @@ -37,7 +37,7 @@ namespace Bit.App.Resources { /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bit.App.Resources.AppResources", typeof(AppResources).GetTypeInfo().Assembly); @@ -52,7 +52,7 @@ namespace Bit.App.Resources { /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -64,7 +64,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Add. /// - internal static string Add { + public static string Add { get { return ResourceManager.GetString("Add", resourceCulture); } @@ -73,7 +73,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Add Site. /// - internal static string AddSite { + public static string AddSite { get { return ResourceManager.GetString("AddSite", resourceCulture); } @@ -82,7 +82,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to An error has occurred.. /// - internal static string AnErrorHasOccurred { + public static string AnErrorHasOccurred { get { return ResourceManager.GetString("AnErrorHasOccurred", resourceCulture); } @@ -91,7 +91,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Back. /// - internal static string Back { + public static string Back { get { return ResourceManager.GetString("Back", resourceCulture); } @@ -100,7 +100,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to bitwarden. /// - internal static string Bitwarden { + public static string Bitwarden { get { return ResourceManager.GetString("Bitwarden", resourceCulture); } @@ -109,7 +109,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Cancel. /// - internal static string Cancel { + public static string Cancel { get { return ResourceManager.GetString("Cancel", resourceCulture); } @@ -118,7 +118,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Copy. /// - internal static string Copy { + public static string Copy { get { return ResourceManager.GetString("Copy", resourceCulture); } @@ -127,7 +127,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Copy Password. /// - internal static string CopyPassword { + public static string CopyPassword { get { return ResourceManager.GetString("CopyPassword", resourceCulture); } @@ -136,7 +136,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Copy Username. /// - internal static string CopyUsername { + public static string CopyUsername { get { return ResourceManager.GetString("CopyUsername", resourceCulture); } @@ -145,7 +145,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Delete. /// - internal static string Delete { + public static string Delete { get { return ResourceManager.GetString("Delete", resourceCulture); } @@ -154,7 +154,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Do you really want to delete? This cannot be undone.. /// - internal static string DoYouReallyWantToDelete { + public static string DoYouReallyWantToDelete { get { return ResourceManager.GetString("DoYouReallyWantToDelete", resourceCulture); } @@ -163,7 +163,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Edit. /// - internal static string Edit { + public static string Edit { get { return ResourceManager.GetString("Edit", resourceCulture); } @@ -172,7 +172,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Email. /// - internal static string Email { + public static string Email { get { return ResourceManager.GetString("Email", resourceCulture); } @@ -181,7 +181,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Email Address. /// - internal static string EmailAddress { + public static string EmailAddress { get { return ResourceManager.GetString("EmailAddress", resourceCulture); } @@ -190,7 +190,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Favorites. /// - internal static string Favorites { + public static string Favorites { get { return ResourceManager.GetString("Favorites", resourceCulture); } @@ -199,7 +199,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Folder. /// - internal static string Folder { + public static string Folder { get { return ResourceManager.GetString("Folder", resourceCulture); } @@ -208,7 +208,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to (none). /// - internal static string FolderNone { + public static string FolderNone { get { return ResourceManager.GetString("FolderNone", resourceCulture); } @@ -217,7 +217,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Go To Website. /// - internal static string GoToWebsite { + public static string GoToWebsite { get { return ResourceManager.GetString("GoToWebsite", resourceCulture); } @@ -226,7 +226,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Hide. /// - internal static string Hide { + public static string Hide { get { return ResourceManager.GetString("Hide", resourceCulture); } @@ -235,7 +235,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Please connect to the internet before continuing.. /// - internal static string InternetConnectionRequiredMessage { + public static string InternetConnectionRequiredMessage { get { return ResourceManager.GetString("InternetConnectionRequiredMessage", resourceCulture); } @@ -244,7 +244,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Internet Connection Required. /// - internal static string InternetConnectionRequiredTitle { + public static string InternetConnectionRequiredTitle { get { return ResourceManager.GetString("InternetConnectionRequiredTitle", resourceCulture); } @@ -253,7 +253,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Launch. /// - internal static string Launch { + public static string Launch { get { return ResourceManager.GetString("Launch", resourceCulture); } @@ -262,7 +262,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Log In. /// - internal static string LogIn { + public static string LogIn { get { return ResourceManager.GetString("LogIn", resourceCulture); } @@ -271,7 +271,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Login. /// - internal static string LogInNoun { + public static string LogInNoun { get { return ResourceManager.GetString("LogInNoun", resourceCulture); } @@ -280,7 +280,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Log Out. /// - internal static string LogOut { + public static string LogOut { get { return ResourceManager.GetString("LogOut", resourceCulture); } @@ -289,7 +289,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Master Password. /// - internal static string MasterPassword { + public static string MasterPassword { get { return ResourceManager.GetString("MasterPassword", resourceCulture); } @@ -298,7 +298,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to More. /// - internal static string More { + public static string More { get { return ResourceManager.GetString("More", resourceCulture); } @@ -307,7 +307,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to My Vault. /// - internal static string MyVault { + public static string MyVault { get { return ResourceManager.GetString("MyVault", resourceCulture); } @@ -316,7 +316,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Name. /// - internal static string Name { + public static string Name { get { return ResourceManager.GetString("Name", resourceCulture); } @@ -325,7 +325,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to No. /// - internal static string No { + public static string No { get { return ResourceManager.GetString("No", resourceCulture); } @@ -334,7 +334,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Notes. /// - internal static string Notes { + public static string Notes { get { return ResourceManager.GetString("Notes", resourceCulture); } @@ -343,7 +343,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Ok. /// - internal static string Ok { + public static string Ok { get { return ResourceManager.GetString("Ok", resourceCulture); } @@ -352,7 +352,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Password. /// - internal static string Password { + public static string Password { get { return ResourceManager.GetString("Password", resourceCulture); } @@ -361,7 +361,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Save. /// - internal static string Save { + public static string Save { get { return ResourceManager.GetString("Save", resourceCulture); } @@ -370,7 +370,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Settings. /// - internal static string Settings { + public static string Settings { get { return ResourceManager.GetString("Settings", resourceCulture); } @@ -379,7 +379,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Show. /// - internal static string Show { + public static string Show { get { return ResourceManager.GetString("Show", resourceCulture); } @@ -388,7 +388,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Site has been deleted.. /// - internal static string SiteDeleted { + public static string SiteDeleted { get { return ResourceManager.GetString("SiteDeleted", resourceCulture); } @@ -397,7 +397,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to No Name. /// - internal static string SiteNoName { + public static string SiteNoName { get { return ResourceManager.GetString("SiteNoName", resourceCulture); } @@ -406,7 +406,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Sync. /// - internal static string Sync { + public static string Sync { get { return ResourceManager.GetString("Sync", resourceCulture); } @@ -415,7 +415,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Tools. /// - internal static string Tools { + public static string Tools { get { return ResourceManager.GetString("Tools", resourceCulture); } @@ -424,7 +424,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to URI. /// - internal static string URI { + public static string URI { get { return ResourceManager.GetString("URI", resourceCulture); } @@ -433,7 +433,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Username. /// - internal static string Username { + public static string Username { get { return ResourceManager.GetString("Username", resourceCulture); } @@ -442,7 +442,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to The {0} field is required.. /// - internal static string ValidationFieldRequired { + public static string ValidationFieldRequired { get { return ResourceManager.GetString("ValidationFieldRequired", resourceCulture); } @@ -451,7 +451,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to {0} has been copied.. /// - internal static string ValueHasBeenCopied { + public static string ValueHasBeenCopied { get { return ResourceManager.GetString("ValueHasBeenCopied", resourceCulture); } @@ -460,7 +460,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to View. /// - internal static string View { + public static string View { get { return ResourceManager.GetString("View", resourceCulture); } @@ -469,7 +469,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Website. /// - internal static string Website { + public static string Website { get { return ResourceManager.GetString("Website", resourceCulture); } @@ -478,7 +478,7 @@ namespace Bit.App.Resources { /// /// Looks up a localized string similar to Yes. /// - internal static string Yes { + public static string Yes { get { return ResourceManager.GetString("Yes", resourceCulture); } diff --git a/src/iOS.Core/Views/FormEntryTableViewCell.cs b/src/iOS.Core/Views/FormEntryTableViewCell.cs new file mode 100644 index 000000000..5eea6a6c7 --- /dev/null +++ b/src/iOS.Core/Views/FormEntryTableViewCell.cs @@ -0,0 +1,111 @@ +using System; +using UIKit; + +namespace Bit.iOS.Core.Views +{ + public class FormEntryTableViewCell : UITableViewCell + { + public FormEntryTableViewCell( + string labelName = null, + bool useTextView = false, + nfloat? height = null) + : base(UITableViewCellStyle.Default, nameof(FormEntryTableViewCell)) + { + var descriptor = UIFontDescriptor.PreferredBody; + var pointSize = descriptor.PointSize; + + if(labelName != null) + { + Label = new UILabel + { + Text = labelName, + TranslatesAutoresizingMaskIntoConstraints = false, + Font = UIFont.FromDescriptor(descriptor, 0.8f * pointSize), + TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f) + }; + + ContentView.Add(Label); + } + + if(useTextView) + { + TextView = new UITextView + { + TranslatesAutoresizingMaskIntoConstraints = false, + Font = UIFont.FromDescriptor(descriptor, pointSize) + }; + + ContentView.Add(TextView); + ContentView.AddConstraints(new NSLayoutConstraint[] { + NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f), + NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextView, NSLayoutAttribute.Trailing, 1f, 15f), + NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextView, NSLayoutAttribute.Bottom, 1f, 10f) + }); + + if(labelName != null) + { + ContentView.AddConstraint( + NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f)); + } + else + { + ContentView.AddConstraint( + NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f)); + } + + if(height.HasValue) + { + ContentView.AddConstraint( + NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value)); + } + } + else + { + TextField = new UITextField + { + TranslatesAutoresizingMaskIntoConstraints = false, + BorderStyle = UITextBorderStyle.None, + Font = UIFont.FromDescriptor(descriptor, pointSize), + ClearButtonMode = UITextFieldViewMode.WhileEditing + }; + + ContentView.Add(TextField); + ContentView.AddConstraints(new NSLayoutConstraint[] { + NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f), + NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Trailing, 1f, 15f), + NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Bottom, 1f, 10f) + }); + + if(labelName != null) + { + ContentView.AddConstraint( + NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f)); + } + else + { + ContentView.AddConstraint( + NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f)); + } + + if(height.HasValue) + { + ContentView.AddConstraint( + NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value)); + } + } + + if(labelName != null) + { + ContentView.AddConstraints(new NSLayoutConstraint[] { + NSLayoutConstraint.Create(Label, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f), + NSLayoutConstraint.Create(Label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f), + NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Trailing, 1f, 15f) + }); + } + } + + public UILabel Label { get; set; } + public UITextField TextField { get; set; } + public UITextView TextView { get; set; } + } +} diff --git a/src/iOS.Core/Views/PickerTableViewCell.cs b/src/iOS.Core/Views/PickerTableViewCell.cs new file mode 100644 index 000000000..96ff280d8 --- /dev/null +++ b/src/iOS.Core/Views/PickerTableViewCell.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using UIKit; + +namespace Bit.iOS.Core.Views +{ + public class PickerTableViewCell : UITableViewCell + { + public PickerTableViewCell(string labelName) + : base(UITableViewCellStyle.Default, nameof(PickerTableViewCell)) + { + TextLabel.Text = labelName; + + var entry = new UITextField { BorderStyle = UITextBorderStyle.RoundedRect }; + entry.Started += Entry_Started; + entry.Ended += Entry_Ended; + + var width = (float)UIScreen.MainScreen.Bounds.Width; + var toolbar = new UIToolbar(new RectangleF(0, 0, width, 44)) + { + BarStyle = UIBarStyle.Default, + Translucent = true + }; + var spacer = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); + var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (o, a) => + { + var s = (PickerSource)Picker.Model; + if(s.SelectedIndex == -1 && Items != null && Items.Count > 0) + { + + } + entry.ResignFirstResponder(); + }); + + toolbar.SetItems(new[] { spacer, doneButton }, false); + + entry.InputView = Picker; + entry.InputAccessoryView = toolbar; + } + + public UIPickerView Picker { get; set; } = new UIPickerView(); + public int MyProperty { get; set; } + public List Items { get; set; } = new List(); + public int SelectedIndex { get; set; } + + private void Entry_Ended(object sender, EventArgs e) + { + //throw new NotImplementedException(); + } + + private void Entry_Started(object sender, EventArgs e) + { + //throw new NotImplementedException(); + } + + private class PickerSource : UIPickerViewModel + { + readonly PickerTableViewCell _cell; + + public PickerSource(PickerTableViewCell cell) + { + _cell = cell; + } + + public int SelectedIndex { get; internal set; } + + public string SelectedItem { get; internal set; } + + public override nint GetComponentCount(UIPickerView picker) + { + return 1; + } + + public override nint GetRowsInComponent(UIPickerView pickerView, nint component) + { + return _cell.Items != null ? _cell.Items.Count : 0; + } + + public override string GetTitle(UIPickerView picker, nint row, nint component) + { + return _cell.Items[(int)row]; + } + + public override void Selected(UIPickerView picker, nint row, nint component) + { + if(_cell.Items.Count == 0) + { + SelectedItem = null; + SelectedIndex = -1; + } + else + { + SelectedItem = _cell.Items[(int)row]; + SelectedIndex = (int)row; + } + + //_renderer.UpdatePickerFromModel(this); + } + } + } +} diff --git a/src/iOS.Core/Views/SwitchTableViewCell.cs b/src/iOS.Core/Views/SwitchTableViewCell.cs new file mode 100644 index 000000000..5b6b7b2e7 --- /dev/null +++ b/src/iOS.Core/Views/SwitchTableViewCell.cs @@ -0,0 +1,17 @@ +using System; +using UIKit; + +namespace Bit.iOS.Core.Views +{ + public class SwitchTableViewCell : UITableViewCell + { + public SwitchTableViewCell(string labelName) + : base(UITableViewCellStyle.Default, nameof(SwitchTableViewCell)) + { + TextLabel.Text = labelName; + AccessoryView = Switch; + } + + public UISwitch Switch { get; set; } = new UISwitch(); + } +} diff --git a/src/iOS.Core/iOS.Core.csproj b/src/iOS.Core/iOS.Core.csproj index 8e2ba7f5c..0fa1fef7f 100644 --- a/src/iOS.Core/iOS.Core.csproj +++ b/src/iOS.Core/iOS.Core.csproj @@ -67,6 +67,9 @@ + + + diff --git a/src/iOS.Extension/AddSiteViewController.cs b/src/iOS.Extension/AddSiteViewController.cs index 1cde47ad0..e2cc48837 100644 --- a/src/iOS.Extension/AddSiteViewController.cs +++ b/src/iOS.Extension/AddSiteViewController.cs @@ -4,13 +4,11 @@ using System.Diagnostics; using System.Linq; using Bit.App.Abstractions; using Bit.App.Models; -using Bit.iOS.Core; +using Bit.App.Resources; +using Bit.iOS.Core.Views; using Bit.iOS.Extension.Models; using Foundation; -using MobileCoreServices; -using Newtonsoft.Json; using UIKit; -using XLabs.Ioc; namespace Bit.iOS.Extension { @@ -20,35 +18,71 @@ namespace Bit.iOS.Extension { } public Context Context { get; set; } + public FormEntryTableViewCell NameCell { get; set; } = new FormEntryTableViewCell(AppResources.Name); + public FormEntryTableViewCell UriCell { get; set; } = new FormEntryTableViewCell(AppResources.URI); + public FormEntryTableViewCell UsernameCell { get; set; } = new FormEntryTableViewCell(AppResources.Username); + public FormEntryTableViewCell PasswordCell { get; set; } = new FormEntryTableViewCell(AppResources.Password); + public UITableViewCell GeneratePasswordCell { get; set; } = new UITableViewCell(UITableViewCellStyle.Subtitle, "GeneratePasswordCell"); + public SwitchTableViewCell FavoriteCell { get; set; } = new SwitchTableViewCell("Favorite"); + public FormEntryTableViewCell NotesCell { get; set; } = new FormEntryTableViewCell(useTextView: true, height: 90); public override void ViewWillAppear(bool animated) { UINavigationBar.Appearance.ShadowImage = new UIImage(); UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); - base.ViewWillAppear(animated); } public override void ViewDidLoad() { - View.BackgroundColor = new UIColor(red: 0.93f, green: 0.94f, blue: 0.96f, alpha: 1.0f); + View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); - nameField.Text = Context.Url.Host; - uriField.Text = Context.Url.ToString(); + NameCell.TextField.Text = Context.Url.Host; + NameCell.TextField.ReturnKeyType = UIReturnKeyType.Next; + NameCell.TextField.ShouldReturn += (UITextField tf) => + { + UriCell.TextField.BecomeFirstResponder(); + return true; + }; + + UriCell.TextField.Text = Context.Url.ToString(); + UriCell.TextField.KeyboardType = UIKeyboardType.Url; + UriCell.TextField.ReturnKeyType = UIReturnKeyType.Next; + UriCell.TextField.ShouldReturn += (UITextField tf) => + { + UsernameCell.TextField.BecomeFirstResponder(); + return true; + }; + + UsernameCell.TextField.BecomeFirstResponder(); + UsernameCell.TextField.AutocapitalizationType = UITextAutocapitalizationType.None; + UsernameCell.TextField.AutocorrectionType = UITextAutocorrectionType.No; + UsernameCell.TextField.SpellCheckingType = UITextSpellCheckingType.No; + UsernameCell.TextField.ReturnKeyType = UIReturnKeyType.Next; + UsernameCell.TextField.ShouldReturn += (UITextField tf) => + { + PasswordCell.TextField.BecomeFirstResponder(); + return true; + }; + + PasswordCell.TextField.SecureTextEntry = true; + PasswordCell.TextField.ReturnKeyType = UIReturnKeyType.Next; + PasswordCell.TextField.ShouldReturn += (UITextField tf) => + { + NotesCell.TextView.BecomeFirstResponder(); + return true; + }; + + GeneratePasswordCell.TextLabel.Text = "Generate Password"; + GeneratePasswordCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; tableView.RowHeight = UITableView.AutomaticDimension; - tableView.EstimatedRowHeight = 44; - tableView.Source = new TableSource (this); + tableView.EstimatedRowHeight = 70; + tableView.Source = new TableSource(this); base.ViewDidLoad(); } - public override void ViewDidAppear(bool animated) - { - usernameCell.BecomeFirstResponder(); - base.ViewDidAppear(animated); - } - partial void UIBarButtonItem2289_Activated(UIBarButtonItem sender) { DismissViewController(true, null); @@ -63,58 +97,94 @@ namespace Bit.iOS.Extension { private AddSiteViewController _controller; - public TableSource (AddSiteViewController controller) + public TableSource(AddSiteViewController controller) { _controller = controller; } - public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) + public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { - if (indexPath.Row == 0) { - return _controller.nameCell; - } else if (indexPath.Row == 1) { - return _controller.uriCell; - } else if (indexPath.Row == 2) { - return _controller.usernameCell; - } else if (indexPath.Row == 3) { - return _controller.passwordCell; - } else if (indexPath.Row == 4) { - return _controller.generatePasswordCell; + if(indexPath.Section == 0) + { + if(indexPath.Row == 0) + { + return _controller.NameCell; + } + else if(indexPath.Row == 1) + { + return _controller.UriCell; + } + else if(indexPath.Row == 2) + { + return _controller.UsernameCell; + } + else if(indexPath.Row == 3) + { + return _controller.PasswordCell; + } + else if(indexPath.Row == 4) + { + return _controller.GeneratePasswordCell; + } + } + else if(indexPath.Section == 1) + { + if(indexPath.Row == 1) + { + return _controller.FavoriteCell; + } + } + else if(indexPath.Section == 2) + { + return _controller.NotesCell; } return new UITableViewCell(); } - public override nfloat GetHeightForRow (UITableView tableView, NSIndexPath indexPath) + public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath) { return UITableView.AutomaticDimension; } - public override nint RowsInSection (UITableView tableview, nint section) + public override nint NumberOfSections(UITableView tableView) { - if (section == 0) { + return 3; + } + + public override nint RowsInSection(UITableView tableview, nint section) + { + if(section == 0) + { return 5; - } else if (section == 1) { + } + else if(section == 1) + { return 2; - } else { + } + else + { return 1; } } - public override nfloat GetHeightForHeader (UITableView tableView, nint section) + public override nfloat GetHeightForHeader(UITableView tableView, nint section) { return UITableView.AutomaticDimension; - } + } - public override string TitleForHeader (UITableView tableView, nint section) + public override string TitleForHeader(UITableView tableView, nint section) { - if (section == 0) { + if(section == 0) + { return "Site Information"; - } else if (section == 2) { + } + else if(section == 2) + { return "Notes"; } - return " "; + return null; } } } diff --git a/src/iOS.Extension/AddSiteViewController.designer.cs b/src/iOS.Extension/AddSiteViewController.designer.cs index e44e2ed7a..bc623816d 100644 --- a/src/iOS.Extension/AddSiteViewController.designer.cs +++ b/src/iOS.Extension/AddSiteViewController.designer.cs @@ -14,50 +14,10 @@ namespace Bit.iOS.Extension [Register ("AddSiteViewController")] partial class AddSiteViewController { - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITableViewCell generatePasswordCell { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITableViewCell nameCell { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITextField nameField { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UILabel nameLabel { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITableViewCell passwordCell { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITextField passwordField { get; set; } - [Outlet] [GeneratedCode ("iOS Designer", "1.0")] UITableView tableView { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITableViewCell uriCell { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITextField uriField { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITableViewCell usernameCell { get; set; } - - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITextField usernameField { get; set; } - [Action ("UIBarButtonItem2289_Activated:")] [GeneratedCode ("iOS Designer", "1.0")] partial void UIBarButtonItem2289_Activated (UIBarButtonItem sender); @@ -68,50 +28,10 @@ namespace Bit.iOS.Extension void ReleaseDesignerOutlets () { - if (generatePasswordCell != null) { - generatePasswordCell.Dispose (); - generatePasswordCell = null; - } - if (nameCell != null) { - nameCell.Dispose (); - nameCell = null; - } - if (nameField != null) { - nameField.Dispose (); - nameField = null; - } - if (nameLabel != null) { - nameLabel.Dispose (); - nameLabel = null; - } - if (passwordCell != null) { - passwordCell.Dispose (); - passwordCell = null; - } - if (passwordField != null) { - passwordField.Dispose (); - passwordField = null; - } if (tableView != null) { tableView.Dispose (); tableView = null; } - if (uriCell != null) { - uriCell.Dispose (); - uriCell = null; - } - if (uriField != null) { - uriField.Dispose (); - uriField = null; - } - if (usernameCell != null) { - usernameCell.Dispose (); - usernameCell = null; - } - if (usernameField != null) { - usernameField.Dispose (); - usernameField = null; - } } } } diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs index c43fae328..d2c2af1f9 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.cs @@ -30,7 +30,7 @@ namespace Bit.iOS.Extension public override void ViewDidLoad() { base.ViewDidLoad(); - View.BackgroundColor = new UIColor(red: 0.93f, green: 0.94f, blue: 0.96f, alpha: 1.0f); + View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); _context.ExtContext = ExtensionContext; if(!Resolver.IsSet) diff --git a/src/iOS.Extension/MainInterface.storyboard b/src/iOS.Extension/MainInterface.storyboard index 5a420dd48..19c844cd6 100644 --- a/src/iOS.Extension/MainInterface.storyboard +++ b/src/iOS.Extension/MainInterface.storyboard @@ -200,189 +200,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -401,16 +219,6 @@ - - - - - - - - - -