mirror of
https://github.com/bitwarden/android.git
synced 2024-12-20 00:02:58 +03:00
Moved lock logic to loading view controller.
This commit is contained in:
parent
047f5b100f
commit
7f5d371bf3
6 changed files with 74 additions and 55 deletions
|
@ -66,7 +66,24 @@ namespace Bit.iOS.Extension
|
|||
public override void ViewDidAppear(bool animated)
|
||||
{
|
||||
base.ViewDidAppear(animated);
|
||||
|
||||
var lockService = Resolver.Resolve<ILockService>();
|
||||
var lockType = lockService.GetLockType(false);
|
||||
switch(lockType)
|
||||
{
|
||||
case App.Enums.LockType.Fingerprint:
|
||||
PerformSegue("lockFingerprintSegue", this);
|
||||
break;
|
||||
case App.Enums.LockType.PIN:
|
||||
PerformSegue("lockPinSegue", this);
|
||||
break;
|
||||
case App.Enums.LockType.Password:
|
||||
PerformSegue("lockPasswordSegue", this);
|
||||
break;
|
||||
default:
|
||||
PerformSegue("siteListSegue", this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
|
||||
|
@ -74,14 +91,46 @@ namespace Bit.iOS.Extension
|
|||
var navController = segue.DestinationViewController as UINavigationController;
|
||||
if(navController != null)
|
||||
{
|
||||
var actionController = navController.TopViewController as SiteListViewController;
|
||||
if(actionController != null)
|
||||
var listSiteController = navController.TopViewController as SiteListViewController;
|
||||
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(listSiteController != null)
|
||||
{
|
||||
actionController.Context = _context;
|
||||
listSiteController.Context = _context;
|
||||
}
|
||||
else if(addSiteController != null)
|
||||
{
|
||||
addSiteController.Context = _context;
|
||||
}
|
||||
else if(fingerprintViewController != null)
|
||||
{
|
||||
fingerprintViewController.Context = _context;
|
||||
fingerprintViewController.LoadingViewController = this;
|
||||
}
|
||||
else if(pinViewController != null)
|
||||
{
|
||||
pinViewController.Context = _context;
|
||||
pinViewController.LoadingViewController = this;
|
||||
}
|
||||
else if(passwordViewController != null)
|
||||
{
|
||||
passwordViewController.Context = _context;
|
||||
passwordViewController.LoadingViewController = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DismissLockAndContinue()
|
||||
{
|
||||
DismissViewController(true, () =>
|
||||
{
|
||||
PerformSegue("siteListSegue", this);
|
||||
});
|
||||
}
|
||||
|
||||
private void SetIoc()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Bit.iOS.Extension
|
|||
{ }
|
||||
|
||||
public Context Context { get; set; }
|
||||
public LoadingViewController LoadingViewController { get; set; }
|
||||
|
||||
public override void ViewWillAppear(bool animated)
|
||||
{
|
||||
|
@ -73,7 +74,7 @@ namespace Bit.iOS.Extension
|
|||
var result = await _fingerprint.AuthenticateAsync("Use your fingerprint to verify.");
|
||||
if(result.Authenticated)
|
||||
{
|
||||
DismissModalViewController(true);
|
||||
LoadingViewController.DismissLockAndContinue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Bit.iOS.Extension
|
|||
{ }
|
||||
|
||||
public Context Context { get; set; }
|
||||
public LoadingViewController LoadingViewController { get; set; }
|
||||
public FormEntryTableViewCell MasterPasswordCell { get; set; } = new FormEntryTableViewCell(
|
||||
AppResources.MasterPassword, useLabelAsPlaceholder: true);
|
||||
|
||||
|
@ -85,7 +86,7 @@ namespace Bit.iOS.Extension
|
|||
if(key.SequenceEqual(_cryptoService.Key))
|
||||
{
|
||||
MasterPasswordCell.TextField.ResignFirstResponder();
|
||||
DismissModalViewController(true);
|
||||
LoadingViewController.DismissLockAndContinue();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace Bit.iOS.Extension
|
|||
{ }
|
||||
|
||||
public Context Context { get; set; }
|
||||
public LoadingViewController LoadingViewController { get; set; }
|
||||
|
||||
public override void ViewWillAppear(bool animated)
|
||||
{
|
||||
|
@ -58,7 +59,7 @@ namespace Bit.iOS.Extension
|
|||
if(PinTextField.Text == _authService.PIN)
|
||||
{
|
||||
PinTextField.ResignFirstResponder();
|
||||
DismissModalViewController(true);
|
||||
LoadingViewController.DismissLockAndContinue();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
</view>
|
||||
<connections>
|
||||
<segue destination="oCZ-GQ-aOK" kind="show" identifier="siteListSegue" id="1679"/>
|
||||
<segue id="8446" destination="6512" kind="presentation" identifier="lockFingerprintSegue" animates="NO"/>
|
||||
<segue id="8924" destination="6815" kind="presentation" identifier="lockPinSegue" animates="NO"/>
|
||||
<segue id="9874" destination="6855" kind="presentation" identifier="lockPasswordSegue" animates="NO"/>
|
||||
<segue id="10498" destination="1845" kind="presentation" identifier="newSiteSegue" modalPresentationStyle="" modalTransitionStyle=""/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="45" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
@ -90,7 +94,7 @@
|
|||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="1849" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1900" y="562"/>
|
||||
<point key="canvasLocation" x="1932" y="-270"/>
|
||||
</scene>
|
||||
<scene sceneID="2086">
|
||||
<objects>
|
||||
|
@ -128,7 +132,7 @@
|
|||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="2093" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2644" y="570"/>
|
||||
<point key="canvasLocation" x="2632" y="-276"/>
|
||||
</scene>
|
||||
<scene sceneID="2303">
|
||||
<objects>
|
||||
|
@ -173,9 +177,6 @@
|
|||
<outlet property="AddBarButton" destination="3736" id="name-outlet-3736"/>
|
||||
<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" animates="NO"/>
|
||||
<segue id="7291" destination="6855" kind="presentation" identifier="lockPasswordSegue" animates="NO"/>
|
||||
</connections>
|
||||
<toolbarItems/>
|
||||
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
|
||||
|
@ -215,7 +216,7 @@
|
|||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4578" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="3357" y="556"/>
|
||||
<point key="canvasLocation" x="3369" y="-276"/>
|
||||
</scene>
|
||||
<scene sceneID="4579">
|
||||
<objects>
|
||||
|
@ -276,7 +277,7 @@
|
|||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4582" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="4045" y="558"/>
|
||||
<point key="canvasLocation" x="4045" y="-272"/>
|
||||
</scene>
|
||||
<scene sceneID="4911">
|
||||
<objects>
|
||||
|
@ -294,7 +295,7 @@
|
|||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4918" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="4676" y="618"/>
|
||||
<point key="canvasLocation" x="4708" y="-194"/>
|
||||
</scene>
|
||||
<scene sceneID="6511">
|
||||
<objects>
|
||||
|
@ -309,7 +310,7 @@
|
|||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="6516" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1906" y="1256"/>
|
||||
<point key="canvasLocation" x="296" y="1394"/>
|
||||
</scene>
|
||||
<scene sceneID="6517">
|
||||
<objects>
|
||||
|
@ -352,7 +353,7 @@
|
|||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="6520" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2655" y="1260"/>
|
||||
<point key="canvasLocation" x="983" y="1390"/>
|
||||
</scene>
|
||||
<scene sceneID="6801">
|
||||
<objects>
|
||||
|
@ -407,7 +408,7 @@
|
|||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="6813" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2653" y="1933"/>
|
||||
<point key="canvasLocation" x="975" y="2083"/>
|
||||
</scene>
|
||||
<scene sceneID="6814">
|
||||
<objects>
|
||||
|
@ -422,7 +423,7 @@
|
|||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="6818" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1886" y="1931"/>
|
||||
<point key="canvasLocation" x="306" y="2083"/>
|
||||
</scene>
|
||||
<scene sceneID="6854">
|
||||
<objects>
|
||||
|
@ -437,7 +438,7 @@
|
|||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="6858" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1878" y="2669"/>
|
||||
<point key="canvasLocation" x="306" y="2759"/>
|
||||
</scene>
|
||||
<scene sceneID="7412">
|
||||
<objects>
|
||||
|
@ -471,7 +472,7 @@
|
|||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="7419" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2532" y="2675"/>
|
||||
<point key="canvasLocation" x="977" y="2775"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Bit.iOS.Core;
|
||||
using Bit.iOS.Extension.Models;
|
||||
using Foundation;
|
||||
|
@ -32,23 +31,6 @@ namespace Bit.iOS.Extension
|
|||
{
|
||||
base.ViewDidLoad();
|
||||
|
||||
var lockService = Resolver.Resolve<ILockService>();
|
||||
var lockType = lockService.GetLockType(false);
|
||||
switch(lockType)
|
||||
{
|
||||
case App.Enums.LockType.Fingerprint:
|
||||
PerformSegue("lockFingerprintSegue", this);
|
||||
break;
|
||||
case App.Enums.LockType.PIN:
|
||||
PerformSegue("lockPinSegue", this);
|
||||
break;
|
||||
case App.Enums.LockType.Password:
|
||||
PerformSegue("lockPasswordSegue", this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
IEnumerable<SiteViewModel> filteredSiteModels = new List<SiteViewModel>();
|
||||
if(Context.DomainName != null)
|
||||
{
|
||||
|
@ -88,27 +70,11 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue