mirror of
https://github.com/bitwarden/mobile
synced 2025-12-18 09:13:15 +00:00
moved view controllers to core library for reuse
This commit is contained in:
@@ -1,68 +1,19 @@
|
||||
using System;
|
||||
using Bit.iOS.Extension.Models;
|
||||
using UIKit;
|
||||
using XLabs.Ioc;
|
||||
using Plugin.Fingerprint.Abstractions;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.iOS.Core.Controllers;
|
||||
using Bit.App.Resources;
|
||||
using Bit.App.Abstractions;
|
||||
|
||||
namespace Bit.iOS.Extension
|
||||
{
|
||||
public partial class LockFingerprintViewController : ExtendedUIViewController
|
||||
public partial class LockFingerprintViewController : Core.Controllers.LockFingerprintViewController
|
||||
{
|
||||
private IAppSettingsService _appSettingsService;
|
||||
private IFingerprint _fingerprint;
|
||||
private IDeviceInfoService _deviceInfo;
|
||||
|
||||
public LockFingerprintViewController(IntPtr handle) : base(handle)
|
||||
{ }
|
||||
|
||||
public Context Context { get; set; }
|
||||
public LoadingViewController LoadingController { get; set; }
|
||||
|
||||
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()
|
||||
{
|
||||
_appSettingsService = Resolver.Resolve<IAppSettingsService>();
|
||||
_fingerprint = Resolver.Resolve<IFingerprint>();
|
||||
_deviceInfo = Resolver.Resolve<IDeviceInfoService>();
|
||||
|
||||
NavItem.Title = _deviceInfo.HasFaceIdSupport ? AppResources.VerifyFaceID : AppResources.VerifyFingerprint;
|
||||
CancelButton.Title = AppResources.Cancel;
|
||||
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
|
||||
|
||||
UseButton.SetTitle(_deviceInfo.HasFaceIdSupport ? AppResources.UseFaceIDToUnlock :
|
||||
AppResources.UseFingerprintToUnlock, UIControlState.Normal);
|
||||
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;
|
||||
|
||||
FingerprintButton.SetImage(new UIImage(_deviceInfo.HasFaceIdSupport ? "smile.png" : "fingerprint.png"),
|
||||
UIControlState.Normal);
|
||||
|
||||
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();
|
||||
}
|
||||
public override UINavigationItem BaseNavItem => NavItem;
|
||||
public override UIBarButtonItem BaseCancelButton => CancelButton;
|
||||
public override UIButton BaseUseButton => UseButton;
|
||||
public override UIButton BaseFingerprintButton => FingerprintButton;
|
||||
public override Action Success => () => LoadingController.DismissLockAndContinue();
|
||||
|
||||
partial void CancelButton_Activated(UIBarButtonItem sender)
|
||||
{
|
||||
@@ -73,22 +24,5 @@ namespace Bit.iOS.Extension
|
||||
{
|
||||
var task = CheckFingerprintAsync();
|
||||
}
|
||||
|
||||
public async Task CheckFingerprintAsync()
|
||||
{
|
||||
var fingerprintRequest = new AuthenticationRequestConfiguration(
|
||||
_deviceInfo.HasFaceIdSupport ? AppResources.FaceIDDirection : AppResources.FingerprintDirection)
|
||||
{
|
||||
AllowAlternativeAuthentication = true,
|
||||
CancelTitle = AppResources.Cancel,
|
||||
FallbackTitle = AppResources.LogOut
|
||||
};
|
||||
var result = await _fingerprint.AuthenticateAsync(fingerprintRequest);
|
||||
if(result.Authenticated)
|
||||
{
|
||||
_appSettingsService.Locked = false;
|
||||
LoadingController.DismissLockAndContinue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user