1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-28 12:35:40 +01:00

Setup lock apge segues from site list VC. Implemented touchid checking in lock fingerprint VC.

This commit is contained in:
Kyle Spearrin 2016-07-19 23:04:37 -04:00
parent 4f9740043b
commit 7fb51b5aa4
3 changed files with 62 additions and 7 deletions

View File

@ -5,12 +5,15 @@ using XLabs.Ioc;
using Plugin.Settings.Abstractions;
using Foundation;
using MobileCoreServices;
using Plugin.Fingerprint.Abstractions;
using System.Threading.Tasks;
namespace Bit.iOS.Extension
{
public partial class LockFingerprintViewController : UIViewController
{
private ISettings _settings;
private IFingerprint _fingerprint;
public LockFingerprintViewController(IntPtr handle) : base(handle)
{ }
@ -27,14 +30,30 @@ namespace Bit.iOS.Extension
public override void ViewDidLoad()
{
_settings = Resolver.Resolve<ISettings>();
_fingerprint = Resolver.Resolve<IFingerprint>();
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
var descriptor = UIFontDescriptor.PreferredBody;
UseButton.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize);
UseButton.BackgroundColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f);
UseButton.TintColor = UIColor.White;
UseButton.TouchUpInside += UseButton_TouchUpInside;
base.ViewDidLoad();
}
private void UseButton_TouchUpInside(object sender, EventArgs e)
{
var task = CheckFingerprintAsync();
}
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
var task = CheckFingerprintAsync();
}
partial void CancelButton_Activated(UIBarButtonItem sender)
{
CompleteRequest();
@ -48,5 +67,14 @@ namespace Bit.iOS.Extension
Context.ExtContext.CompleteRequest(returningItems, null);
}
public async Task CheckFingerprintAsync()
{
var result = await _fingerprint.AuthenticateAsync("Use your fingerprint to verify.");
if(result.Authenticated)
{
DismissModalViewController(true);
}
}
}
}

View File

@ -174,8 +174,8 @@
<outlet property="CancelBarButton" destination="3735" id="name-outlet-3735"/>
<outlet property="NavItem" destination="3734" id="name-outlet-3734"/>
<segue id="6763" destination="6512" kind="presentation" identifier="lockFingerprintSegue" animates="NO" modalPresentationStyle="" modalTransitionStyle=""/>
<segue id="7049" destination="6815" kind="presentation" identifier="lockPinSegue"/>
<segue id="7291" destination="6855" kind="presentation" identifier="lockPasswordSegue"/>
<segue id="7049" destination="6815" kind="presentation" identifier="lockPinSegue" animates="NO"/>
<segue id="7291" destination="6855" kind="presentation" identifier="lockPasswordSegue" animates="NO"/>
</connections>
<toolbarItems/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>

View File

@ -32,8 +32,19 @@ namespace Bit.iOS.Extension
{
base.ViewDidLoad();
// TODO: lock logic
if(true)
{
PerformSegue("lockFingerprintSegue", this);
}
else if(true)
{
PerformSegue("lockPinSegue", this);
}
else
{
PerformSegue("lockPasswordSegue", this);
}
IEnumerable<SiteViewModel> filteredSiteModels = new List<SiteViewModel>();
if(Context.DomainName != null)
@ -74,11 +85,27 @@ namespace Bit.iOS.Extension
if(navController != null)
{
var addSiteController = navController.TopViewController as SiteAddViewController;
var fingerprintViewController = navController.TopViewController as LockFingerprintViewController;
var pinViewController = navController.TopViewController as LockPinViewController;
var passwordViewController = navController.TopViewController as LockPasswordViewController;
if(addSiteController != null)
{
addSiteController.Context = Context;
addSiteController.Parent = this;
}
else if(fingerprintViewController != null)
{
fingerprintViewController.Context = Context;
}
else if(pinViewController != null)
{
pinViewController.Context = Context;
}
else if(passwordViewController != null)
{
passwordViewController.Context = Context;
}
}
}
@ -120,17 +147,17 @@ namespace Bit.iOS.Extension
return cell;
}
public override void WillDisplay( UITableView tableView, UITableViewCell cell, NSIndexPath indexPath )
public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
{
if(cell == null)
{
return;
}
var item = _tableItems.ElementAt( indexPath.Row );
var item = _tableItems.ElementAt(indexPath.Row);
cell.TextLabel.Text = item.Name;
cell.DetailTextLabel.Text = item.Username;
cell.DetailTextLabel.TextColor = cell.DetailTextLabel.TintColor = new UIColor( red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f );
cell.DetailTextLabel.TextColor = cell.DetailTextLabel.TintColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);
}
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)