Skip to content

Commit

Permalink
Merge pull request #8 from regulaforensics/api-updates
Browse files Browse the repository at this point in the history
Api updates
  • Loading branch information
DzmitrySmaliakou authored Jul 6, 2022
2 parents 56accb3 + fca7589 commit 82ae0a7
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Catalog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
86D5E2A1266123480076D417 /* LivenessLogoItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86D5E2A0266123480076D417 /* LivenessLogoItem.swift */; };
86D5E2A7266128160076D417 /* FaceCaptureBackgroundColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86D5E2A6266128160076D417 /* FaceCaptureBackgroundColor.swift */; };
86E7479A265D2AB500767F52 /* URLRequestInterceptorItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86E74799265D2AB500767F52 /* URLRequestInterceptorItem.swift */; };
9DE86D912850820400FCC18C /* LivenessHideTorchConfigurationItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE86D8F2850820400FCC18C /* LivenessHideTorchConfigurationItem.swift */; };
9DE86D922850820400FCC18C /* FaceCaptureHideTorchConfigurationItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE86D902850820400FCC18C /* FaceCaptureHideTorchConfigurationItem.swift */; };
9DE86D942850820C00FCC18C /* LivenessProcessAndRetryCustomization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE86D932850820C00FCC18C /* LivenessProcessAndRetryCustomization.swift */; };
F1D3B0BD2ECCF5ED96E71FEB /* Pods_Catalog.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1DBE93D03DA4D5B36021E6A /* Pods_Catalog.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -104,6 +107,9 @@
86D5E2A0266123480076D417 /* LivenessLogoItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LivenessLogoItem.swift; sourceTree = "<group>"; };
86D5E2A6266128160076D417 /* FaceCaptureBackgroundColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceCaptureBackgroundColor.swift; sourceTree = "<group>"; };
86E74799265D2AB500767F52 /* URLRequestInterceptorItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLRequestInterceptorItem.swift; sourceTree = "<group>"; };
9DE86D8F2850820400FCC18C /* LivenessHideTorchConfigurationItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LivenessHideTorchConfigurationItem.swift; sourceTree = "<group>"; };
9DE86D902850820400FCC18C /* FaceCaptureHideTorchConfigurationItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FaceCaptureHideTorchConfigurationItem.swift; sourceTree = "<group>"; };
9DE86D932850820C00FCC18C /* LivenessProcessAndRetryCustomization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LivenessProcessAndRetryCustomization.swift; sourceTree = "<group>"; };
D1DBE93D03DA4D5B36021E6A /* Pods_Catalog.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Catalog.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EE68E96211232EE8DBF2FE18 /* Pods-Catalog.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Catalog.release.xcconfig"; path = "Target Support Files/Pods-Catalog/Pods-Catalog.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -141,6 +147,8 @@
86133D6A26568CBE00546D8A /* Features */ = {
isa = PBXGroup;
children = (
9DE86D902850820400FCC18C /* FaceCaptureHideTorchConfigurationItem.swift */,
9DE86D8F2850820400FCC18C /* LivenessHideTorchConfigurationItem.swift */,
86B6D2D32653E84200794170 /* LivenessCameraSwitchItem.swift */,
86CED8F42664E123008CC8AA /* LivenessAttemptsCountItem.swift */,
86CED8FF2664F319008CC8AA /* LivenessHintAnimationItem.swift */,
Expand Down Expand Up @@ -239,6 +247,7 @@
86B6D2F62655306500794170 /* ViewCustomization */ = {
isa = PBXGroup;
children = (
9DE86D932850820C00FCC18C /* LivenessProcessAndRetryCustomization.swift */,
86B6D2F126552EF800794170 /* LivenessHintViewAppearanceItem.swift */,
86D5E284266116B80076D417 /* LivenessHintPositionItem.swift */,
86D5E288266118400076D417 /* LivenessToolbarAppearanceItem.swift */,
Expand Down Expand Up @@ -413,15 +422,18 @@
86B6D2F226552EF800794170 /* LivenessHintViewAppearanceItem.swift in Sources */,
86D5E285266116B80076D417 /* LivenessHintPositionItem.swift in Sources */,
86D5E2A1266123480076D417 /* LivenessLogoItem.swift in Sources */,
9DE86D912850820400FCC18C /* LivenessHideTorchConfigurationItem.swift in Sources */,
86133D5426565E2B00546D8A /* FaceCaptureDefaultItem.swift in Sources */,
86B2D28B26555BCE00D85D45 /* LocalizationHandlerItem.swift in Sources */,
86B2D2802655593600D85D45 /* LivenessHideTorchItem.swift in Sources */,
9DE86D942850820C00FCC18C /* LivenessProcessAndRetryCustomization.swift in Sources */,
86E7479A265D2AB500767F52 /* URLRequestInterceptorItem.swift in Sources */,
86CED8F52664E123008CC8AA /* LivenessAttemptsCountItem.swift in Sources */,
86B6D29E2653D50500794170 /* AppDelegate.swift in Sources */,
86C2559B2681E34D00067907 /* LivenessToolbarCustomColors.swift in Sources */,
86B6D2A02653D50500794170 /* SceneDelegate.swift in Sources */,
86CED9032664F376008CC8AA /* FaceCaptureHintAnimationItem.swift in Sources */,
9DE86D922850820400FCC18C /* FaceCaptureHideTorchConfigurationItem.swift in Sources */,
86951B542657E30D00FB23D8 /* UIColor+Hex.swift in Sources */,
86D5E28D26611A690076D417 /* LivenessToolbarPositionItem.swift in Sources */,
8611D4442657A47000E4E700 /* ImagesPreviewViewController.swift in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions Catalog/Core/CatalogTableDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ final class CatalogTableDataProvider {
LivenessCameraSwitchItem(),
LivenessAttemptsCountItem(),
LivenessHintAnimationItem(),
LivenessHideTorchConfigurationItem(),
FaceCaptureCameraPositionItem(),
FaceCaptureHintAnimationItem(),
FaceCaptureHideTorchConfigurationItem(),

LivenessHintViewAppearanceItem(),
LivenessHintPositionItem(),
Expand All @@ -41,6 +43,7 @@ final class CatalogTableDataProvider {
LivenessToolbarCustomButtonItem(),
LivenessToolbarCustomColors(),
LivenessLogoItem(),
LivenessCustomProcessingAndRetryScreensItem(),
FaceCaptureBackgroundColor(),

LocalizationHandlerItem(),
Expand Down
38 changes: 38 additions & 0 deletions Catalog/Items/Features/FaceCaptureHideTorchConfigurationItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// FaceCaptureHideTorchConfigurationItem.swift
// Catalog
//
// Created by Pavel Kondrashkov on 7/5/21.
// Copyright © 2021 Regula. All rights reserved.
//

import FaceSDK

final class FaceCaptureHideTorchConfigurationItem: CatalogItem {
override init() {
super.init()

title = "FaceCapture CameraToolbarView hide torch button"
itemDescription = "FaceCaptureConfiguration usage example."
category = .feature
}

override func onItemSelected(from viewController: UIViewController) {
let configuration = FaceCaptureConfiguration {
$0.cameraPosition = .back
$0.isCameraSwitchButtonEnabled = true
$0.isTorchButtonEnabled = false
}
FaceSDK.service.presentFaceCaptureViewController(
from: viewController,
animated: true,
configuration: configuration,
onCapture: { [weak self, weak viewController] response in
guard let self = self, let viewController = viewController else { return }
self.showFaceCaptureResult(response, from: viewController)
},
completion: nil
)
}
}

39 changes: 39 additions & 0 deletions Catalog/Items/Features/LivenessHideTorchConfigurationItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// LivenessHideTorchConfigurationItem.swift
// Catalog
//
// Created by Pavel Kondrashkov on 7/5/21.
// Copyright © 2021 Regula. All rights reserved.
//

import FaceSDK

final class LivenessHideTorchConfigurationItem: CatalogItem {
override init() {
super.init()

title = "Liveness CameraToolbarView hide torch button"
itemDescription = "LivenessConfiguration usage example."
category = .feature
}

override func onItemSelected(from viewController: UIViewController) {
let configuration = LivenessConfiguration {
$0.cameraPosition = .back
$0.isCameraSwitchButtonEnabled = true
$0.isTorchButtonEnabled = false
}

FaceSDK.service.startLiveness(
from: viewController,
animated: true,
configuration: configuration,
onLiveness: { [weak self, weak viewController] response in
guard let self = self, let viewController = viewController else { return }
self.showLivenessResult(response, from: viewController)
},
completion: nil
)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
//
// LivenessProcessAndRetryCustomization.swift
// Catalog
//
// Created by Dmitry Evglevsky on 7.06.22.
// Copyright © 2022 Regula. All rights reserved.
//

import FaceSDK

final class LivenessCustomProcessingAndRetryScreensItem: CatalogItem {
final class RetryContentView: LivenessRetryContentView {
let customTryAgainStatus = UILabel()
let customCheckConditionsLabel = UILabel()
let customConditionsLabel = UILabel()
let customCloseButton = UIButton()
let customRetryButton = UIButton()

override var tryAgainStatus: UILabel? { return customTryAgainStatus }
override var checkConditionsLabel: UILabel? { return customCheckConditionsLabel }
override var conditionsLabel: UILabel? { return customConditionsLabel }
override var closeButton: UIButton? { return customCloseButton }
override var retryButton: UIButton? { return customRetryButton }

override init(frame: CGRect) {
super.init(frame: frame)

customTryAgainStatus.textColor = .red
customTryAgainStatus.textAlignment = .center
customTryAgainStatus.font = UIFont.systemFont(ofSize: 22)

customCheckConditionsLabel.textColor = .systemBlue
customCheckConditionsLabel.textAlignment = .center
customCheckConditionsLabel.font = UIFont.systemFont(ofSize: 18)

customConditionsLabel.textColor = .magenta
customConditionsLabel.textAlignment = .center
customConditionsLabel.font = UIFont.systemFont(ofSize: 12)

customRetryButton.layer.cornerRadius = 32
customRetryButton.backgroundColor = UIColor.systemBlue
customRetryButton.setTitleColor(.white, for: .normal)
customRetryButton.setTitle("RETRY", for: .normal)
customRetryButton.titleLabel?.font = UIFont.systemFont(ofSize: 20, weight: .light)

customCloseButton.layer.cornerRadius = 32
customCloseButton.backgroundColor = UIColor.clear
customCloseButton.setTitleColor(.systemBlue, for: .normal)
customCloseButton.setTitle("CANCEL", for: .normal)
customCloseButton.titleLabel?.font = UIFont.systemFont(ofSize: 20, weight: .light)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func setupConstraints() {
// Don't call super.setupConstraints()

if let tryAgainStatus = tryAgainStatus {
tryAgainStatus.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
tryAgainStatus.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 8),
tryAgainStatus.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -8),
tryAgainStatus.topAnchor.constraint(equalTo: self.topAnchor, constant: 25)
])
}

if let checkConditionsLabel = checkConditionsLabel, let tryAgainStatus = tryAgainStatus {
checkConditionsLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
checkConditionsLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 8),
checkConditionsLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -8),
checkConditionsLabel.topAnchor.constraint(equalTo: tryAgainStatus.bottomAnchor, constant: 50)
])
}

if let conditionsLabel = conditionsLabel, let checkConditionsLabel = checkConditionsLabel {
conditionsLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
conditionsLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 16),
conditionsLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -16),
conditionsLabel.topAnchor.constraint(equalTo: checkConditionsLabel.bottomAnchor, constant: 24)
])
}

if let closeButton = closeButton {
closeButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
closeButton.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -20),
closeButton.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 32),
closeButton.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -32),
closeButton.heightAnchor.constraint(equalToConstant: 64)
])
}

if let retryButton = retryButton, let closeButton = closeButton {
retryButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
retryButton.bottomAnchor.constraint(equalTo: closeButton.topAnchor, constant: -20),
retryButton.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 32),
retryButton.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -32),
retryButton.heightAnchor.constraint(equalToConstant: 64)
])
}
}
}

final class ProcessingContentView: LivenessProcessingContentView {
let customCloseButton = UIButton()
let customProcessingStatusLabel = UILabel()
let customActivityIndicator = UIActivityIndicatorView()

override var closeButton: UIButton? { return customCloseButton }
override var processingStatusLabel: UILabel? { return customProcessingStatusLabel }
override var activityIndicator: UIActivityIndicatorView? { return customActivityIndicator }

override init(frame: CGRect) {
super.init(frame: frame)

customProcessingStatusLabel.textColor = .systemBlue
customProcessingStatusLabel.textAlignment = .center
customProcessingStatusLabel.font = UIFont.systemFont(ofSize: 22)

customCloseButton.layer.cornerRadius = 32
customCloseButton.backgroundColor = .systemBlue
customCloseButton.setTitleColor(.white, for: .normal)
customCloseButton.setTitle("CANCEL", for: .normal)
customCloseButton.titleLabel?.font = UIFont.systemFont(ofSize: 20, weight: .light)

customActivityIndicator.color = .magenta
customActivityIndicator.startAnimating()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func setupConstraints() {
// Don't call super.setupConstraints()

if let activityIndicator = activityIndicator {
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
activityIndicator.centerXAnchor.constraint(equalTo: self.centerXAnchor),
activityIndicator.centerYAnchor.constraint(equalTo: self.centerYAnchor)
])
}

if let processingStatusLabel = processingStatusLabel {
processingStatusLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
processingStatusLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 8),
processingStatusLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -8),
processingStatusLabel.topAnchor.constraint(equalTo: self.topAnchor, constant: 50)
])
}

if let closeButton = closeButton {
closeButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
closeButton.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -20),
closeButton.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 32),
closeButton.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -32),
closeButton.heightAnchor.constraint(equalToConstant: 64)
])
}
}
}

override init() {
super.init()

title = "Custom Liveness Process & Retry Screens"
itemDescription = "Overriden ProcessingContentView & RetryContentView layout"
category = .viewCustomization
}

override func onItemSelected(from viewController: UIViewController) {
let configuration = LivenessConfiguration {
$0.registerClass(ProcessingContentView.self, forBaseClass: LivenessProcessingContentView.self)
$0.registerClass(RetryContentView.self, forBaseClass: LivenessRetryContentView.self)
}

FaceSDK.service.startLiveness(
from: viewController,
animated: true,
configuration: configuration,
onLiveness: { [weak self, weak viewController] response in
guard let self = self, let viewController = viewController else { return }
self.showLivenessResult(response, from: viewController)
},
completion: nil
)
}
}

0 comments on commit 82ae0a7

Please sign in to comment.