diff --git a/src/iOS.Core/Utilities/Dialogs.cs b/src/iOS.Core/Utilities/Dialogs.cs
new file mode 100644
index 000000000..9065d0eac
--- /dev/null
+++ b/src/iOS.Core/Utilities/Dialogs.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Drawing;
+using CoreGraphics;
+using UIKit;
+
+namespace Bit.iOS.Core.Utilities
+{
+ public static class Dialogs
+ {
+ public static UIAlertController CreateLoadingAlert(string message)
+ {
+ var loadingIndicator = new UIActivityIndicatorView(new CGRect(10, 5, 50, 50));
+ loadingIndicator.HidesWhenStopped = true;
+ loadingIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray;
+ loadingIndicator.StartAnimating();
+
+ var alert = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert);
+ alert.View.TintColor = UIColor.Black;
+ alert.View.Add(loadingIndicator);
+ return alert;
+ }
+
+ public static UIAlertController CreateAlert(string title, string message, string accept)
+ {
+ var alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);
+ var oldFrame = alert.View.Frame;
+ alert.View.Frame = new RectangleF((float)oldFrame.X, (float)oldFrame.Y, (float)oldFrame.Width, (float)oldFrame.Height - 20);
+ alert.AddAction(UIAlertAction.Create(accept, UIAlertActionStyle.Default, null));
+ return alert;
+ }
+ }
+}
diff --git a/src/iOS.Core/iOS.Core.csproj b/src/iOS.Core/iOS.Core.csproj
index 0fa1fef7f..cbb3f77a8 100644
--- a/src/iOS.Core/iOS.Core.csproj
+++ b/src/iOS.Core/iOS.Core.csproj
@@ -67,6 +67,7 @@
+
diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs
index 8e00fd831..b1b86714a 100644
--- a/src/iOS.Extension/LoadingViewController.cs
+++ b/src/iOS.Extension/LoadingViewController.cs
@@ -16,7 +16,6 @@ using Bit.iOS.Extension.Models;
using MobileCoreServices;
using Plugin.Settings.Abstractions;
using Plugin.Connectivity;
-using Acr.UserDialogs;
using Plugin.Fingerprint;
namespace Bit.iOS.Extension
@@ -108,7 +107,6 @@ namespace Bit.iOS.Extension
.RegisterType(new ContainerControlledLifetimeManager())
// Other
.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager())
- .RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager())
.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager());
ISettings settings = new Settings("group.com.8bit.bitwarden");
diff --git a/src/iOS.Extension/SiteAddViewController.cs b/src/iOS.Extension/SiteAddViewController.cs
index 6bb76a817..6652de114 100644
--- a/src/iOS.Extension/SiteAddViewController.cs
+++ b/src/iOS.Extension/SiteAddViewController.cs
@@ -12,17 +12,20 @@ using UIKit;
using XLabs.Ioc;
using Bit.App;
using Plugin.Connectivity.Abstractions;
-using Acr.UserDialogs;
-using System.Drawing;
+using Bit.iOS.Core.Utilities;
namespace Bit.iOS.Extension
{
public partial class SiteAddViewController : UITableViewController
{
+ private ISiteService _siteService;
+ private IConnectivity _connectivity;
+
public SiteAddViewController(IntPtr handle) : base(handle)
{ }
public Context Context { get; set; }
+ public SiteListViewController Parent { 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);
@@ -40,6 +43,9 @@ namespace Bit.iOS.Extension
public override void ViewDidLoad()
{
+ _siteService = Resolver.Resolve();
+ _connectivity = Resolver.Resolve();
+
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
NameCell.TextField.Text = Context.Url.Host;
@@ -88,18 +94,23 @@ namespace Bit.iOS.Extension
base.ViewDidLoad();
}
- async partial void CancelBarButton_Activated(UIBarButtonItem sender)
+ public override void ViewDidAppear(bool animated)
+ {
+ base.ViewDidAppear(animated);
+ if(!_connectivity.IsConnected)
+ {
+ AlertNoConnection();
+ }
+ }
+
+ partial void CancelBarButton_Activated(UIBarButtonItem sender)
{
DismissViewController(true, null);
}
async partial void SaveBarButton_Activated(UIBarButtonItem sender)
{
- var siteService = Resolver.Resolve();
- var connectivity = Resolver.Resolve();
- var userDialogs = Resolver.Resolve();
-
- if(!connectivity.IsConnected)
+ if(!_connectivity.IsConnected)
{
AlertNoConnection();
return;
@@ -119,29 +130,27 @@ namespace Bit.iOS.Extension
var site = new Site
{
- Uri = UriCell.TextField.Text?.Encrypt(),
- Name = NameCell.TextField.Text?.Encrypt(),
- Username = UsernameCell.TextField.Text?.Encrypt(),
- Password = PasswordCell.TextField.Text?.Encrypt(),
- Notes = NotesCell.TextView.Text?.Encrypt(),
+ Uri = string.IsNullOrWhiteSpace(UriCell.TextField.Text) ? null : UriCell.TextField.Text.Encrypt(),
+ Name = string.IsNullOrWhiteSpace(NameCell.TextField.Text) ? null : NameCell.TextField.Text.Encrypt(),
+ Username = string.IsNullOrWhiteSpace(UsernameCell.TextField.Text) ? null : UsernameCell.TextField.Text.Encrypt(),
+ Password = string.IsNullOrWhiteSpace(PasswordCell.TextField.Text) ? null : PasswordCell.TextField.Text.Encrypt(),
+ Notes = string.IsNullOrWhiteSpace(NotesCell.TextView.Text) ? null : NotesCell.TextView.Text.Encrypt(),
Favorite = FavoriteCell.Switch.On
};
- var saveTask = siteService.SaveAsync(site);
- userDialogs.ShowLoading("Saving...", MaskType.Black);
+ var saveTask = _siteService.SaveAsync(site);
+ var loadingAlert = Dialogs.CreateLoadingAlert("Saving...");
+ PresentViewController(loadingAlert, true, null);
await saveTask;
-
- userDialogs.HideLoading();
- DismissViewController(true, null);
- userDialogs.SuccessToast(NameCell.TextField.Text, "New site created.");
+ DismissViewController(false, () =>
+ {
+ Parent.DismissModal();
+ });
}
public void DisplayAlert(string title, string message, string accept)
{
- var alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);
- var oldFrame = alert.View.Frame;
- alert.View.Frame = new RectangleF((float)oldFrame.X, (float)oldFrame.Y, (float)oldFrame.Width, (float)oldFrame.Height - 20);
- alert.AddAction(UIAlertAction.Create(accept, UIAlertActionStyle.Default, null));
+ var alert = Dialogs.CreateAlert(title, message, accept);
PresentViewController(alert, true, null);
}
diff --git a/src/iOS.Extension/SiteListViewController.cs b/src/iOS.Extension/SiteListViewController.cs
index c21fc043a..a13131874 100644
--- a/src/iOS.Extension/SiteListViewController.cs
+++ b/src/iOS.Extension/SiteListViewController.cs
@@ -74,10 +74,17 @@ namespace Bit.iOS.Extension
if(addSiteController != null)
{
addSiteController.Context = Context;
+ addSiteController.Parent = this;
}
}
}
+ public void DismissModal()
+ {
+ DismissModalViewController(true);
+ TableView.ReloadData();
+ }
+
public class TableSource : UITableViewSource
{
private const string CellIdentifier = "TableCell";
diff --git a/src/iOS.Extension/iOS.Extension.csproj b/src/iOS.Extension/iOS.Extension.csproj
index a250396a7..aeb0ac75c 100644
--- a/src/iOS.Extension/iOS.Extension.csproj
+++ b/src/iOS.Extension/iOS.Extension.csproj
@@ -26,8 +26,6 @@
None
true
Entitlements.plist
- Legacy
- NSUrlSessionHandler
none
@@ -59,8 +57,6 @@
9.3
None
- Legacy
- NSUrlSessionHandler
none
@@ -132,16 +128,8 @@
..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll
True
-
- ..\..\packages\Acr.UserDialogs.5.3.0\lib\Xamarin.iOS10\Acr.UserDialogs.dll
- True
-
-
- ..\..\packages\Acr.UserDialogs.5.3.0\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll
- True
-
-
- ..\..\packages\BTProgressHUD.1.2.0.3\lib\Xamarin.iOS10\BTProgressHUD.dll
+
+ ..\..\packages\modernhttpclient.2.4.2\lib\Xamarin.iOS10\ModernHttpClient.dll
True
@@ -172,10 +160,6 @@
..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll
True
-
- ..\..\packages\Splat.1.6.2\lib\Xamarin.iOS10\Splat.dll
- True
-
..\..\packages\sqlite-net-pcl.1.1.2\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll
True
diff --git a/src/iOS.Extension/packages.config b/src/iOS.Extension/packages.config
index 4399e825e..9e851f59f 100644
--- a/src/iOS.Extension/packages.config
+++ b/src/iOS.Extension/packages.config
@@ -1,12 +1,10 @@
-
-
+
-