diff --git a/Documentation/source/Customization guide.md b/Documentation/source/Customization guide.md index 64a7ff0..e74fbfe 100644 --- a/Documentation/source/Customization guide.md +++ b/Documentation/source/Customization guide.md @@ -66,16 +66,22 @@ Some background and text colors use the `GiniColor` type with which you can set - With title only - Title → `GiniConfiguration.navigationBarCameraTitleCloseButton` - Help button - - Image → *navigationCameraHelp* image asset - - Title → *ginicapture.navigationbar.camera.help* localized string - + - With image and title + - Image → *navigationCameraHelp* image asset + - Title → *ginicapture.navigationbar.camera.help* localized string + - With title only + - Title → `GiniConfiguration.navigationBarCameraTitleHelpButton` + ##### 2. Camera preview +- Preview frame color → `GiniConfiguration.cameraPreviewFrameColor` - Guides color → `GiniConfiguration.cameraPreviewCornerGuidesColor` - Focus large image → *cameraFocusLarge* image asset - Focus large small → *cameraFocusSmall* image asset - Opaque view style (when tool tip is shown) → `GiniConfiguration.toolTipOpaqueBackgroundStyle` ##### 3. Camera buttons container +- Background color → `GiniConfiguration.cameraButtonsViewBackgroundColor` +- Container view background color under the home indicator → `GiniConfiguration.cameraContainerViewBackgroundColor` - Capture button - Image → *cameraCaptureButton* image asset - Import button @@ -193,7 +199,9 @@ Some background and text colors use the `GiniColor` type with which you can set - Title → `GiniConfiguration.navigationBarHelpScreenTitleBackToMenuButton` ##### 1. Supported format cells +- Supported fortmats icon → *supportedFormatsIcon* image asset - Supported formats icon color → `GiniConfiguration.supportedFormatsIconColor` +- Non supported fortmats icon → *nonSupportedFormatsIcon* image asset - Non supported formats icon color → `GiniConfiguration.nonSupportedFormatsIconColor` ## Open with tutorial screen @@ -244,6 +252,8 @@ Some background and text colors use the `GiniColor` type with which you can set ##### 2. Go to camera button - Background color → `GiniConfiguration.noResultsBottomButtonColor` +- Text color → `GiniConfiguration.noResultsBottomButtonTextColor` +- Corner radius → `GiniConfiguration.noResultsBottomButtonCornerRadius` ## Gallery album screen diff --git a/Documentation/source/Installation.md b/Documentation/source/Installation.md index ec1e716..29f7621 100644 --- a/Documentation/source/Installation.md +++ b/Documentation/source/Installation.md @@ -10,14 +10,14 @@ Once you have your Swift package set up, adding `GiniCaptureSDK` as a dependency ```swift dependencies: [ - .package(url: "https://github.com/gini/capture-sdk-ios.git", .exact("1.6.0")) + .package(url: "https://github.com/gini/capture-sdk-ios.git", .exact("1.7.0")) ] ``` In case that you want to use the certificate pinning in the library, add `GiniCaptureSDKPinning`: ```swift dependencies: [ - .package(url: "https://github.com/gini/capture-sdk-pinning-ios.git", .exact("1.6.0")) + .package(url: "https://github.com/gini/capture-sdk-pinning-ios.git", .exact("1.7.0")) ] ``` diff --git a/Package.swift b/Package.swift index e7af465..fe861c2 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), - .package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("1.2.0")), + .package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("1.3.0")), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/GiniCaptureSDK/Core/Extensions/UIImage.swift b/Sources/GiniCaptureSDK/Core/Extensions/UIImage.swift index dbec259..d1ed6fd 100644 --- a/Sources/GiniCaptureSDK/Core/Extensions/UIImage.swift +++ b/Sources/GiniCaptureSDK/Core/Extensions/UIImage.swift @@ -69,4 +69,17 @@ extension UIImage { return UIImage(cgImage: downsampledImage) } + func tintedImageWithColor(_ color: UIColor) -> UIImage? { + let image = withRenderingMode(.alwaysTemplate) + UIGraphicsBeginImageContextWithOptions(size, false, scale) + color.set() + image.draw(in: CGRect(origin: .zero, size: size)) + + guard let imageColored = UIGraphicsGetImageFromCurrentImageContext() else { + return nil + } + UIGraphicsEndImageContext() + return imageColored + } + } diff --git a/Sources/GiniCaptureSDK/Core/GiniConfiguration.swift b/Sources/GiniCaptureSDK/Core/GiniConfiguration.swift index e27c739..cfb5acc 100644 --- a/Sources/GiniCaptureSDK/Core/GiniConfiguration.swift +++ b/Sources/GiniCaptureSDK/Core/GiniConfiguration.swift @@ -234,6 +234,21 @@ import UIKit */ @objc public var cameraPreviewCornerGuidesColor = UIColor.white + /** + Sets the background color of camera container view. + */ + @objc public var cameraContainerViewBackgroundColor = GiniColor(lightModeColor: .black, darkModeColor: .black) + + /** + Sets the color of camera preview frame. + */ + @objc public var cameraPreviewFrameColor = GiniColor(lightModeColor: UIColor(white: 0.0, alpha: 0.7), darkModeColor: UIColor(white: 0.0, alpha: 0.7)) + + /** + Sets the background color of camera buttons view. + */ + @objc public var cameraButtonsViewBackgroundColor = GiniColor(lightModeColor: .black, darkModeColor: .black) + /** Set the types supported by the file import feature. `GiniCaptureImportFileTypes.none` by default. */ @@ -608,6 +623,16 @@ import UIKit */ @objc public var noResultsBottomButtonColor = Colors.Gini.blue + /** + Sets the text color of the bottom button to the specified color. + */ + @objc public var noResultsBottomButtonTextColor = GiniColor.init(lightModeColor: .white, darkModeColor: .white) + + /** + Sets the corner radius of the bottom button. + */ + @objc public var noResultsBottomButtonCornerRadius: CGFloat = 0.0 + /** Sets the color of the warning container background to the specified color. */ diff --git a/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraButtonsViewController.swift b/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraButtonsViewController.swift index 466d1d4..85fa32f 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraButtonsViewController.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraButtonsViewController.swift @@ -130,7 +130,7 @@ final class CameraButtonsViewController: UIViewController { public override func loadView() { super.loadView() - view.backgroundColor = .black + view.backgroundColor = UIColor.from(giniColor: giniConfiguration.cameraButtonsViewBackgroundColor) view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(captureButton) diff --git a/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraPreviewView.swift b/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraPreviewView.swift index 115d798..d86db5f 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraPreviewView.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraPreviewView.swift @@ -11,7 +11,7 @@ import AVFoundation final class CameraPreviewView: UIView { - let frameColor = UIColor(white: 0.0, alpha: 0.7) + let frameColor = UIColor.from(giniColor: GiniConfiguration.shared.cameraPreviewFrameColor) let guideLineLength: CGFloat = 50.0 let guideLineWidth: CGFloat = 2.0 /// the size of the guides compared to the size of the whole view diff --git a/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraViewController.swift b/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraViewController.swift index 0fc4219..d07361f 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraViewController.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Camera/CameraViewController.swift @@ -126,7 +126,7 @@ import AVFoundation public override func loadView() { super.loadView() edgesForExtendedLayout = [] - view.backgroundColor = .black + view.backgroundColor = UIColor.from(giniColor: giniConfiguration.cameraContainerViewBackgroundColor) // `previewView` must be added at 0 because otherwise NotAuthorizedView button won't ever be touchable addChild(cameraPreviewViewController) diff --git a/Sources/GiniCaptureSDK/Core/Screens/Help/No results/ImageAnalysisNoResultsViewController.swift b/Sources/GiniCaptureSDK/Core/Screens/Help/No results/ImageAnalysisNoResultsViewController.swift index 3e8a7ec..70b0765 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Help/No results/ImageAnalysisNoResultsViewController.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Help/No results/ImageAnalysisNoResultsViewController.swift @@ -27,11 +27,17 @@ public final class ImageAnalysisNoResultsViewController: UIViewController { bottomButton.translatesAutoresizingMaskIntoConstraints = false bottomButton.setTitle(self.bottomButtonText, for: .normal) bottomButton.titleLabel?.font = giniConfiguration.customFont.with(weight: .bold, size: 14, style: .caption1) - bottomButton.setTitleColor(UIColor.white.withAlphaComponent(0.5), for: .highlighted) + let bottomButtonTextColor = UIColor.from(giniColor: giniConfiguration.noResultsBottomButtonTextColor) + bottomButton.setTitleColor(bottomButtonTextColor, for: .normal) + bottomButton.setTitleColor(bottomButtonTextColor.withAlphaComponent(0.5), for: .highlighted) bottomButton.setImage(self.bottomButtonIconImage, for: .normal) + if let highlightedImage = self.bottomButtonIconImage?.tintedImageWithColor(bottomButtonTextColor.withAlphaComponent(0.5)){ + bottomButton.setImage(highlightedImage, for: .highlighted) + } bottomButton.addTarget(self, action: #selector(didTapBottomButtonAction), for: .touchUpInside) bottomButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 20) - bottomButton.backgroundColor = GiniConfiguration.shared.noResultsBottomButtonColor + bottomButton.backgroundColor = giniConfiguration.noResultsBottomButtonColor + bottomButton.layer.cornerRadius = giniConfiguration.noResultsBottomButtonCornerRadius return bottomButton }() diff --git a/Sources/GiniCaptureSDK/Core/Screens/Help/Supported formats/SupportedFormatsViewController.swift b/Sources/GiniCaptureSDK/Core/Screens/Help/Supported formats/SupportedFormatsViewController.swift index f4c4abf..c780697 100644 --- a/Sources/GiniCaptureSDK/Core/Screens/Help/Supported formats/SupportedFormatsViewController.swift +++ b/Sources/GiniCaptureSDK/Core/Screens/Help/Supported formats/SupportedFormatsViewController.swift @@ -23,14 +23,12 @@ final class SupportedFormatsViewController: UITableViewController { var sections: [SupportedFormatCollectionSection] = [ (.localized(resource: HelpStrings.supportedFormatsSection1Title), [.localized(resource: HelpStrings.supportedFormatsSection1Item1Text)], - UIImage(named: "supportedFormatsIcon", - in: giniCaptureBundle(), - compatibleWith: nil), + UIImageNamedPreferred(named: "supportedFormatsIcon"), GiniConfiguration.shared.supportedFormatsIconColor), (.localized(resource: HelpStrings.supportedFormatsSection2Title), [.localized(resource: HelpStrings.supportedFormatsSection2Item1Text), .localized(resource: HelpStrings.supportedFormatsSection2Item2Text)], - UIImage(named: "nonSupportedFormatsIcon", in: giniCaptureBundle(), compatibleWith: nil), + UIImageNamedPreferred(named: "nonSupportedFormatsIcon"), GiniConfiguration.shared.nonSupportedFormatsIconColor) ] diff --git a/Sources/GiniCaptureSDK/GiniCaptureSDKVersion.swift b/Sources/GiniCaptureSDK/GiniCaptureSDKVersion.swift index d86a518..c6172be 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 = "1.6.0" +public let GiniCaptureSDKVersion = "1.7.0" diff --git a/Sources/GiniCaptureSDK/Networking/AccountingDocumentService.swift b/Sources/GiniCaptureSDK/Networking/AccountingDocumentService.swift index 4a89011..52ce8c5 100644 --- a/Sources/GiniCaptureSDK/Networking/AccountingDocumentService.swift +++ b/Sources/GiniCaptureSDK/Networking/AccountingDocumentService.swift @@ -40,7 +40,7 @@ public final class AccountingDocumentService: DocumentServiceProtocol { document = nil } - public func sendFeedback(with updatedExtractions: [Extraction]) { + public func sendFeedback(with updatedExtractions: [Extraction], updatedCompoundExtractions: [String : [[Extraction]]]?) { guard let document = document else { return } documentService.submitFeedback(for: document, with: updatedExtractions) { result in switch result { diff --git a/Sources/GiniCaptureSDK/Networking/DocumentService.swift b/Sources/GiniCaptureSDK/Networking/DocumentService.swift index efa16ae..e73c095 100644 --- a/Sources/GiniCaptureSDK/Networking/DocumentService.swift +++ b/Sources/GiniCaptureSDK/Networking/DocumentService.swift @@ -107,16 +107,16 @@ public final class DocumentService: DocumentServiceProtocol { partialDocuments[imageDocument.id]?.info.rotationDelta = imageDocument.rotationDelta } - public func sendFeedback(with updatedExtractions: [Extraction]) { + public func sendFeedback(with updatedExtractions: [Extraction], updatedCompoundExtractions: [String: [[Extraction]]]?) { Log(message: "Sending feedback", event: "💬") guard let document = document else { Log(message: "Cannot send feedback: no document", event: .error) return } - captureNetworkService.sendFeedback(document: document, updatedExtractions: updatedExtractions) { result in + captureNetworkService.sendFeedback(document: document, updatedExtractions: updatedExtractions, updatedCompoundExtractions: updatedCompoundExtractions) { result in switch result { case .success: - Log(message: "Feedback sent with \(updatedExtractions.count) extractions", + Log(message: "Feedback sent with \(updatedExtractions.count) extractions and \(updatedCompoundExtractions?.count ?? 0) compound extractions", event: "🚀") case .failure(let error): let message = "Error sending feedback for document with id: \(document.id) error: \(error)" diff --git a/Sources/GiniCaptureSDK/Networking/DocumentServiceProtocol.swift b/Sources/GiniCaptureSDK/Networking/DocumentServiceProtocol.swift index 498cb65..5463a4d 100644 --- a/Sources/GiniCaptureSDK/Networking/DocumentServiceProtocol.swift +++ b/Sources/GiniCaptureSDK/Networking/DocumentServiceProtocol.swift @@ -20,7 +20,7 @@ public protocol DocumentServiceProtocol: AnyObject { func cancelAnalysis() func remove(document: GiniCaptureDocument) func resetToInitialState() - func sendFeedback(with updatedExtractions: [Extraction]) + func sendFeedback(with updatedExtractions: [Extraction], updatedCompoundExtractions: [String: [[Extraction]]]?) func startAnalysis(completion: @escaping AnalysisCompletion) func sortDocuments(withSameOrderAs documents: [GiniCaptureDocument]) func upload(document: GiniCaptureDocument, diff --git a/Sources/GiniCaptureSDK/Networking/GiniCaptureNetworkService.swift b/Sources/GiniCaptureSDK/Networking/GiniCaptureNetworkService.swift index 1c12604..89c9393 100644 --- a/Sources/GiniCaptureSDK/Networking/GiniCaptureNetworkService.swift +++ b/Sources/GiniCaptureSDK/Networking/GiniCaptureNetworkService.swift @@ -21,6 +21,7 @@ public protocol GiniCaptureNetworkService: AnyObject { completion: @escaping UploadDocumentCompletion) func sendFeedback(document: Document, updatedExtractions: [Extraction], + updatedCompoundExtractions: [String: [[Extraction]]]?, completion: @escaping (Result) -> Void) func log(errorEvent: ErrorEvent, completion: @escaping (Result) -> Void) @@ -134,9 +135,16 @@ class DefaultCaptureNetworkService: GiniCaptureNetworkService { func sendFeedback(document: Document, updatedExtractions: [Extraction], + updatedCompoundExtractions: [String: [[Extraction]]]?, completion: @escaping (Result) -> Void) { - documentService.submitFeedback(for: document, with: updatedExtractions) { result in - completion(result) + if let updatedCompoundExtractions = updatedCompoundExtractions { + documentService.submitFeedback(for: document, with: updatedExtractions, and: updatedCompoundExtractions) { result in + completion(result) + } + } else { + documentService.submitFeedback(for: document, with: updatedExtractions) { result in + completion(result) + } } } } diff --git a/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift b/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift index 9ea541f..a243784 100644 --- a/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift +++ b/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift @@ -131,7 +131,7 @@ import GiniBankAPILibrary let documentService = self.documentService self.resultsDelegate?.giniCaptureAnalysisDidFinishWith(result: result) { updatedExtractions in - documentService.sendFeedback(with: updatedExtractions.map { $0.value }) + documentService.sendFeedback(with: updatedExtractions.map { $0.value }, updatedCompoundExtractions: nil) documentService.resetToInitialState() } } else {