Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions PasscodeLock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
281AA9201DB626E000908E23 /* Localize.strings in Resources */ = {isa = PBXBuildFile; fileRef = 281AA9221DB626E000908E23 /* Localize.strings */; };
4A57CCF92010A437006A7B80 /* Localize.strings in Resources */ = {isa = PBXBuildFile; fileRef = 281AA9221DB626E000908E23 /* Localize.strings */; };
8F3B9D031E028815008CF18F /* PasscodeLockImages.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8F3B9D021E028815008CF18F /* PasscodeLockImages.xcassets */; };
C99EAF431B90B05700D61E1B /* PasscodeLock.h in Headers */ = {isa = PBXBuildFile; fileRef = C99EAF421B90B05700D61E1B /* PasscodeLock.h */; settings = {ATTRIBUTES = (Public, ); }; };
C99EAF4A1B90B05800D61E1B /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; };
Expand Down Expand Up @@ -516,6 +517,7 @@
C9D3DF1D1B91AD11008561EB /* LaunchScreen.storyboard in Resources */,
C9D3DF1A1B91AD11008561EB /* Assets.xcassets in Resources */,
C9D3DF181B91AD11008561EB /* Main.storyboard in Resources */,
4A57CCF92010A437006A7B80 /* Localize.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 1 addition & 0 deletions PasscodeLock/Base.lproj/Localize.strings
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
"Cancel" = "Cancel";
"Delete" = "Delete";
"UseTouchId" = "Use TouchID";
"UseFaceId" = "Use FaceID";
4 changes: 2 additions & 2 deletions PasscodeLock/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func localizedStringFor(_ key: String, comment: String) -> String {

let name = "Localize"
let bundle = bundleForResource(name, ofType: "strings")
return NSLocalizedString(key, tableName: name, bundle: bundle, comment: comment)

return NSLocalizedString(key, tableName: name, bundle: bundle, value: "", comment: comment)
}

func bundleForResource(_ name: String, ofType type: String) -> Bundle {
Expand Down
4 changes: 3 additions & 1 deletion PasscodeLock/PasscodeLockPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public struct StringsToBeDisplayed {
public var cancel: String?
public var delete: String?
public var useTouchID: String?
public var useFaceID: String?

public init(passcodeLockEnterTitle: String?, passcodeLockEnterDescription: String?, passcodeLockSetTitle: String?, passcodeLockSetDescription: String?, passcodeLockConfirmTitle: String?, passcodeLockConfirmDescription: String?, passcodeLockChangeTitle: String?, passcodeLockChangeDescription: String?, passcodeLockMismatchTitle: String?, passcodeLockMismatchDescription: String?, passcodeLockTouchIDReason: String?, passcodeLockTouchIDButton: String?, cancel: String?, delete: String?, useTouchID: String?) {
public init(passcodeLockEnterTitle: String?, passcodeLockEnterDescription: String?, passcodeLockSetTitle: String?, passcodeLockSetDescription: String?, passcodeLockConfirmTitle: String?, passcodeLockConfirmDescription: String?, passcodeLockChangeTitle: String?, passcodeLockChangeDescription: String?, passcodeLockMismatchTitle: String?, passcodeLockMismatchDescription: String?, passcodeLockTouchIDReason: String?, passcodeLockTouchIDButton: String?, cancel: String?, delete: String?, useTouchID: String?, useFaceID: String?) {

self.passcodeLockEnterTitle = passcodeLockEnterTitle
self.passcodeLockEnterDescription = passcodeLockEnterDescription
Expand All @@ -45,6 +46,7 @@ public struct StringsToBeDisplayed {
self.cancel = cancel
self.delete = delete
self.useTouchID = useTouchID
self.useFaceID = useFaceID
}
}

Expand Down
27 changes: 20 additions & 7 deletions PasscodeLock/PasscodeLockViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import LocalAuthentication

open class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegate {

Expand Down Expand Up @@ -111,22 +112,34 @@ open class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegat
}
}

internal func updatePasscodeView() {
internal func updatePasscodeView() {

self.customImageView?.image = self.customImage
self.titleLabel?.text = passcodeLock.state.title
self.titleLabel?.text = passcodeLock.state.title
self.titleLabel?.font = self.font
self.titleLabel?.textColor = self.customTintColor
self.descriptionLabel?.text = passcodeLock.state.description
self.touchIDButton?.isHidden = !passcodeLock.isTouchIDAllowed
self.touchIDButton?.setTitle((self.stringsToShow?.useTouchID ?? localizedStringFor("UseTouchId", comment: "")), for: UIControlState())
self.touchIDButton?.setTitleColor(self.customTintColor, for: UIControlState())
self.descriptionLabel?.text = passcodeLock.state.description
self.touchIDButton?.isHidden = !passcodeLock.isTouchIDAllowed

var useBiometrics: String = localizedStringFor("UseTouchId", comment: "")
var useBiomatricsToShow: String? = self.stringsToShow?.useTouchID
if #available(iOS 11.0, *) {
let context = LAContext()
context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil)
let bioType = context.biometryType
if (bioType == .faceID) {
useBiometrics = localizedStringFor("UseFaceId", comment: "")
useBiomatricsToShow = self.stringsToShow?.useFaceID
}
}

self.touchIDButton?.setTitle((useBiomatricsToShow ?? useBiometrics), for: UIControlState())
self.passcodeButtons?.forEach({ (passcodeButton: PasscodeSignButton) in
passcodeButton.tintColor = self.customTintColor
})

self.cancelDeleteButtonSetup()
}
}

// MARK: - Events

Expand Down
37 changes: 24 additions & 13 deletions PasscodeLock/Views/PasscodeLockView.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16G1114" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina3_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
Expand Down Expand Up @@ -328,23 +328,33 @@
<action selector="deleteSignButtonTap:" destination="-1" eventType="touchUpInside" id="uXY-lj-GdX"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Ph-dj-v7R" userLabel="TouchID Button">
<rect key="frame" x="112" y="444" width="96" height="26"/>
<inset key="contentEdgeInsets" minX="4" minY="4" maxX="4" maxY="4"/>
<state key="normal" title="Use TouchID">
<color key="titleColor" red="0.0" green="0.3921568627" blue="0.64705882349999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="touchIDButtonTap:" destination="-1" eventType="touchUpInside" id="MT9-Ev-GsW"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Rqp-GG-saa">
<rect key="frame" x="0.0" y="115.5" width="320" height="16"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0IE-Ei-nOQ">
<rect key="frame" x="0.0" y="467.5" width="320" height="12.5"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Ph-dj-v7R" userLabel="TouchID Button">
<rect key="frame" x="112" y="-6.5" width="96" height="26"/>
<inset key="contentEdgeInsets" minX="4" minY="4" maxX="4" maxY="4"/>
<state key="normal" title="Use TouchID">
<color key="titleColor" red="0.0" green="0.3921568627" blue="0.64705882349999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="touchIDButtonTap:" destination="-1" eventType="touchUpInside" id="MT9-Ev-GsW"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="0Ph-dj-v7R" firstAttribute="centerY" secondItem="0IE-Ei-nOQ" secondAttribute="centerY" id="CIU-5o-Im8"/>
<constraint firstItem="0Ph-dj-v7R" firstAttribute="centerX" secondItem="0IE-Ei-nOQ" secondAttribute="centerX" id="Cud-bg-mLZ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.96862745098039216" green="0.96862745098039216" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="0IE-Ei-nOQ" firstAttribute="top" secondItem="0CR-0R-0Nr" secondAttribute="bottom" id="07Z-f8-ROb"/>
<constraint firstItem="0CR-0R-0Nr" firstAttribute="centerX" secondItem="PbJ-Y8-MMf" secondAttribute="centerX" id="16E-tM-5HY"/>
<constraint firstItem="RR4-5o-pli" firstAttribute="width" secondItem="cuq-ue-Jyj" secondAttribute="width" id="1Y8-V9-aBS"/>
<constraint firstItem="cuq-ue-Jyj" firstAttribute="top" secondItem="CGh-ph-49t" secondAttribute="top" id="1pk-a8-KUM"/>
Expand All @@ -355,7 +365,7 @@
<constraint firstItem="pLy-90-g1a" firstAttribute="leading" secondItem="CGh-ph-49t" secondAttribute="trailing" constant="24" id="6jk-5n-EC0"/>
<constraint firstItem="cuq-ue-Jyj" firstAttribute="trailing" secondItem="CGh-ph-49t" secondAttribute="leading" constant="-24" id="6wf-5d-CCI"/>
<constraint firstItem="CGh-ph-49t" firstAttribute="height" secondItem="cuq-ue-Jyj" secondAttribute="height" id="8C1-7Z-93C"/>
<constraint firstItem="0Ph-dj-v7R" firstAttribute="bottom" secondItem="iN0-l3-epB" secondAttribute="bottom" constant="-10" id="BIJ-v9-DKU"/>
<constraint firstAttribute="trailing" secondItem="0IE-Ei-nOQ" secondAttribute="trailing" id="CUA-F7-xuM"/>
<constraint firstItem="RR4-5o-pli" firstAttribute="centerX" secondItem="cuq-ue-Jyj" secondAttribute="centerX" id="EsN-cG-KcQ"/>
<constraint firstItem="Rqp-GG-saa" firstAttribute="top" secondItem="HcN-lo-9Jb" secondAttribute="bottom" id="Exa-HL-6AW"/>
<constraint firstItem="HcN-lo-9Jb" firstAttribute="top" secondItem="1wK-Ol-7mm" secondAttribute="bottom" constant="21" id="FU1-S4-Dgn"/>
Expand Down Expand Up @@ -387,10 +397,10 @@
<constraint firstAttribute="trailing" secondItem="Rqp-GG-saa" secondAttribute="trailing" id="bt3-RR-PYG"/>
<constraint firstItem="CGh-ph-49t" firstAttribute="width" secondItem="cuq-ue-Jyj" secondAttribute="width" id="cKS-R3-cbB"/>
<constraint firstItem="CGh-ph-49t" firstAttribute="bottom" secondItem="C9Z-3u-ohd" secondAttribute="top" constant="-16" id="diZ-Kj-1hU"/>
<constraint firstItem="0IE-Ei-nOQ" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="f5L-iG-gsC"/>
<constraint firstItem="C9Z-3u-ohd" firstAttribute="height" secondItem="cuq-ue-Jyj" secondAttribute="height" id="f9I-Gc-Ro2"/>
<constraint firstItem="pLy-90-g1a" firstAttribute="width" secondItem="cuq-ue-Jyj" secondAttribute="width" id="fZe-Hh-Jwx"/>
<constraint firstItem="1wK-Ol-7mm" firstAttribute="top" secondItem="chh-VR-PhS" secondAttribute="bottom" constant="10" id="gxv-9b-Ycv"/>
<constraint firstItem="0Ph-dj-v7R" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="i6j-iI-02e"/>
<constraint firstItem="PbJ-Y8-MMf" firstAttribute="height" secondItem="cuq-ue-Jyj" secondAttribute="height" id="iBA-3z-Eff"/>
<constraint firstItem="RA8-jd-dag" firstAttribute="centerX" secondItem="RR4-5o-pli" secondAttribute="centerX" id="inw-ZS-osP"/>
<constraint firstItem="EUD-XB-0CR" firstAttribute="width" secondItem="cuq-ue-Jyj" secondAttribute="width" id="jYu-vM-ZAZ"/>
Expand All @@ -402,6 +412,7 @@
<constraint firstItem="PbJ-Y8-MMf" firstAttribute="width" secondItem="cuq-ue-Jyj" secondAttribute="width" id="qzR-s7-A2R"/>
<constraint firstItem="EUD-XB-0CR" firstAttribute="height" secondItem="cuq-ue-Jyj" secondAttribute="height" id="voC-UM-LiW"/>
<constraint firstItem="chh-VR-PhS" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="wfT-B6-6MJ"/>
<constraint firstAttribute="bottom" secondItem="0IE-Ei-nOQ" secondAttribute="bottom" id="yIp-yD-2Eq"/>
<constraint firstItem="RR4-5o-pli" firstAttribute="top" secondItem="cuq-ue-Jyj" secondAttribute="bottom" constant="16" id="ymC-lk-DI6"/>
<constraint firstItem="WDx-aD-wJK" firstAttribute="height" secondItem="cuq-ue-Jyj" secondAttribute="height" id="zgS-rv-c0P"/>
</constraints>
Expand Down
1 change: 1 addition & 0 deletions PasscodeLock/de.lproj/Localize.strings
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
"Cancel" = "Abbrechen";
"Delete" = "Löschen";
"UseTouchId" = "TouchID verwenden";
"UseFaceId" = "FaceID verwenden";
38 changes: 38 additions & 0 deletions PasscodeLock/en.lproj/Localize.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Localize.strings
PasscodeLock

Created by Ramiro Ramirez on 18/10/16.
Copyright © 2016 Yanko Dimitrov. All rights reserved.
*/

/* Enter Passcode State */
"PasscodeLockEnterTitle" = "Enter Passcode";
"PasscodeLockEnterDescription" = "Enter your passcode to proceed.";

/* Set Passcode State */
"PasscodeLockSetTitle" = "Enter a Passcode";
"PasscodeLockSetDescription" = "Choose your passcode.";

/* Confirm Passcode State */
"PasscodeLockConfirmTitle" = "Confirm Passcode";
"PasscodeLockConfirmDescription" = "Enter the passcode again.";

/* Change Passcode State */
"PasscodeLockChangeTitle" = "Enter Old Passcode";
"PasscodeLockChangeDescription" = "Enter your old passcode.";

/* Passcode Mismatch State */
"PasscodeLockMismatchTitle" = "Try again";
"PasscodeLockMismatchDescription" = "Passcodes didn\'t match.";

/* Touch ID Reason */
"PasscodeLockTouchIDReason" = "Authentication required to proceed";

/* Touch ID Fallback Button */
"PasscodeLockTouchIDButton" = "Enter Passcode";

"Cancel" = "Cancel";
"Delete" = "Delete";
"UseTouchId" = "Use TouchID";
"UseFaceId" = "Use FaceID";