Skip to content

Commit

Permalink
Release version 3.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Team Mobile Schorsch committed May 7, 2024
1 parent ab665a3 commit aea1141
Show file tree
Hide file tree
Showing 25 changed files with 255 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
9 changes: 8 additions & 1 deletion Sources/GiniCaptureSDK/Core/GiniConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 19 additions & 4 deletions Sources/GiniCaptureSDK/Core/Helpers/GiniCaptureUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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.
Expand All @@ -91,7 +106,7 @@ public func NSLocalizedStringPreferredFormat(_ key: String,
fallbackKey: fallbackKey,
comment: comment,
bundle: customBundle) {

return clientLocalizedStringCustomBundle
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
21 changes: 21 additions & 0 deletions Sources/GiniCaptureSDK/Core/Protocols/CustomResourceProvider.swift
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ extension GiniScreenAPICoordinator {
}

@objc func showHelpMenuScreen() {
let topViewController = screenAPINavigationController.topViewController
guard topViewController is CameraViewController else {
return
}

let helpMenuViewController = HelpMenuViewController(
giniConfiguration: giniConfiguration
)
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GiniCaptureSDK/GiniCaptureSDKVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Created by Nadya Karaban on 29.10.21.
//

public let GiniCaptureSDKVersion = "3.7.2"
public let GiniCaptureSDKVersion = "3.8.0"
28 changes: 17 additions & 11 deletions Sources/GiniCaptureSDK/Networking/DocumentService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Loading

0 comments on commit aea1141

Please sign in to comment.