Update the passcode lock view

This commit is contained in:
Yishi Lin 2019-09-29 00:28:46 +08:00
parent 35f599c45b
commit c4f0462d43
6 changed files with 63 additions and 16 deletions

View file

@ -88,6 +88,7 @@
A239F59C2158C08C00576CBF /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A239F59A2158C08C00576CBF /* MainInterface.storyboard */; };
A239F5A12158C08C00576CBF /* passAutoFillExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = A239F5952158C08B00576CBF /* passAutoFillExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
A239F5A52158C3F400576CBF /* passKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A26075781EEC6F34005DB03E /* passKit.framework */; };
A23DD0DC233FB46900E6CD83 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A23DD0DB233FB46900E6CD83 /* Assets.xcassets */; };
A26075811EEC6F34005DB03E /* passKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A26075781EEC6F34005DB03E /* passKit.framework */; };
A26075881EEC6F34005DB03E /* passKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A26075871EEC6F34005DB03E /* passKitTests.swift */; };
A260758A1EEC6F34005DB03E /* passKit.h in Headers */ = {isa = PBXBuildFile; fileRef = A260757A1EEC6F34005DB03E /* passKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -299,6 +300,7 @@
A239F59B2158C08C00576CBF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
A239F59D2158C08C00576CBF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A239F59E2158C08C00576CBF /* passAutoFillExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = passAutoFillExtension.entitlements; sourceTree = "<group>"; };
A23DD0DB233FB46900E6CD83 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A26075781EEC6F34005DB03E /* passKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = passKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A260757A1EEC6F34005DB03E /* passKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = passKit.h; sourceTree = "<group>"; };
A260757B1EEC6F34005DB03E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@ -603,6 +605,7 @@
A2F4E20F1EED7F0A0011986E /* Helpers */,
A2F4E20E1EED7F040011986E /* Models */,
30C015A3214ECF2B005BB6DF /* Parser */,
A23DD0DB233FB46900E6CD83 /* Assets.xcassets */,
A260757A1EEC6F34005DB03E /* passKit.h */,
A26075A51EEC7125005DB03E /* pass.xcdatamodeld */,
A260757B1EEC6F34005DB03E /* Info.plist */,
@ -1065,6 +1068,7 @@
files = (
556EC3DA22335D3400934F9C /* InfoPlist.strings in Resources */,
556EC3D522335CD900934F9C /* Localizable.strings in Resources */,
A23DD0DC233FB46900E6CD83 /* Assets.xcassets in Resources */,
556EC3D622335CD900934F9C /* Localizable.stringsdict in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -1822,6 +1826,8 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = NO;
ENABLE_ON_DEMAND_RESOURCES = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/iOS";
@ -1888,7 +1894,9 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = NO;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_ON_DEMAND_RESOURCES = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/iOS";
GCC_C_LANGUAGE_STANDARD = gnu99;

View file

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Icon-72.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -17,7 +17,6 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
open var successCallback: (()->Void)?
open var cancelCallback: (()->Void)?
weak var passcodeLabel: UILabel?
weak var passcodeTextField: UITextField?
weak var biometryAuthButton: UIButton?
weak var forgotPasscodeButton: UIButton?
@ -30,14 +29,6 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
open override func loadView() {
super.loadView()
let passcodeLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 40))
passcodeLabel.text = "EnterPasscode".localize()
passcodeLabel.font = UIFont.boldSystemFont(ofSize: 18)
passcodeLabel.textAlignment = .center
passcodeLabel.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(passcodeLabel)
self.passcodeLabel = passcodeLabel
let passcodeTextField = UITextField(frame: CGRect(x: 0, y: 0, width: 300, height: 40))
passcodeTextField.borderStyle = UITextField.BorderStyle.roundedRect
passcodeTextField.placeholder = "EnterPasscode".localize()
@ -100,19 +91,29 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
cancelButton.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.left
self.view.addSubview(cancelButton)
self.cancelButton = cancelButton
// Display the Pass icon in the middle of the screen
let bundle = Bundle(for: PasscodeLockViewController.self)
let appIcon = UIImage(named: "PasscodeLockViewIcon", in: bundle, compatibleWith: nil)
let appIconSize = (appIcon?.size.height) ?? 0
let appIconView = UIImageView(image: appIcon)
appIconView.translatesAutoresizingMaskIntoConstraints = false
appIconView.layer.cornerRadius = appIconSize / 5
appIconView.layer.masksToBounds = true
self.view?.addSubview(appIconView)
NSLayoutConstraint.activate([
passcodeTextField.widthAnchor.constraint(equalToConstant: 300),
passcodeTextField.widthAnchor.constraint(equalToConstant: 250),
passcodeTextField.heightAnchor.constraint(equalToConstant: 40),
passcodeTextField.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
passcodeTextField.centerYAnchor.constraint(equalTo: self.view.centerYAnchor, constant: -20),
// above passocde
passcodeLabel.widthAnchor.constraint(equalToConstant: 300),
passcodeLabel.heightAnchor.constraint(equalToConstant: 40),
passcodeLabel.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
passcodeLabel.bottomAnchor.constraint(equalTo: passcodeTextField.topAnchor),
appIconView.widthAnchor.constraint(equalToConstant: appIconSize),
appIconView.heightAnchor.constraint(equalToConstant: appIconSize),
appIconView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
appIconView.bottomAnchor.constraint(equalTo: passcodeTextField.topAnchor, constant: -appIconSize),
// below passcode
biometryAuthButton.widthAnchor.constraint(equalToConstant: 300),
biometryAuthButton.widthAnchor.constraint(equalToConstant: 250),
biometryAuthButton.heightAnchor.constraint(equalToConstant: 40),
biometryAuthButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
biometryAuthButton.topAnchor.constraint(equalTo: passcodeTextField.bottomAnchor),
@ -122,7 +123,7 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
cancelButton.topAnchor.constraint(equalTo: self.view.safeTopAnchor),
cancelButton.leftAnchor.constraint(equalTo: self.view.safeLeftAnchor, constant: 20),
// bottom of the screen
forgotPasscodeButton.widthAnchor.constraint(equalToConstant: 300),
forgotPasscodeButton.widthAnchor.constraint(equalToConstant: 250),
forgotPasscodeButton.heightAnchor.constraint(equalToConstant: 40),
forgotPasscodeButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
forgotPasscodeButton.bottomAnchor.constraint(equalTo: self.view.safeBottomAnchor, constant: -40)
@ -227,6 +228,7 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
self.passcodeTextField?.placeholder =
"TryAgain".localize()
self.passcodeTextField?.text = ""
self.passcodeTextField?.shake()
}
}
textField.resignFirstResponder()

View file

@ -20,4 +20,14 @@ extension UITextField {
objc_setAssociatedObject(self, &kAssociationKeyNextField, newField, .OBJC_ASSOCIATION_RETAIN)
}
}
func shake() {
let animation = CAKeyframeAnimation(keyPath: "transform.translation.x")
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
animation.repeatCount = 3
animation.duration = 0.2/TimeInterval(animation.repeatCount)
animation.autoreverses = true
animation.values = [3, -3]
layer.add(animation, forKey: "shake")
}
}