Skip to content

Commit

Permalink
Merge pull request #14 from regulaforensics/ui-configuration
Browse files Browse the repository at this point in the history
UI configuration
  • Loading branch information
DzmitrySmaliakou authored Jul 10, 2023
2 parents 9051bd0 + 5828e96 commit 22c3c3f
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 52 deletions.
8 changes: 8 additions & 0 deletions Catalog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
96AA511D2A0109AC00783B08 /* DetectFacesItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AA511B2A0109AC00783B08 /* DetectFacesItem.swift */; };
96AA511E2A0109AC00783B08 /* ImageQualityItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AA511C2A0109AC00783B08 /* ImageQualityItem.swift */; };
96AA51202A010A2A00783B08 /* QualityResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AA511F2A010A2A00783B08 /* QualityResultsViewController.swift */; };
9D0660742A3337D9000370EC /* LivenessUIConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D0660732A3337D9000370EC /* LivenessUIConfiguration.swift */; };
9D7EFC862A4D793B0016736B /* FaceCaptureUIConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D7EFC852A4D793B0016736B /* FaceCaptureUIConfiguration.swift */; };
9DC35FC2298174D00043FBB1 /* LivenessSkipOnboardingAndSuccessItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DC35FC1298174D00043FBB1 /* LivenessSkipOnboardingAndSuccessItem.swift */; };
9DE86D922850820400FCC18C /* FaceCaptureHideTorchConfigurationItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE86D902850820400FCC18C /* FaceCaptureHideTorchConfigurationItem.swift */; };
F1D3B0BD2ECCF5ED96E71FEB /* Pods_Catalog.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1DBE93D03DA4D5B36021E6A /* Pods_Catalog.framework */; };
Expand Down Expand Up @@ -128,6 +130,8 @@
96AA511B2A0109AC00783B08 /* DetectFacesItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetectFacesItem.swift; sourceTree = "<group>"; };
96AA511C2A0109AC00783B08 /* ImageQualityItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageQualityItem.swift; sourceTree = "<group>"; };
96AA511F2A010A2A00783B08 /* QualityResultsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QualityResultsViewController.swift; sourceTree = "<group>"; };
9D0660732A3337D9000370EC /* LivenessUIConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LivenessUIConfiguration.swift; sourceTree = "<group>"; };
9D7EFC852A4D793B0016736B /* FaceCaptureUIConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceCaptureUIConfiguration.swift; sourceTree = "<group>"; };
9DC35FC1298174D00043FBB1 /* LivenessSkipOnboardingAndSuccessItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LivenessSkipOnboardingAndSuccessItem.swift; sourceTree = "<group>"; };
9DE86D902850820400FCC18C /* FaceCaptureHideTorchConfigurationItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FaceCaptureHideTorchConfigurationItem.swift; sourceTree = "<group>"; };
D1DBE93D03DA4D5B36021E6A /* Pods_Catalog.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Catalog.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -269,6 +273,8 @@
86B6D2F62655306500794170 /* ViewCustomization */ = {
isa = PBXGroup;
children = (
9D0660732A3337D9000370EC /* LivenessUIConfiguration.swift */,
9D7EFC852A4D793B0016736B /* FaceCaptureUIConfiguration.swift */,
86B6D2F126552EF800794170 /* LivenessHintViewAppearanceItem.swift */,
86D5E284266116B80076D417 /* LivenessHintPositionItem.swift */,
86D5E288266118400076D417 /* LivenessToolbarAppearanceItem.swift */,
Expand Down Expand Up @@ -483,6 +489,8 @@
86B2D27C2655568400D85D45 /* UIView+Layout.swift in Sources */,
86B6D2C12653DA7C00794170 /* RFCCatalogItem.m in Sources */,
86D5E2A7266128160076D417 /* FaceCaptureBackgroundColor.swift in Sources */,
9D0660742A3337D9000370EC /* LivenessUIConfiguration.swift in Sources */,
9D7EFC862A4D793B0016736B /* FaceCaptureUIConfiguration.swift in Sources */,
86B6D2F226552EF800794170 /* LivenessHintViewAppearanceItem.swift in Sources */,
86D5E285266116B80076D417 /* LivenessHintPositionItem.swift in Sources */,
86D5E2A1266123480076D417 /* LivenessLogoItem.swift in Sources */,
Expand Down
4 changes: 3 additions & 1 deletion Catalog/Core/CatalogTableDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ final class CatalogTableDataProvider {
FaceCaptureCameraPositionItem(),
FaceCaptureHideTorchConfigurationItem(),
LivenessSkipOnboardingAndSuccessItem(),


LivenessUIConfigurationItem(),
FaceCaptureUIConfigurationItem(),
LivenessHintViewAppearanceItem(),
LivenessHintPositionItem(),
LivenessToolbarAppearanceItem(),
Expand Down
46 changes: 46 additions & 0 deletions Catalog/Items/ViewCustomization/FaceCaptureUIConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// FaceCaptureUIConfiguration.swift
// Catalog
//
// Created by Dmitry Evglevsky on 29.06.23.
// Copyright © 2023 Regula. All rights reserved.
//

import FaceSDK

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

title = "FaceCapture UI Configuration"
itemDescription = "Interface customization."
category = .viewCustomization
}

override func onItemSelected(from viewController: UIViewController) {
let titleFont = UIFont(name: "Copperplate", size: 26)!

let interfaceConfiguration = UIConfiguration {
// Camera screen colors.
$0.setColor(.systemYellow, forItem: .CameraScreenStrokeActive)
$0.setColor(.systemYellow, forItem: .CameraScreenStrokeNormal)
$0.setColor(.systemYellow, forItem: .CameraScreenFrontHintLabelBackground)
$0.setColor(.black, forItem: .CameraScreenFrontHintLabelText)

// Camera screen fonts.
$0.setFont(titleFont, forItem: .CameraScreenHintLabel)
}
FaceSDK.service.customization.configuration = interfaceConfiguration

FaceSDK.service.presentFaceCaptureViewController(
from: viewController,
animated: true,
onCapture: { [weak self, weak viewController] response in
FaceSDK.service.customization.configuration = nil
guard let self = self, let viewController = viewController else { return }
self.showFaceCaptureResult(response, from: viewController)
},
completion: nil)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ final class LivenessHintViewAppearanceItem: CatalogItem {
private extension LivenessHintViewAppearanceItem {
/// Restorins original appearance of the HintView.
private func applyOriginalAppearance() {
let lightGrayColor = UIColor(white: 0.91, alpha: 1.0)

let hintViewAppearance = HintView.appearance(whenContainedInInstancesOf: [LivenessContentView.self])
hintViewAppearance.cornerRadius = 8
hintViewAppearance.setBackgroundColor(.black, for: .front)
hintViewAppearance.setTextColor(.white, for: .front)
hintViewAppearance.setBackgroundColor(lightGrayColor, for: .front)
hintViewAppearance.setTextColor(.black, for: .front)

let hintLabelAppearance = UILabel.appearance(whenContainedInInstancesOf: [HintView.self, LivenessContentView.self])
hintLabelAppearance.font = .systemFont(ofSize: 30)
hintLabelAppearance.font = .preferredFont(forTextStyle: .title2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private extension LivenessToolbarAppearanceItem {
/// Restorins original appearance.
private func applyOriginalAppearance() {
let toolbarAppearance = CameraToolbarView.appearance(whenContainedInInstancesOf: [LivenessContentView.self])
toolbarAppearance.backgroundColor = .black
toolbarAppearance.backgroundColor = .clear

let toolbarButtonAppearance = UIButton.appearance(whenContainedInInstancesOf: [CameraToolbarView.self, LivenessContentView.self])
toolbarButtonAppearance.backgroundColor = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class LivenessToolbarCustomButtonItem: CatalogItem {

override init(frame: CGRect) {
super.init(frame: frame)
customCloseButton.backgroundColor = .windsor
customCloseButton.setTitle("CLOSE", for: .normal)
customCloseButton.titleLabel?.font = UIFont(name: "AmericanTypewriter", size: 30)
}
Expand Down
102 changes: 102 additions & 0 deletions Catalog/Items/ViewCustomization/LivenessUIConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// LivenessUIConfiguration.swift
// Catalog
//
// Created by Dmitry Evglevsky on 9.06.23.
// Copyright © 2023 Regula. All rights reserved.
//

import FaceSDK

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

title = "Liveness UI Configuration"
itemDescription = "Interface customization."
category = .viewCustomization
}

override func onItemSelected(from viewController: UIViewController) {
let messageFont = UIFont(name: "Copperplate", size: 18)!
let titleFont = UIFont(name: "Copperplate", size: 26)!

let interfaceConfiguration = UIConfiguration {
// Onboarding screen colors.
$0.setColor(.systemYellow, forItem: .OnboardingScreenBackground)
$0.setColor(.black, forItem: .OnboardingScreenStartButtonBackground)

// Onboarding screen fonts.
$0.setFont(messageFont, forItem: .OnboardingScreenMessageLabel)
$0.setFont(titleFont, forItem: .OnboardingScreenTitleLabel)
$0.setFont(titleFont, forItem: .OnboardingScreenStartButton)

// Onboarding screen images.
if #available(iOS 16.0, *) {
$0.setImage(UIImage(systemName: "sun.max.trianglebadge.exclamationmark")!.withTintColor(.black, renderingMode: .alwaysOriginal),
forItem: .OnboardingScreenIllumination)
$0.setImage(UIImage(systemName: "eyeglasses")!.withTintColor(.black, renderingMode: .alwaysOriginal),
forItem: .OnboardingScreenAccessories)
$0.setImage(UIImage(systemName: "camera.viewfinder")!.withTintColor(.black, renderingMode: .alwaysOriginal),
forItem: .OnboardingScreenCameraLevel)
} else {
// Use your image assets.
}

// Camera screen colors.
$0.setColor(.systemYellow, forItem: .CameraScreenStrokeActive)
$0.setColor(.systemYellow, forItem: .CameraScreenStrokeNormal)
$0.setColor(.systemYellow, forItem: .CameraScreenSectorActive)
$0.setColor(.systemYellow.withAlphaComponent(0.35), forItem: .CameraScreenSectorTarget)
$0.setColor(.systemYellow, forItem: .CameraScreenFrontHintLabelBackground)
$0.setColor(.black, forItem: .CameraScreenFrontHintLabelText)

// Camera screen fonts.
$0.setFont(titleFont, forItem: .CameraScreenHintLabel)

// Processing screen colors.
$0.setColor(.systemYellow, forItem: .ProcessingScreenBackground)
$0.setColor(.black, forItem: .ProcessingScreenProgress)
$0.setColor(.black, forItem: .ProcessingScreenTitleLabel)

// Processing screen fonts.
$0.setFont(titleFont, forItem: .ProcessingScreenLabel)

// Retry screen colors.
$0.setColor(.systemYellow, forItem: .RetryScreenBackground)
$0.setColor(.black, forItem: .RetryScreenRetryButtonBackground)

// Retry screen fonts.
$0.setFont(messageFont, forItem: .RetryScreenHintLabels)
$0.setFont(titleFont, forItem: .RetryScreenTitleLabel)
$0.setFont(titleFont, forItem: .RetryScreenRetryButton)

// Retry screen images.
if #available(iOS 16.0, *) {
$0.setImage(UIImage(systemName: "sun.max.trianglebadge.exclamationmark")!.withTintColor(.black, renderingMode: .alwaysOriginal),
forItem: .RetryScreenHintEnvironment)
$0.setImage(UIImage(systemName: "face.smiling")!.withTintColor(.black, renderingMode: .alwaysOriginal),
forItem: .RetryScreenHintSubject)
} else {
// Use your image assets.
}

// Success screen colors.
$0.setColor(.systemYellow, forItem: .SuccessScreenBackground)

// Success screen images.
$0.setImage(UIImage(named: "checkmark")!, forItem: .SuccessScreenImage)
}
FaceSDK.service.customization.configuration = interfaceConfiguration

FaceSDK.service.startLiveness(
from: viewController,
animated: true,
onLiveness: { [weak self, weak viewController] response in
FaceSDK.service.customization.configuration = nil
guard let self = self, let viewController = viewController else { return }
self.showLivenessResult(response, from: viewController)
},
completion: nil)
}
}
12 changes: 12 additions & 0 deletions Catalog/Resources/Assets.xcassets/checkmark.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "checkmark.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
45 changes: 2 additions & 43 deletions Catalog/Resources/Assets.xcassets/logo.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,8 @@
{
"images" : [
{
"filename" : "2017_1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "2017_2.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "2017.png",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "3x"
"filename" : "logo.pdf",
"idiom" : "universal"
}
],
"info" : {
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions Catalog/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
8 changes: 4 additions & 4 deletions Catalog/Resources/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?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="LZZ-dN-BKW">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="LZZ-dN-BKW">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<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"/>
Expand All @@ -17,7 +17,7 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="0ei-NJ-EAS">
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="0ei-NJ-EAS">
<rect key="frame" x="0.0" y="338" width="414" height="220"/>
<constraints>
<constraint firstAttribute="width" secondItem="0ei-NJ-EAS" secondAttribute="height" multiplier="1.88:1" id="awl-P6-jQF"/>
Expand All @@ -41,7 +41,7 @@
</scene>
</scenes>
<resources>
<image name="logo" width="534.5" height="291"/>
<image name="logo" width="144" height="44"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
Expand Down

0 comments on commit 22c3c3f

Please sign in to comment.