Refactor and merge code of extensions

This commit is contained in:
Mingshen Sun 2021-01-10 13:40:17 -08:00
parent 87d1dd5be1
commit 776884e894
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
13 changed files with 391 additions and 446 deletions

View file

@ -9,63 +9,6 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Password Store-->
<scene sceneID="Uma-9u-xWV">
<objects>
<viewController id="Xki-Si-B7m" customClass="PasswordsViewController" customModule="passAutoFillExtension" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="BuU-Ak-iZz">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="XmI-l4-SgT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="passwordTableViewCell" textLabel="U0x-8f-AET" detailTextLabel="kY1-Ac-C3d" style="IBUITableViewCellStyleValue1" id="fXA-SG-IOe" customClass="PasswordTableViewCell" customModule="passAutoFillExtension" customModuleProvider="target">
<rect key="frame" x="0.0" y="55.5" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="fXA-SG-IOe" id="KPa-Az-i6V">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="U0x-8f-AET">
<rect key="frame" x="16" y="12" width="33" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="kY1-Ac-C3d">
<rect key="frame" x="315" y="12" width="44" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<navigationItem key="navigationItem" title="Password Store" prompt="url" id="apM-bN-eca">
<barButtonItem key="leftBarButtonItem" style="plain" systemItem="cancel" id="zCC-lm-1xr">
<connections>
<action selector="cancel:" destination="Xki-Si-B7m" id="CgJ-49-QwT"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="tableView" destination="XmI-l4-SgT" id="9k1-t7-Xnc"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="RwB-HB-TSk" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="992.79999999999995" y="26.53673163418291"/>
</scene>
<!--Credential Provider View Controller-->
<scene sceneID="Ebu-3J-rOU">
<objects>
@ -90,9 +33,20 @@
</objects>
<point key="canvasLocation" x="-946.39999999999998" y="26.53673163418291"/>
</scene>
<!--SearchPassword-->
<scene sceneID="sDa-xb-78h">
<objects>
<viewControllerPlaceholder storyboardName="SearchPassword" id="SvX-bP-rbb" sceneMemberID="viewController">
<navigationItem key="navigationItem" id="SpE-87-sGe"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="00W-OZ-EmF" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="788" y="26"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="mg9-JA-x9T">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="ydk-0z-dUy" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="Aeb-0C-dDR" sceneMemberID="viewController">
<toolbarItems/>
<navigationItem key="navigationItem" id="d0b-i7-rXf"/>
@ -102,10 +56,9 @@
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="Xki-Si-B7m" kind="relationship" relationship="rootViewController" id="Jjj-k4-Bbd"/>
<segue destination="SvX-bP-rbb" kind="relationship" relationship="rootViewController" id="MFO-5M-l7I"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ydk-0z-dUy" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53.600000000000001" y="26.53673163418291"/>
</scene>

View file

@ -32,6 +32,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
let dataSource = PasswordsTableDataSource(entries: passwordsTableEntries)
passwordsViewController.dataSource = dataSource
passwordsViewController.selectionDelegate = self
passwordsViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancel))
}
override func prepareCredentialList(for serviceIdentifiers: [ASCredentialServiceIdentifier]) {
@ -58,6 +59,11 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
passwordsViewController.navigationItem.prompt = identifier
passwordsViewController.showPasswordsWithSuggstion(matching: identifier)
}
@objc
private func cancel(_: AnyObject?) {
self.extensionContext.cancelRequest(withError: NSError(domain: "PassExtension", code: 0))
}
}
extension CredentialProviderViewController: PasswordSelectionDelegate {

View file

@ -12,9 +12,9 @@ import passKit
// cancel means cancel the extension
class PasscodeLockViewControllerForExtension: PasscodeLockViewController {
var originalExtensionContext: ASCredentialProviderExtensionContext!
var originalExtensionContext: NSExtensionContext!
convenience init(extensionContext: ASCredentialProviderExtensionContext) {
convenience init(extensionContext: NSExtensionContext) {
self.init()
self.originalExtensionContext = extensionContext
}
@ -27,15 +27,15 @@ class PasscodeLockViewControllerForExtension: PasscodeLockViewController {
@objc
func cancelExtension() {
originalExtensionContext.cancelRequest(withError: NSError(domain: ASExtensionErrorDomain, code: ASExtensionError.userCanceled.rawValue))
originalExtensionContext.cancelRequest(withError: NSError(domain: "PassExtension", code: 0))
}
}
class PasscodeExtensionDisplay {
private let passcodeLockVC: PasscodeLockViewControllerForExtension
private let extensionContext: ASCredentialProviderExtensionContext?
private let extensionContext: NSExtensionContext?
init(extensionContext: ASCredentialProviderExtensionContext) {
init(extensionContext: NSExtensionContext) {
self.extensionContext = extensionContext
self.passcodeLockVC = PasscodeLockViewControllerForExtension(extensionContext: extensionContext)
passcodeLockVC.setCancellable(true)

View file

@ -47,12 +47,6 @@ class PasswordsViewController: UIViewController {
dataSource.showTableEntriesWithSuggestion(matching: text)
tableView.reloadData()
}
@IBAction
private func cancel(_: AnyObject?) {
self.extensionContext?.cancelRequest(withError: NSError(domain: ASExtensionErrorDomain, code: ASExtensionError.userCanceled.rawValue))
self.dismiss(animated: true)
}
}
extension PasswordsViewController: UISearchBarDelegate {

View file

@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>$(PRODUCT_NAME)</string>
<string>Pass</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="WVw-Ck-H1t">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Password Store-->
<scene sceneID="Q0D-bP-v18">
<objects>
<viewController id="WVw-Ck-H1t" customClass="PasswordsViewController" customModule="passAutoFillExtension" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="owN-l8-xf3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="4ye-B2-IJQ">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="passwordTableViewCell" textLabel="EBG-Ig-X29" detailTextLabel="cy6-w7-gwt" style="IBUITableViewCellStyleValue1" id="VQv-m5-GNR" customClass="PasswordTableViewCell" customModule="passAutoFillExtension" customModuleProvider="target">
<rect key="frame" x="0.0" y="55.5" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="VQv-m5-GNR" id="Ypj-Vf-x6H">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="EBG-Ig-X29">
<rect key="frame" x="20" y="12" width="33" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="cy6-w7-gwt">
<rect key="frame" x="350" y="12" width="44" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<viewLayoutGuide key="safeArea" id="Zkt-0U-evx"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<navigationItem key="navigationItem" title="Password Store" prompt="Select Password" id="qdN-Ea-jGZ"/>
<connections>
<outlet property="tableView" destination="4ye-B2-IJQ" id="cen-WZ-u7e"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Byi-Tx-CZe" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="992.79999999999995" y="26.53673163418291"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>