From 3291a0d78de82c383ddee6afa57028841f675251 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 8 Jul 2016 00:35:48 -0400 Subject: [PATCH] Assigning context to add site cells --- src/iOS.Extension/ActionViewController.cs | 7 +- src/iOS.Extension/AddSiteViewController.cs | 11 ++ .../AddSiteViewController.designer.cs | 167 ++++++++++-------- src/iOS.Extension/MainInterface.storyboard | 27 +-- src/iOS.Extension/Models/Context.cs | 21 +++ 5 files changed, 141 insertions(+), 92 deletions(-) diff --git a/src/iOS.Extension/ActionViewController.cs b/src/iOS.Extension/ActionViewController.cs index eb42b9b36..fd08c089b 100644 --- a/src/iOS.Extension/ActionViewController.cs +++ b/src/iOS.Extension/ActionViewController.cs @@ -33,14 +33,13 @@ namespace Bit.iOS.Extension { base.ViewDidLoad(); - IEnumerable filteredSiteModels = new List< SiteViewModel>(); - DomainName domain; - if(Context.Url?.Host != null && DomainName.TryParse(Context.Url?.Host, out domain)) + IEnumerable filteredSiteModels = new List(); + if(Context.DomainName != null) { var siteService = Resolver.Resolve(); var sites = await siteService.GetAllAsync(); var siteModels = sites.Select(s => new SiteViewModel(s)); - filteredSiteModels = siteModels.Where(s => s.Domain != null && s.Domain.BaseDomain == domain.BaseDomain); + filteredSiteModels = siteModels.Where(s => s.Domain != null && s.Domain.BaseDomain == Context.DomainName.BaseDomain); } tableView.RowHeight = UITableView.AutomaticDimension; diff --git a/src/iOS.Extension/AddSiteViewController.cs b/src/iOS.Extension/AddSiteViewController.cs index 923e3f8e1..1cde47ad0 100644 --- a/src/iOS.Extension/AddSiteViewController.cs +++ b/src/iOS.Extension/AddSiteViewController.cs @@ -31,6 +31,11 @@ namespace Bit.iOS.Extension public override void ViewDidLoad() { + View.BackgroundColor = new UIColor(red: 0.93f, green: 0.94f, blue: 0.96f, alpha: 1.0f); + + nameField.Text = Context.Url.Host; + uriField.Text = Context.Url.ToString(); + tableView.RowHeight = UITableView.AutomaticDimension; tableView.EstimatedRowHeight = 44; tableView.Source = new TableSource (this); @@ -38,6 +43,12 @@ namespace Bit.iOS.Extension base.ViewDidLoad(); } + public override void ViewDidAppear(bool animated) + { + usernameCell.BecomeFirstResponder(); + base.ViewDidAppear(animated); + } + partial void UIBarButtonItem2289_Activated(UIBarButtonItem sender) { DismissViewController(true, null); diff --git a/src/iOS.Extension/AddSiteViewController.designer.cs b/src/iOS.Extension/AddSiteViewController.designer.cs index 5c2719588..e44e2ed7a 100644 --- a/src/iOS.Extension/AddSiteViewController.designer.cs +++ b/src/iOS.Extension/AddSiteViewController.designer.cs @@ -11,92 +11,107 @@ using UIKit; namespace Bit.iOS.Extension { - [Register ("AddSiteViewController")] - partial class AddSiteViewController - { - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UITableViewCell generatePasswordCell { get; set; } + [Register ("AddSiteViewController")] + partial class AddSiteViewController + { + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITableViewCell generatePasswordCell { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UITableViewCell nameCell { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITableViewCell nameCell { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UITextField nameField { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITextField nameField { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UILabel nameLabel { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UILabel nameLabel { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UITableViewCell passwordCell { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITableViewCell passwordCell { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UITableView tableView { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITextField passwordField { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UITableViewCell uriCell { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITableView tableView { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIKit.UITableViewCell usernameCell { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITableViewCell uriCell { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITextField uriField { get; set; } - [Action ("UIBarButtonItem2289_Activated:")] - [GeneratedCode ("iOS Designer", "1.0")] - partial void UIBarButtonItem2289_Activated (UIBarButtonItem sender); + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITableViewCell usernameCell { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UITextField usernameField { get; set; } - [Action ("UIBarButtonItem2290_Activated:")] - [GeneratedCode ("iOS Designer", "1.0")] - partial void UIBarButtonItem2290_Activated (UIBarButtonItem sender); + [Action ("UIBarButtonItem2289_Activated:")] + [GeneratedCode ("iOS Designer", "1.0")] + partial void UIBarButtonItem2289_Activated (UIBarButtonItem sender); - void ReleaseDesignerOutlets () - { - if (generatePasswordCell != null) { - generatePasswordCell.Dispose (); - generatePasswordCell = null; - } + [Action ("UIBarButtonItem2290_Activated:")] + [GeneratedCode ("iOS Designer", "1.0")] + partial void UIBarButtonItem2290_Activated (UIBarButtonItem sender); - 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 (tableView != null) { - tableView.Dispose (); - tableView = null; - } - - if (uriCell != null) { - uriCell.Dispose (); - uriCell = null; - } - - if (usernameCell != null) { - usernameCell.Dispose (); - usernameCell = null; - } - } - } -} \ No newline at end of file + 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/MainInterface.storyboard b/src/iOS.Extension/MainInterface.storyboard index 23f9d3746..5a420dd48 100644 --- a/src/iOS.Extension/MainInterface.storyboard +++ b/src/iOS.Extension/MainInterface.storyboard @@ -137,7 +137,7 @@ @@ -154,7 +154,7 @@ - + @@ -175,7 +175,7 @@ - + @@ -192,7 +192,7 @@ - + @@ -210,14 +210,14 @@ - diff --git a/src/iOS.Extension/Models/Context.cs b/src/iOS.Extension/Models/Context.cs index 721258a9d..b0f4a3a2d 100644 --- a/src/iOS.Extension/Models/Context.cs +++ b/src/iOS.Extension/Models/Context.cs @@ -1,13 +1,34 @@ using System; +using Bit.App.Models; using Foundation; namespace Bit.iOS.Extension.Models { public class Context { + private DomainName _domainName; + public NSExtensionContext ExtContext { get; set; } public string ProviderType { get; set; } public Uri Url { get; set; } + public DomainName DomainName + { + get + { + if(_domainName != null) + { + return _domainName; + } + + DomainName domain; + if(Url?.Host != null && DomainName.TryParse(Url?.Host, out domain)) + { + _domainName = domain; + } + + return _domainName; + } + } public string SiteTitle { get; set; } public string Username { get; set; } public string Password { get; set; }