From 75c15798fa3479f33d417a43751a38f1f4a7bc65 Mon Sep 17 00:00:00 2001 From: JNdhlovu Date: Fri, 6 Sep 2024 12:11:14 +0200 Subject: [PATCH 1/2] feat: optional confirmation on docv --- CHANGELOG.md | 5 + Example/Podfile.lock | 4 +- SmileID.podspec | 4 +- .../View/DocumentCaptureScreen.swift | 133 +++++++++++------- Sources/SmileID/Classes/SmileID.swift | 2 +- 5 files changed, 89 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4e74bb2..ffeec909 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Release Notes +## 10.2.9 + +### Added +* Document capture cleanup and optionally showing confirmation and returning the captured image if false + ## 10.2.8 ### Changed diff --git a/Example/Podfile.lock b/Example/Podfile.lock index b438a203..d61ffa7d 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -7,7 +7,7 @@ PODS: - Sentry (8.32.0): - Sentry/Core (= 8.32.0) - Sentry/Core (8.32.0) - - SmileID (10.2.8): + - SmileID (10.2.9): - lottie-ios (~> 4.4.2) - ZIPFoundation (~> 0.9) - SwiftLint (0.55.1) @@ -43,7 +43,7 @@ SPEC CHECKSUMS: lottie-ios: fcb5e73e17ba4c983140b7d21095c834b3087418 netfox: 9d5cc727fe7576c4c7688a2504618a156b7d44b7 Sentry: 96ae1dcdf01a644bc3a3b1dc279cecaf48a833fb - SmileID: 8d3a64e845a5fb82239516def978391d4d814c9e + SmileID: cbeaf5142f11cea7a4778d7c000fa9b766c4afa2 SwiftLint: 3fe909719babe5537c552ee8181c0031392be933 ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c diff --git a/SmileID.podspec b/SmileID.podspec index 6d5e1f4f..8fcb8642 100644 --- a/SmileID.podspec +++ b/SmileID.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'SmileID' - s.version = '10.2.8' + s.version = '10.2.9' s.summary = 'The Official Smile Identity iOS SDK.' s.homepage = 'https://docs.usesmileid.com/integration-options/mobile/ios-v10-beta' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'Japhet' => 'japhet@usesmileid.com', 'Juma Allan' => 'juma@usesmileid.com', 'Vansh Gandhi' => 'vansh@usesmileid.com'} - s.source = { :git => "https://github.com/smileidentity/ios.git", :tag => "v10.2.7" } + s.source = { :git => "https://github.com/smileidentity/ios.git", :tag => "v10.2.9" } s.ios.deployment_target = '13.0' s.dependency 'ZIPFoundation', '~> 0.9' s.dependency 'lottie-ios', '~> 4.4.2' diff --git a/Sources/SmileID/Classes/DocumentVerification/View/DocumentCaptureScreen.swift b/Sources/SmileID/Classes/DocumentVerification/View/DocumentCaptureScreen.swift index a7897077..39ad81a3 100644 --- a/Sources/SmileID/Classes/DocumentVerification/View/DocumentCaptureScreen.swift +++ b/Sources/SmileID/Classes/DocumentVerification/View/DocumentCaptureScreen.swift @@ -11,6 +11,7 @@ public struct DocumentCaptureScreen: View { let instructionsSubtitleText: String let captureTitleText: String let knownIdAspectRatio: Double? + let showConfirmation: Bool = true let onConfirm: (Data) -> Void let onError: (Error) -> Void let onSkip: () -> Void @@ -49,66 +50,90 @@ public struct DocumentCaptureScreen: View { } public var body: some View { - if let captureError = viewModel.captureError { - let _ = onError(captureError) - } else if showInstructions, !viewModel.acknowledgedInstructions { - DocumentCaptureInstructionsScreen( - heroImage: instructionsHeroImage, - title: instructionsTitleText, - subtitle: instructionsSubtitleText, - showAttribution: showAttribution, - allowPhotoFromGallery: allowGallerySelection, - showSkipButton: showSkipButton, - onSkip: onSkip, - onInstructionsAcknowledgedSelectFromGallery: viewModel.onGalleryClick, - onInstructionsAcknowledgedTakePhoto: viewModel.onTakePhotoClick - ) - .sheet(isPresented: $viewModel.showPhotoPicker) { - ImagePicker(onImageSelected: viewModel.onPhotoSelectedFromGallery) + ZStack { + if let captureError = viewModel.captureError { + errorView(error: captureError) + } else if showInstructions && !viewModel.acknowledgedInstructions { + instructionsView + } else if let imageToConfirm = viewModel.documentImageToConfirm { + confirmationView(imageToConfirm: imageToConfirm) + } else { + captureView } - } else if let imageToConfirm = viewModel.documentImageToConfirm { - ImageCaptureConfirmationDialog( - title: SmileIDResourcesHelper.localizedString(for: "Document.Confirmation.Header"), - subtitle: SmileIDResourcesHelper.localizedString( - for: "Document.Confirmation.Callout" - ), - image: UIImage(data: imageToConfirm) ?? UIImage(), - confirmationButtonText: SmileIDResourcesHelper.localizedString( - for: "Document.Confirmation.Accept" - ), - onConfirm: { onConfirm(imageToConfirm) }, - retakeButtonText: SmileIDResourcesHelper.localizedString( - for: "Document.Confirmation.Decline" - ), - onRetake: viewModel.onRetry, - scaleFactor: 1.0 - ) - } else { - CaptureScreenContent( - title: captureTitleText, - subtitle: SmileIDResourcesHelper.localizedString(for: viewModel.directive.rawValue), - idAspectRatio: viewModel.idAspectRatio, - areEdgesDetected: viewModel.areEdgesDetected, - showCaptureInProgress: viewModel.isCapturing, - showManualCaptureButton: viewModel.showManualCaptureButton, - cameraManager: viewModel.cameraManager, - onCaptureClick: viewModel.captureDocument - ) - .alert(item: $viewModel.unauthorizedAlert) { alert in - Alert( - title: Text(alert.title), - message: Text(alert.message ?? ""), - primaryButton: .default( - Text(SmileIDResourcesHelper.localizedString(for: "Camera.Unauthorized.PrimaryAction")), - action: { - viewModel.openSettings() - } + } + } + + private var instructionsView: some View { + DocumentCaptureInstructionsScreen( + heroImage: instructionsHeroImage, + title: instructionsTitleText, + subtitle: instructionsSubtitleText, + showAttribution: showAttribution, + allowPhotoFromGallery: allowGallerySelection, + showSkipButton: showSkipButton, + onSkip: onSkip, + onInstructionsAcknowledgedSelectFromGallery: viewModel.onGalleryClick, + onInstructionsAcknowledgedTakePhoto: viewModel.onTakePhotoClick + ) + .sheet(isPresented: $viewModel.showPhotoPicker) { + ImagePicker(onImageSelected: viewModel.onPhotoSelectedFromGallery) + } + } + + private func errorView(error: Error) -> some View { + Color.clear.onAppear { onError(error) } + } + + private func confirmationView(imageToConfirm: Data) -> some View { + Group { + if showConfirmation { + ImageCaptureConfirmationDialog( + title: SmileIDResourcesHelper.localizedString(for: "Document.Confirmation.Header"), + subtitle: SmileIDResourcesHelper.localizedString( + for: "Document.Confirmation.Callout" + ), + image: UIImage(data: imageToConfirm) ?? UIImage(), + confirmationButtonText: SmileIDResourcesHelper.localizedString( + for: "Document.Confirmation.Accept" + ), + onConfirm: { onConfirm(imageToConfirm) }, + retakeButtonText: SmileIDResourcesHelper.localizedString( + for: "Document.Confirmation.Decline" ), - secondaryButton: .cancel() + onRetake: viewModel.onRetry, + scaleFactor: 1.0 ) + } else { + Color.clear.onAppear { onConfirm(imageToConfirm) } } } } + + private var captureView: some View { + CaptureScreenContent( + title: captureTitleText, + subtitle: SmileIDResourcesHelper.localizedString(for: viewModel.directive.rawValue), + idAspectRatio: viewModel.idAspectRatio, + areEdgesDetected: viewModel.areEdgesDetected, + showCaptureInProgress: viewModel.isCapturing, + showManualCaptureButton: viewModel.showManualCaptureButton, + cameraManager: viewModel.cameraManager, + onCaptureClick: viewModel.captureDocument + ) + .alert(item: $viewModel.unauthorizedAlert) { alert in + Alert( + title: Text(alert.title), + message: Text(alert.message ?? ""), + primaryButton: .default( + Text(SmileIDResourcesHelper.localizedString(for: "Camera.Unauthorized.PrimaryAction")), + action: { + viewModel.openSettings() + } + ), + secondaryButton: .cancel() + ) + } + } } struct CaptureScreenContent: View { diff --git a/Sources/SmileID/Classes/SmileID.swift b/Sources/SmileID/Classes/SmileID.swift index f21a708e..cc1a9df1 100644 --- a/Sources/SmileID/Classes/SmileID.swift +++ b/Sources/SmileID/Classes/SmileID.swift @@ -3,7 +3,7 @@ import SwiftUI import UIKit public class SmileID { - public static let version = "10.2.8" + public static let version = "10.2.9" @Injected var injectedApi: SmileIDServiceable public static var configuration: Config { config } From 07cdeb9ca0dd952a45a1a67f88ac334eea85370c Mon Sep 17 00:00:00 2001 From: JNdhlovu Date: Fri, 6 Sep 2024 12:23:02 +0200 Subject: [PATCH 2/2] feat: confirm optional --- .../DocumentVerification/View/DocumentCaptureScreen.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SmileID/Classes/DocumentVerification/View/DocumentCaptureScreen.swift b/Sources/SmileID/Classes/DocumentVerification/View/DocumentCaptureScreen.swift index 39ad81a3..142d6856 100644 --- a/Sources/SmileID/Classes/DocumentVerification/View/DocumentCaptureScreen.swift +++ b/Sources/SmileID/Classes/DocumentVerification/View/DocumentCaptureScreen.swift @@ -11,7 +11,7 @@ public struct DocumentCaptureScreen: View { let instructionsSubtitleText: String let captureTitleText: String let knownIdAspectRatio: Double? - let showConfirmation: Bool = true + let showConfirmation: Bool let onConfirm: (Data) -> Void let onError: (Error) -> Void let onSkip: () -> Void @@ -29,6 +29,7 @@ public struct DocumentCaptureScreen: View { instructionsSubtitleText: String, captureTitleText: String, knownIdAspectRatio: Double?, + showConfirmation: Bool = true, onConfirm: @escaping (Data) -> Void, onError: @escaping (Error) -> Void, onSkip: @escaping () -> Void = {} @@ -43,6 +44,7 @@ public struct DocumentCaptureScreen: View { self.instructionsSubtitleText = instructionsSubtitleText self.captureTitleText = captureTitleText self.knownIdAspectRatio = knownIdAspectRatio + self.showConfirmation = showConfirmation self.onConfirm = onConfirm self.onError = onError self.onSkip = onSkip