2016-07-20 05:38:12 +03:00
|
|
|
using System;
|
|
|
|
using Bit.iOS.Extension.Models;
|
|
|
|
using UIKit;
|
|
|
|
using XLabs.Ioc;
|
|
|
|
using Plugin.Settings.Abstractions;
|
2016-07-20 06:04:37 +03:00
|
|
|
using Plugin.Fingerprint.Abstractions;
|
|
|
|
using System.Threading.Tasks;
|
2016-07-22 06:41:50 +03:00
|
|
|
using Bit.App;
|
2016-08-04 07:06:09 +03:00
|
|
|
using Bit.iOS.Core.Controllers;
|
2016-07-20 05:38:12 +03:00
|
|
|
|
|
|
|
namespace Bit.iOS.Extension
|
|
|
|
{
|
2016-08-04 07:06:09 +03:00
|
|
|
public partial class LockFingerprintViewController : ExtendedUIViewController
|
2016-07-20 05:38:12 +03:00
|
|
|
{
|
|
|
|
private ISettings _settings;
|
2016-07-20 06:04:37 +03:00
|
|
|
private IFingerprint _fingerprint;
|
2016-07-20 05:38:12 +03:00
|
|
|
|
|
|
|
public LockFingerprintViewController(IntPtr handle) : base(handle)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
public Context Context { get; set; }
|
2016-07-26 04:32:15 +03:00
|
|
|
public LoadingViewController LoadingController { get; set; }
|
2016-07-20 05:38:12 +03:00
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
_settings = Resolver.Resolve<ISettings>();
|
2016-07-20 06:04:37 +03:00
|
|
|
_fingerprint = Resolver.Resolve<IFingerprint>();
|
2016-07-20 05:38:12 +03:00
|
|
|
|
|
|
|
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
|
|
|
|
|
|
|
|
var descriptor = UIFontDescriptor.PreferredBody;
|
2016-07-20 06:04:37 +03:00
|
|
|
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;
|
2016-07-20 05:38:12 +03:00
|
|
|
|
|
|
|
base.ViewDidLoad();
|
|
|
|
}
|
|
|
|
|
2016-07-20 06:04:37 +03:00
|
|
|
private void UseButton_TouchUpInside(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
var task = CheckFingerprintAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void ViewDidAppear(bool animated)
|
|
|
|
{
|
|
|
|
base.ViewDidAppear(animated);
|
|
|
|
var task = CheckFingerprintAsync();
|
|
|
|
}
|
|
|
|
|
2016-07-20 05:38:12 +03:00
|
|
|
partial void CancelButton_Activated(UIBarButtonItem sender)
|
|
|
|
{
|
2016-07-26 04:32:15 +03:00
|
|
|
LoadingController.CompleteRequest(null);
|
2016-07-20 05:38:12 +03:00
|
|
|
}
|
2016-07-20 06:04:37 +03:00
|
|
|
|
2016-07-30 19:44:02 +03:00
|
|
|
partial void FingerprintButton_TouchUpInside(UIButton sender)
|
|
|
|
{
|
|
|
|
var task = CheckFingerprintAsync();
|
|
|
|
}
|
|
|
|
|
2016-07-20 06:04:37 +03:00
|
|
|
public async Task CheckFingerprintAsync()
|
|
|
|
{
|
|
|
|
var result = await _fingerprint.AuthenticateAsync("Use your fingerprint to verify.");
|
|
|
|
if(result.Authenticated)
|
|
|
|
{
|
2016-08-06 06:58:31 +03:00
|
|
|
_settings.AddOrUpdateValue(Constants.Locked, false);
|
2016-07-26 04:32:15 +03:00
|
|
|
LoadingController.DismissLockAndContinue();
|
2016-07-20 06:04:37 +03:00
|
|
|
}
|
|
|
|
}
|
2016-07-20 05:38:12 +03:00
|
|
|
}
|
|
|
|
}
|