From aea11414d5272c7cddc90db738afedf1376bd54e Mon Sep 17 00:00:00 2001 From: Team Mobile Schorsch Date: Tue, 7 May 2024 09:45:32 +0000 Subject: [PATCH] Release version 3.8.0 --- .jazzy.yaml | 2 +- .../Core/Custom views/BottomLabelButton.swift | 1 + .../Custom views/FileImportButtonView.swift | 1 + .../Core/Custom views/GiniBarButton.swift | 1 + .../Custom views/MultilineTitleButton.swift | 1 + .../Core/GiniConfiguration.swift | 9 +- .../Core/Helpers/GiniCaptureUtils.swift | 23 +- .../Helpers/PreferredButtonResource.swift | 2 +- .../Protocols/CustomResourceProvider.swift | 21 ++ .../Camera/CameraLensSwitcherView.swift | 3 + .../Views/CameraNotAuthorizedView.swift | 1 + .../Screens/Camera/Views/CameraPane.swift | 1 + .../Screens/Camera/Views/ThumbnailView.swift | 1 + .../Gallery/AlbumsHeaderView.swift | 1 + .../Views/OnboardingBottomNavigationBar.swift | 3 + .../Screens/Review/ReviewCollectionCell.swift | 1 + .../Review/ReviewZoomViewController.swift | 1 + .../GiniScreenAPICoordinator+Camera.swift | 21 +- .../GiniScreenAPICoordinator.swift | 19 +- .../GiniCaptureSDKVersion.swift | 2 +- .../Networking/DocumentService.swift | 28 ++- .../GiniCaptureSDK/Resources/GiniColors.swift | 209 ++++++++++++------ .../errorBackground.colorset/Contents.json | 38 ---- .../grayLabel.colorset/Contents.json | 38 ---- .../labelWhite.colorset/Contents.json | 38 ---- 25 files changed, 255 insertions(+), 211 deletions(-) create mode 100644 Sources/GiniCaptureSDK/Core/Protocols/CustomResourceProvider.swift delete mode 100644 Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/errorBackground.colorset/Contents.json delete mode 100644 Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/grayLabel.colorset/Contents.json delete mode 100644 Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/labelWhite.colorset/Contents.json diff --git a/.jazzy.yaml b/.jazzy.yaml index f3b38f0..6d065c3 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -5,7 +5,7 @@ xcodebuild_arguments: - "-scheme" - GiniCaptureSDK - "-destination" -- platform=iOS Simulator,OS=16.2,name=iPhone 13 +- platform=iOS Simulator,OS=17.2,name=iPhone 14 author: Gini GmbH author_url: https://gini.net module: GiniCaptureSDK diff --git a/Sources/GiniCaptureSDK/Core/Custom views/BottomLabelButton.swift b/Sources/GiniCaptureSDK/Core/Custom views/BottomLabelButton.swift index 5da19f2..8ef7b74 100644 --- a/Sources/GiniCaptureSDK/Core/Custom views/BottomLabelButton.swift +++ b/Sources/GiniCaptureSDK/Core/Custom views/BottomLabelButton.swift @@ -15,6 +15,7 @@ final class BottomLabelButton: UIView { let button = UIButton() button.translatesAutoresizingMaskIntoConstraints = false button.addTarget(self, action: #selector(didPressButton(_:)), for: .touchUpInside) + button.isExclusiveTouch = true return button }() diff --git a/Sources/GiniCaptureSDK/Core/Custom views/FileImportButtonView.swift b/Sources/GiniCaptureSDK/Core/Custom views/FileImportButtonView.swift index 207dd48..0078007 100644 --- a/Sources/GiniCaptureSDK/Core/Custom views/FileImportButtonView.swift +++ b/Sources/GiniCaptureSDK/Core/Custom views/FileImportButtonView.swift @@ -21,6 +21,7 @@ final class FileImportButtonView: UIView { button.setImage(self.documentImportButtonImage, for: .normal) button.imageView?.contentMode = .scaleAspectFit button.addTarget(self, action: #selector(showImportFileSheet), for: .touchUpInside) + button.isExclusiveTouch = true button.imageEdgeInsets = UIEdgeInsets(top: 4, left: 4, bottom: 4, right: 4) return button }() diff --git a/Sources/GiniCaptureSDK/Core/Custom views/GiniBarButton.swift b/Sources/GiniCaptureSDK/Core/Custom views/GiniBarButton.swift index 8a19485..3114a16 100644 --- a/Sources/GiniCaptureSDK/Core/Custom views/GiniBarButton.swift +++ b/Sources/GiniCaptureSDK/Core/Custom views/GiniBarButton.swift @@ -56,6 +56,7 @@ public final class GiniBarButton { public func addAction(_ target: Any?, _ action: Selector) { let tapRecognizer = UITapGestureRecognizer(target: target, action: action) stackView.addGestureRecognizer(tapRecognizer) + stackView.isExclusiveTouch = true } /** diff --git a/Sources/GiniCaptureSDK/Core/Custom views/MultilineTitleButton.swift b/Sources/GiniCaptureSDK/Core/Custom views/MultilineTitleButton.swift index c14ddaf..63fb06b 100644 --- a/Sources/GiniCaptureSDK/Core/Custom views/MultilineTitleButton.swift +++ b/Sources/GiniCaptureSDK/Core/Custom views/MultilineTitleButton.swift @@ -40,6 +40,7 @@ public class MultilineTitleButton: UIButton { titleLabel?.textAlignment = .center setContentHuggingPriority(UILayoutPriority.defaultLow + 1, for: .vertical) setContentHuggingPriority(UILayoutPriority.defaultLow + 1, for: .horizontal) + isExclusiveTouch = true } /** diff --git a/Sources/GiniCaptureSDK/Core/GiniConfiguration.swift b/Sources/GiniCaptureSDK/Core/GiniConfiguration.swift index 5614bf3..73ab5bc 100644 --- a/Sources/GiniCaptureSDK/Core/GiniConfiguration.swift +++ b/Sources/GiniCaptureSDK/Core/GiniConfiguration.swift @@ -94,7 +94,14 @@ import GiniBankAPILibrary /** Should be set if the main app's bundle is not used. */ - public var customResourceBundle: Bundle? + public var customResourceBundle: Bundle? + + /** + Enables the customization of resources to override the default Gini resources. The change will affect all screens. + + - Important: To ensure proper customization, set this property before configuring any custom Gini button configurations, such as `primaryButtonConfiguration`, `secondaryButtonConfiguration`, `transparentButtonConfiguration`, `cameraControlButtonConfiguration` and `addPageButtonConfiguration`. + */ + public var customResourceProvider: CustomResourceProvider? // MARK: Button configuration options diff --git a/Sources/GiniCaptureSDK/Core/Helpers/GiniCaptureUtils.swift b/Sources/GiniCaptureSDK/Core/Helpers/GiniCaptureUtils.swift index c888af0..f3d2ed9 100644 --- a/Sources/GiniCaptureSDK/Core/Helpers/GiniCaptureUtils.swift +++ b/Sources/GiniCaptureSDK/Core/Helpers/GiniCaptureUtils.swift @@ -52,9 +52,9 @@ public func UIColorPreferred(named name: String) -> UIColor { } if let customBundle = GiniConfiguration.shared.customResourceBundle, - let customBundleColor = UIColor(named: name, - in: customBundle, - compatibleWith: nil) { + let customBundleColor = UIColor(named: name, + in: customBundle, + compatibleWith: nil) { return customBundleColor } @@ -67,6 +67,21 @@ public func UIColorPreferred(named name: String) -> UIColor { } } +/** + Returns an optional `UIColor` instance with the given `name` preferably from the client's custom resources provider. + + - parameter name: The name of the UIColor. + + - returns: UIColor if found with name. + */ + +public func UIColorPreferredByProvider(named name: String) -> UIColor { + if let customProvider = GiniConfiguration.shared.customResourceProvider { + return customProvider.customPrefferedColor(name: name) + } + return UIColorPreferred(named: name) +} + /** Returns a localized string resource preferably from the client's bundle. @@ -91,7 +106,7 @@ public func NSLocalizedStringPreferredFormat(_ key: String, fallbackKey: fallbackKey, comment: comment, bundle: customBundle) { - + return clientLocalizedStringCustomBundle } } diff --git a/Sources/GiniCaptureSDK/Core/Helpers/PreferredButtonResource.swift b/Sources/GiniCaptureSDK/Core/Helpers/PreferredButtonResource.swift index a0744c7..b9d0c19 100644 --- a/Sources/GiniCaptureSDK/Core/Helpers/PreferredButtonResource.swift +++ b/Sources/GiniCaptureSDK/Core/Helpers/PreferredButtonResource.swift @@ -37,7 +37,7 @@ class GiniPreferredButtonResource: PreferredButtonResource { private let localizedConfigEntry: String? private let appBundle = Bundle.main private let libBundle = giniCaptureBundle() - private var customBundle : Bundle { + private var customBundle: Bundle { guard let customBundle = GiniConfiguration.shared.customResourceBundle else { return Bundle.main } diff --git a/Sources/GiniCaptureSDK/Core/Protocols/CustomResourceProvider.swift b/Sources/GiniCaptureSDK/Core/Protocols/CustomResourceProvider.swift new file mode 100644 index 0000000..df29093 --- /dev/null +++ b/Sources/GiniCaptureSDK/Core/Protocols/CustomResourceProvider.swift @@ -0,0 +1,21 @@ +// +// CustomResourceProvider.swift +// +// Copyright © 2024 Gini GmbH. All rights reserved. +// + +import UIKit + +/** + * Custom resource provider protocol which allows clients to override the default Gini resources. + * The change will affect all screens. + */ +public protocol CustomResourceProvider { + /** + * Returns a custom preferred color for a given resource name. + * + * - Parameter name: The name of the resource. + * - Returns: The custom preferred UIColor. + */ + func customPrefferedColor(name: String) -> UIColor +} diff --git a/Sources/GiniCaptureSDK/Core/Screens/Camera/Camera/CameraLensSwitcherView.swift b/Sources/GiniCaptureSDK/Core/Screens/Camera/Camera/CameraLensSwitcherView.swift index da04762..f713676 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Camera/Camera/CameraLensSwitcherView.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Camera/Camera/CameraLensSwitcherView.swift @@ -38,6 +38,7 @@ final class CameraLensSwitcherView: UIView { button.isHidden = true button.setTitleColor(.GiniCapture.light1, for: .normal) button.backgroundColor = .GiniCapture.dark4.withAlphaComponent(Constants.inactiveStateAlpha) + button.isExclusiveTouch = true button.translatesAutoresizingMaskIntoConstraints = false if let font = GiniConfiguration.shared.textStyleFonts[.caption2] { if font.pointSize > Constants.maxFontSize { @@ -54,6 +55,7 @@ final class CameraLensSwitcherView: UIView { button.isHidden = true button.setTitleColor(.GiniCapture.light1, for: .normal) button.backgroundColor = .GiniCapture.dark4.withAlphaComponent(Constants.inactiveStateAlpha) + button.isExclusiveTouch = true button.translatesAutoresizingMaskIntoConstraints = false if let font = GiniConfiguration.shared.textStyleFonts[.caption2] { if font.pointSize > Constants.maxFontSize { @@ -70,6 +72,7 @@ final class CameraLensSwitcherView: UIView { button.isHidden = true button.setTitleColor(.GiniCapture.light1, for: .normal) button.backgroundColor = .GiniCapture.dark4.withAlphaComponent(Constants.inactiveStateAlpha) + button.isExclusiveTouch = true button.translatesAutoresizingMaskIntoConstraints = false if let font = GiniConfiguration.shared.textStyleFonts[.caption2] { if font.pointSize > Constants.maxFontSize { diff --git a/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/CameraNotAuthorizedView.swift b/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/CameraNotAuthorizedView.swift index 22f9a9b..3e943c3 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/CameraNotAuthorizedView.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/CameraNotAuthorizedView.swift @@ -59,6 +59,7 @@ final class CameraNotAuthorizedView: UIView { .limitingFontSize(to: Constants.maximumFontSize) button.titleLabel?.adjustsFontForContentSizeCategory = true button.addTarget(self, action: #selector(openSettings), for: .touchUpInside) + button.isExclusiveTouch = true return button }() diff --git a/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/CameraPane.swift b/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/CameraPane.swift index 28c5253..15e2c8f 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/CameraPane.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/CameraPane.swift @@ -29,6 +29,7 @@ final class CameraPane: UIView { light: UIColor.GiniCapture.dark1, dark: UIColor.GiniCapture.dark1).uiColor().withAlphaComponent(0.4) captureButton.setTitle("", for: .normal) + captureButton.isExclusiveTouch = true thumbnailView.isHidden = true fileUploadButton.setupButton(with: UIImageNamedPreferred(named: "folder") ?? UIImage(), name: NSLocalizedStringPreferredFormat("ginicapture.camera.fileImportButtonLabel", diff --git a/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/ThumbnailView.swift b/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/ThumbnailView.swift index 51bba85..e2829c9 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/ThumbnailView.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Camera/Views/ThumbnailView.swift @@ -23,6 +23,7 @@ final class ThumbnailView: UIView { let button = UIButton() button.translatesAutoresizingMaskIntoConstraints = false button.addTarget(self, action: #selector(thumbnailButtonAction), for: .touchUpInside) + button.isExclusiveTouch = true return button }() diff --git a/Sources/GiniCaptureSDK/Core/Screens/Document picker/Gallery/AlbumsHeaderView.swift b/Sources/GiniCaptureSDK/Core/Screens/Document picker/Gallery/AlbumsHeaderView.swift index 34df61a..b02512a 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Document picker/Gallery/AlbumsHeaderView.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Document picker/Gallery/AlbumsHeaderView.swift @@ -26,6 +26,7 @@ final class AlbumsHeaderView: UITableViewHeaderFooterView { selectPhotosButton.setTitleColor(.GiniCapture.accent1, for: .normal) selectPhotosButton.sizeToFit() selectPhotosButton.titleLabel?.adjustsFontForContentSizeCategory = true + selectPhotosButton.isExclusiveTouch = true } override init(reuseIdentifier: String?) { diff --git a/Sources/GiniCaptureSDK/Core/Screens/Onboarding/Views/OnboardingBottomNavigationBar.swift b/Sources/GiniCaptureSDK/Core/Screens/Onboarding/Views/OnboardingBottomNavigationBar.swift index d346187..8d14cb3 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Onboarding/Views/OnboardingBottomNavigationBar.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Onboarding/Views/OnboardingBottomNavigationBar.swift @@ -30,14 +30,17 @@ final class OnboardingBottomNavigationBar: UIView { nextButton.titleLabel?.font = configuration.textStyleFonts[.bodyBold] nextButton.configure(with: configuration.primaryButtonConfiguration) nextButton.isAccessibilityElement = true + nextButton.isExclusiveTouch = true skipButton.titleLabel?.font = configuration.textStyleFonts[.bodyBold] skipButton.configure(with: configuration.transparentButtonConfiguration) skipButton.isAccessibilityElement = true + skipButton.isExclusiveTouch = true getStarted.titleLabel?.font = configuration.textStyleFonts[.bodyBold] getStarted.configure(with: configuration.primaryButtonConfiguration) getStarted.isAccessibilityElement = true + getStarted.isExclusiveTouch = true skipButton.setTitle(NSLocalizedStringPreferredFormat("ginicapture.onboarding.skip", comment: "Skip button"), for: .normal) diff --git a/Sources/GiniCaptureSDK/Core/Screens/Review/ReviewCollectionCell.swift b/Sources/GiniCaptureSDK/Core/Screens/Review/ReviewCollectionCell.swift index 4a8090a..3277403 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Review/ReviewCollectionCell.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Review/ReviewCollectionCell.swift @@ -33,6 +33,7 @@ final class ReviewCollectionCell: UICollectionViewCell { button.setImage(deleteIcon, for: .normal) button.imageView?.contentMode = .scaleAspectFit button.addTarget(self, action: #selector(didTapDelete), for: .touchUpInside) + button.isExclusiveTouch = true button.isHidden = true button.isAccessibilityElement = true button.accessibilityLabel = NSLocalizedStringPreferredFormat("ginicapture.review.delete", comment: "Delete") diff --git a/Sources/GiniCaptureSDK/Core/Screens/Review/ReviewZoomViewController.swift b/Sources/GiniCaptureSDK/Core/Screens/Review/ReviewZoomViewController.swift index 3034f22..cac7017 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Review/ReviewZoomViewController.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Review/ReviewZoomViewController.swift @@ -16,6 +16,7 @@ final class ReviewZoomViewController: UIViewController { closeButton.setImage(UIImageNamedPreferred(named: "close_icon"), for: .normal) closeButton.imageView?.contentMode = .scaleAspectFit closeButton.addTarget(self, action: #selector(didTapCloseButton), for: .touchUpInside) + closeButton.isExclusiveTouch = true return closeButton }() private var page: GiniCapturePage diff --git a/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator+Camera.swift b/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator+Camera.swift index d31bc5b..3452299 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator+Camera.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator+Camera.swift @@ -2,7 +2,7 @@ // GiniScreenAPICoordinator+Camera.swift // GiniCapture // -// Created by Enrique del Pozo Gómez on 4/4/18. +// Copyright © 2024 Gini GmbH. All rights reserved. // import UIKit @@ -268,22 +268,31 @@ extension GiniScreenAPICoordinator { fileprivate func validate(_ documents: [GiniCaptureDocument], completion: @escaping (Result<[GiniCapturePage], Error>) -> Void) { + var documentsToValidate = documents + pages.map { $0.document } + + for document in documentsToValidate where document.type == .qrcode { + // Scanning a QR code takes priority, even if the user has already taken some pictures. + // All the pages that have already been scanned should be discarded and keep the document generated after scanning the QR code. + // The flow of the QR code scanning process should be followed + documentsToValidate = [document] + break + } - guard !(documents + pages.map {$0.document}).containsDifferentTypes else { + guard !documentsToValidate.containsDifferentTypes else { completion(.failure(FilePickerError.mixedDocumentsUnsupported)) return } - guard (documents.filter({ $0.type == .pdf }) + - pages.map({ $0.document }).filter({ $0.type == .pdf })).count <= 1 else { + guard documentsToValidate.filter({ $0.type == .pdf }).count <= 1 else { completion(.failure(FilePickerError.multiplePdfsUnsupported)) return } - guard (documents.count + pages.count) <= GiniCaptureDocumentValidator.maxPagesCount else { + guard documentsToValidate.count <= GiniCaptureDocumentValidator.maxPagesCount else { completion(.failure(FilePickerError.maxFilesPickedCountExceeded)) return } + self.validate(importedDocuments: documents) { validatedDocuments in let elementsWithError = validatedDocuments.filter { $0.error != nil } if let firstElement = elementsWithError.first, @@ -303,7 +312,7 @@ extension GiniScreenAPICoordinator { var documentError: Error? do { try GiniCaptureDocumentValidator.validate(document, - withConfig: self.giniConfiguration) + withConfig: self.giniConfiguration) } catch let error { documentError = error } diff --git a/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator.swift b/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator.swift index 3664f61..659c81b 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator.swift @@ -233,6 +233,11 @@ extension GiniScreenAPICoordinator { } @objc func showHelpMenuScreen() { + let topViewController = screenAPINavigationController.topViewController + guard topViewController is CameraViewController else { + return + } + let helpMenuViewController = HelpMenuViewController( giniConfiguration: giniConfiguration ) @@ -247,14 +252,12 @@ extension GiniScreenAPICoordinator { // In case of 1 menu item it's better to show the item immediately without any selection - if helpMenuViewController.dataSource.items.count == 1 { - screenAPINavigationController - .pushViewController(helpItemViewController(for: helpMenuViewController.dataSource.items[0]), - animated: true) - } else { - screenAPINavigationController - .pushViewController(helpMenuViewController, animated: true) - } + let menuItems = helpMenuViewController.dataSource.items + let helpViewControllerForOneItem = helpItemViewController(for: helpMenuViewController.dataSource.items[0]) + let helpViewControllerToPush = menuItems.count == 1 ? helpViewControllerForOneItem : helpMenuViewController + + screenAPINavigationController.pushViewController(helpViewControllerToPush, animated: true) + } @objc func showAnalysisScreen() { diff --git a/Sources/GiniCaptureSDK/GiniCaptureSDKVersion.swift b/Sources/GiniCaptureSDK/GiniCaptureSDKVersion.swift index 166818d..e75daee 100644 --- a/Sources/GiniCaptureSDK/GiniCaptureSDKVersion.swift +++ b/Sources/GiniCaptureSDK/GiniCaptureSDKVersion.swift @@ -5,4 +5,4 @@ // Created by Nadya Karaban on 29.10.21. // -public let GiniCaptureSDKVersion = "3.7.2" +public let GiniCaptureSDKVersion = "3.8.0" diff --git a/Sources/GiniCaptureSDK/Networking/DocumentService.swift b/Sources/GiniCaptureSDK/Networking/DocumentService.swift index a63b3f7..d8c6b09 100644 --- a/Sources/GiniCaptureSDK/Networking/DocumentService.swift +++ b/Sources/GiniCaptureSDK/Networking/DocumentService.swift @@ -34,17 +34,12 @@ public final class DocumentService: DocumentServiceProtocol { } public func upload(document: GiniCaptureDocument, - completion: UploadDocumentCompletion?) { - self.partialDocuments[document.id] = - PartialDocument(info: (PartialDocumentInfo(document: nil, rotationDelta: 0)), - document: nil, - order: self.partialDocuments.count) + completion: UploadDocumentCompletion?) { + captureNetworkService.upload(document: document, metadata: metadata) { result in switch result { case .success(let createdDocument): - self.partialDocuments[document.id]?.document = createdDocument - self.partialDocuments[document.id]?.info.document = createdDocument.links.document - + self.updatePartialDocuments(for: document, with: createdDocument) completion?(.success(createdDocument)) case .failure(let error): DispatchQueue.main.async { @@ -59,9 +54,20 @@ public final class DocumentService: DocumentServiceProtocol { } } } - - - + + private func updatePartialDocuments(for document: GiniCaptureDocument, with createdDocument: Document) { + // Scanning a QR code takes priority, even if the user has already taken some pictures. + // All the pages that have already been scanned should be discarded and keep the document generated after scanning the QR code. + // The composite document should be created just with the document generated after scanning the QR cod + if document.type == .qrcode && partialDocuments.isNotEmpty { + partialDocuments.removeAll() + } + let partialDocumentInfo = PartialDocumentInfo(document: createdDocument.links.document, rotationDelta: 0) + partialDocuments[document.id] = PartialDocument(info: partialDocumentInfo, + document: createdDocument, + order: partialDocuments.count) + } + public func startAnalysis(completion: @escaping AnalysisCompletion) { let partialDocumentsInfoSorted = partialDocuments .lazy diff --git a/Sources/GiniCaptureSDK/Resources/GiniColors.swift b/Sources/GiniCaptureSDK/Resources/GiniColors.swift index b43bdd8..8f9c252 100644 --- a/Sources/GiniCaptureSDK/Resources/GiniColors.swift +++ b/Sources/GiniCaptureSDK/Resources/GiniColors.swift @@ -1,76 +1,157 @@ // // UIColor+Gini.swift -// // -// Created by David Vizaknai on 24.08.2022. +// Copyright © 2024 Gini GmbH. All rights reserved. // import UIKit -extension UIColor { - struct GiniCapture { - static let accent1 = UIColorPreferred(named: "Accent01") - static let accent2 = UIColorPreferred(named: "Accent02") - static let accent3 = UIColorPreferred(named: "Accent03") - static let accent4 = UIColorPreferred(named: "Accent04") - static let accent5 = UIColorPreferred(named: "Accent05") - - static let dark1 = UIColorPreferred(named: "Dark01") - static let dark2 = UIColorPreferred(named: "Dark02") - static let dark3 = UIColorPreferred(named: "Dark03") - static let dark4 = UIColorPreferred(named: "Dark04") - static let dark5 = UIColorPreferred(named: "Dark05") - static let dark6 = UIColorPreferred(named: "Dark06") - static let dark7 = UIColorPreferred(named: "Dark07") - - static let error1 = UIColorPreferred(named: "Error01") - static let error2 = UIColorPreferred(named: "Error02") - static let error3 = UIColorPreferred(named: "Error03") - static let error4 = UIColorPreferred(named: "Error04") - static let error5 = UIColorPreferred(named: "Error05") - - static let light1 = UIColorPreferred(named: "Light01") - static let light2 = UIColorPreferred(named: "Light02") - static let light3 = UIColorPreferred(named: "Light03") - static let light4 = UIColorPreferred(named: "Light04") - static let light5 = UIColorPreferred(named: "Light05") - static let light6 = UIColorPreferred(named: "Light06") +public enum GiniCaptureColors: String, CaseIterable { + case accent01 = "Accent01" + case accent02 = "Accent02" + case accent03 = "Accent03" + case accent04 = "Accent04" + case accent05 = "Accent05" + case dark01 = "Dark01" + case dark02 = "Dark02" + case dark03 = "Dark03" + case dark04 = "Dark04" + case dark05 = "Dark05" + case dark06 = "Dark06" + case dark07 = "Dark07" + case error01 = "Error01" + case error02 = "Error02" + case error03 = "Error03" + case error04 = "Error04" + case error05 = "Error05" + case light01 = "Light01" + case light02 = "Light02" + case light03 = "Light03" + case light04 = "Light04" + case light05 = "Light05" + case light06 = "Light06" + case success01 = "Success01" + case success02 = "Success02" + case success03 = "Success03" + case success04 = "Success04" + case success05 = "Success05" + case warning01 = "Warning01" + case warning02 = "Warning02" + case warning03 = "Warning03" + case warning04 = "Warning04" + case warning05 = "Warning05" - static let success1 = UIColorPreferred(named: "Success01") - static let success2 = UIColorPreferred(named: "Success02") - static let success3 = UIColorPreferred(named: "Success03") - static let success4 = UIColorPreferred(named: "Success04") - static let success5 = UIColorPreferred(named: "Success05") + // Convert enum case to UIColor + var toUIColor: UIColor { + return UIColorPreferredByProvider(named: rawValue) + } - static let warning1 = UIColorPreferred(named: "Warning01") - static let warning2 = UIColorPreferred(named: "Warning02") - static let warning3 = UIColorPreferred(named: "Warning03") - static let warning4 = UIColorPreferred(named: "Warning04") - static let warning5 = UIColorPreferred(named: "Warning05") + // This property provides a convenient way to access the UIColor corresponding to the raw value of the GiniCaptureColors enum. + public var preferredUIColor: UIColor { + return UIColorPreferred(named: rawValue) + } +} - // GiniColors OLD - static let systemWhite = UIColorPreferred(named: "systemWhite") - static let label = UIColorPreferred(named: "label") - static let labelWhite = UIColorPreferred(named: "labelWhite") - static let grayLabel = UIColorPreferred(named: "grayLabel") - static let errorBackground = UIColorPreferred(named: "errorBackground") - static let helpBackground = UIColorPreferred(named: "helpBackground") - static let separator = UIColorPreferred(named: "separator") - static let subheadline = UIColorPreferred(named: "subheadline") - static let systemBlue = UIColorPreferred(named: "systemBlue") - static let systemGray = UIColorPreferred(named: "systemGray") - static let systemGray02 = UIColorPreferred(named: "systemGray02") - static let systemGray03 = UIColorPreferred(named: "systemGray03") - static let systemGray04 = UIColorPreferred(named: "systemGray04") - static let systemGray05 = UIColorPreferred(named: "systemGray05") - static let systemGray06 = UIColorPreferred(named: "systemGray06") - static let systemGreen = UIColorPreferred(named: "systemGreen") - static let systemIndigo = UIColorPreferred(named: "systemIndigo") - static let systemOrange = UIColorPreferred(named: "systemOrange") - static let systemPink = UIColorPreferred(named: "systemPink") - static let systemPurple = UIColorPreferred(named: "systemPurple") - static let systemRed = UIColorPreferred(named: "systemRed") - static let systemTeal = UIColorPreferred(named: "systemTeal") - static let systemYellow = UIColorPreferred(named: "systemYellow") +extension UIColor { + public struct GiniCapture { + public static var accent1: UIColor { + return GiniCaptureColors.accent01.toUIColor + } + public static var accent2: UIColor { + return GiniCaptureColors.accent02.toUIColor + } + public static var accent3: UIColor { + return GiniCaptureColors.accent03.toUIColor + } + public static var accent4: UIColor { + return GiniCaptureColors.accent04.toUIColor + } + public static var accent5: UIColor { + return GiniCaptureColors.accent05.toUIColor + } + public static var dark1: UIColor { + return GiniCaptureColors.dark01.toUIColor + } + public static var dark2: UIColor { + return GiniCaptureColors.dark02.toUIColor + } + public static var dark3: UIColor { + return GiniCaptureColors.dark03.toUIColor + } + public static var dark4: UIColor { + return GiniCaptureColors.dark04.toUIColor + } + public static var dark5: UIColor { + return GiniCaptureColors.dark05.toUIColor + } + public static var dark6: UIColor { + return GiniCaptureColors.dark06.toUIColor + } + public static var dark7: UIColor { + return GiniCaptureColors.dark07.toUIColor + } + public static var error1: UIColor { + return GiniCaptureColors.error01.toUIColor + } + public static var error2: UIColor { + return GiniCaptureColors.error02.toUIColor + } + public static var error3: UIColor { + return GiniCaptureColors.error03.toUIColor + } + public static var error4: UIColor { + return GiniCaptureColors.error04.toUIColor + } + public static var error5: UIColor { + return GiniCaptureColors.error05.toUIColor + } + public static var light1: UIColor { + return GiniCaptureColors.light01.toUIColor + } + public static var light2: UIColor { + return GiniCaptureColors.light02.toUIColor + } + public static var light3: UIColor { + return GiniCaptureColors.light03.toUIColor + } + public static var light4: UIColor { + return GiniCaptureColors.light04.toUIColor + } + public static var light5: UIColor { + return GiniCaptureColors.light05.toUIColor + } + public static var light6: UIColor { + return GiniCaptureColors.light06.toUIColor + } + public static var success1: UIColor { + return GiniCaptureColors.success01.toUIColor + } + public static var success2: UIColor { + return GiniCaptureColors.success02.toUIColor + } + public static var success3: UIColor { + return GiniCaptureColors.success03.toUIColor + } + public static var success4: UIColor { + return GiniCaptureColors.success04.toUIColor + } + public static var success5: UIColor { + return GiniCaptureColors.success05.toUIColor + } + public static var warning1: UIColor { + return GiniCaptureColors.warning01.toUIColor + } + public static var warning2: UIColor { + return GiniCaptureColors.warning02.toUIColor + } + public static var warning3: UIColor { + return GiniCaptureColors.warning03.toUIColor + } + public static var warning4: UIColor { + return GiniCaptureColors.warning04.toUIColor + } + public static var warning5: UIColor { + return GiniCaptureColors.warning05.toUIColor + } } } diff --git a/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/errorBackground.colorset/Contents.json b/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/errorBackground.colorset/Contents.json deleted file mode 100644 index ff66020..0000000 --- a/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/errorBackground.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.914", - "green" : "0.914", - "red" : "0.965" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "0.150", - "blue" : "0.227", - "green" : "0.271", - "red" : "1.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/grayLabel.colorset/Contents.json b/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/grayLabel.colorset/Contents.json deleted file mode 100644 index 522d36c..0000000 --- a/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/grayLabel.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.400", - "green" : "0.388", - "red" : "0.388" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/labelWhite.colorset/Contents.json b/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/labelWhite.colorset/Contents.json deleted file mode 100644 index 22c4bb0..0000000 --- a/Sources/GiniCaptureSDK/Resources/GiniColors.xcassets/labelWhite.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -}