Skip to content

Commit

Permalink
Release version 3.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Team Mobile Schorsch committed Nov 26, 2024
1 parent cbbd71b commit f433e38
Show file tree
Hide file tree
Showing 68 changed files with 2,211 additions and 452 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"
- GiniBankSDK
- "-destination"
- platform=iOS Simulator,OS=17.2,name=iPhone 14
- platform=iOS Simulator,OS=17.5,name=iPhone 15
author: Gini GmbH
author_url: https://gini.net
module: GiniBankSDK
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "GiniCaptureSDK", url: "https://github.com/gini/capture-sdk-ios.git", .exact("3.10.1")),
.package(name: "GiniCaptureSDK", url: "https://github.com/gini/capture-sdk-ios.git", .exact("3.11.0")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ final class DocumentPagesFooterView: UIView {
for item in items {
let label = UILabel()
label.text = item
label.accessibilityValue = item
label.font = configuration.textStyleFonts[.footnote]
label.textColor = .GiniBank.light1
label.translatesAutoresizingMaskIntoConstraints = false
Expand Down
101 changes: 80 additions & 21 deletions Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,32 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin
// MARK: - GiniCaptureDelegate

public func didCapture(document: GiniCaptureDocument, networkDelegate: GiniCaptureNetworkDelegate) {
// The EPS QR codes are a special case, since they don0t have to be analyzed by the Gini Bank API and therefore,
// they are ready to be delivered after capturing them.
if let qrCodeDocument = document as? GiniQRCodeDocument,
let format = qrCodeDocument.qrCodeFormat,
case .eps4mobile = format {
let extractions = qrCodeDocument.extractedParameters.compactMap {
// Common logic for creating extractions
func createExtractions(for key: String, from document: GiniQRCodeDocument) -> [Extraction] {
return document.extractedParameters.compactMap {
Extraction(box: nil, candidates: nil,
entity: QRCodesExtractor.epsCodeUrlKey,
entity: key,
value: $0.value,
name: QRCodesExtractor.epsCodeUrlKey)
name: key)
}
}

// Common logic for delivering the result
func deliverExtractionResult(for key: String, document: GiniQRCodeDocument) {
let extractions = createExtractions(for: key, from: document)
let extractionResult = ExtractionResult(extractions: extractions,
lineItems: [],
returnReasons: [],
candidates: [:])

deliver(result: extractionResult, analysisDelegate: networkDelegate)
}

// The EPS QR codes are a special case, since they don't have to be analyzed by the Gini Bank API and therefore,
// they are ready to be delivered after capturing them.
if let qrCodeDocument = document as? GiniQRCodeDocument,
let format = qrCodeDocument.qrCodeFormat,
format == .eps4mobile {
deliverExtractionResult(for: QRCodesExtractor.epsCodeUrlKey, document: qrCodeDocument)
return
}

Expand Down Expand Up @@ -142,6 +151,24 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin
self.trackingDelegate = trackingDelegate
}

private init(resultsDelegate: GiniCaptureResultsDelegate,
configuration: GiniBankConfiguration,
documentMetadata: Document.Metadata?,
trackingDelegate: GiniCaptureTrackingDelegate?,
lib: GiniBankAPI) {
documentService = DocumentService(lib: lib, metadata: documentMetadata)
configurationService = lib.configurationService()
let captureConfiguration = configuration.captureConfiguration()
super.init(withDelegate: nil, giniConfiguration: captureConfiguration)

visionDelegate = self
GiniBank.setConfiguration(configuration)
giniBankConfiguration = configuration
giniBankConfiguration.documentService = documentService
self.resultsDelegate = resultsDelegate
self.trackingDelegate = trackingDelegate
}

public init(resultsDelegate: GiniCaptureResultsDelegate,
configuration: GiniBankConfiguration,
documentMetadata: Document.Metadata?,
Expand Down Expand Up @@ -184,6 +211,22 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin
lib: lib)
}

convenience init(alternativeTokenSource tokenSource: AlternativeTokenSource,
resultsDelegate: GiniCaptureResultsDelegate,
configuration: GiniBankConfiguration,
documentMetadata: Document.Metadata?,
trackingDelegate: GiniCaptureTrackingDelegate?) {
let lib = GiniBankAPI
.Builder(alternativeTokenSource: tokenSource)
.build()

self.init(resultsDelegate: resultsDelegate,
configuration: configuration,
documentMetadata: documentMetadata,
trackingDelegate: trackingDelegate,
lib: lib)
}

private func deliver(result: ExtractionResult, analysisDelegate: AnalysisDelegate) {
let hasExtractions = result.extractions.count > 0

Expand Down Expand Up @@ -567,10 +610,11 @@ extension GiniBankNetworkingScreenApiCoordinator: SkontoCoordinatorDelegate {
self?.transactionDocsDataCoordinator?.transactionDocs = [.init(documentId: documentId,
fileName: "Document",
type: .document)]
self?.setTransactionDocsDataToDisplay(with: extractionResult, for: documentId)
} else {
self?.transactionDocsDataCoordinator?.transactionDocs = []
}
self?.setTransactionDocsDataToDisplay(with: extractionResult)

deliveryFunction(extractionResult)
})
}
Expand Down Expand Up @@ -719,18 +763,31 @@ extension GiniBankNetworkingScreenApiCoordinator: SkontoCoordinatorDelegate {
}

extension GiniBankNetworkingScreenApiCoordinator {
private func setTransactionDocsDataToDisplay(with extractionResult: ExtractionResult) {
private func setTransactionDocsDataToDisplay(with extractionResult: ExtractionResult, for documentId: String) {
transactionDocsDataCoordinator?.loadDocumentData = { [weak self] in
self?.loadDocumentPages { [weak self] images, error in
guard let self = self else { return }
DispatchQueue.main.async {
if let error = error {
self.handlePreviewDocumentError(error: error)
return
}
guard let viewModel = self?.transactionDocsDataCoordinator?.getTransactionDocsViewModel(),
let images = viewModel.cachedImages[documentId],
!images.isEmpty else {
self?.loadDocumentPagesAndHandleErrors(for: documentId, with: extractionResult)
return
}
self?.updateTransactionDocsViewModel(with: images,
extractionResult: extractionResult,
for: documentId)
}
}

self.updateTransactionDocsViewModel(with: images, extractionResult: extractionResult)
private func loadDocumentPagesAndHandleErrors(for documentId: String, with extractionResult: ExtractionResult) {
loadDocumentPages { [weak self] images, error in
guard let self = self else { return }
DispatchQueue.main.async {
if let error = error {
self.handlePreviewDocumentError(error: error)
return
}
self.updateTransactionDocsViewModel(with: images,
extractionResult: extractionResult,
for: documentId)
}
}
}
Expand All @@ -744,12 +801,14 @@ extension GiniBankNetworkingScreenApiCoordinator {
}
}

private func updateTransactionDocsViewModel(with images: [UIImage], extractionResult: ExtractionResult) {
private func updateTransactionDocsViewModel(with images: [UIImage],
extractionResult: ExtractionResult,
for documentId: String) {
let extractionInfo = TransactionDocsExtractions(extractions: extractionResult)
let viewModel = TransactionDocsDocumentPagesViewModel(originalImages: images,
extractions: extractionInfo)
transactionDocsDataCoordinator?
.getTransactionDocsViewModel()?
.setTransactionDocsDocumentPagesViewModel(viewModel)
.setTransactionDocsDocumentPagesViewModel(viewModel, for: documentId)
}
}
29 changes: 29 additions & 0 deletions Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension GiniBank {
all screens and transitions out of the box, including the networking.

- parameter client: `GiniClient` with the information needed to enable document analysis
- parameter importedDocuments: There should be either images or one PDF, and they should be validated before calling this method.
- parameter resultsDelegate: Results delegate object where you can get the results of the analysis.
- parameter configuration: The configuration to set.
- parameter documentMetadata: Additional HTTP headers to send when uploading documents
Expand Down Expand Up @@ -46,6 +47,34 @@ extension GiniBank {
return screenCoordinator.startSDK(withDocuments: importedDocuments)
}

/**
Returns a view controller which will handle the analysis process.
It's the easiest way to get started with the Gini Bank SDK as it comes pre-configured and handles
all screens and transitions out of the box, including the networking.

- parameter tokenSource: Alternative token source
- parameter importedDocuments: There should be either images or one PDF, and they should be validated before calling this method.
- parameter resultsDelegate: Results delegate object where you can get the results of the analysis.
- parameter configuration: The configuration to set.
- parameter documentMetadata: Additional HTTP headers to send when uploading documents
- parameter trackingDelegate: A delegate object to receive user events

- returns: A presentable view controller.
*/
public class func viewController(withAlternativeTokenSource tokenSource: AlternativeTokenSource,
importedDocuments: [GiniCaptureDocument]? = nil,
configuration: GiniBankConfiguration,
resultsDelegate: GiniCaptureResultsDelegate,
documentMetadata: Document.Metadata? = nil,
trackingDelegate: GiniCaptureTrackingDelegate? = nil) -> UIViewController {
let screenCoordinator = GiniBankNetworkingScreenApiCoordinator(alternativeTokenSource: tokenSource,
resultsDelegate: resultsDelegate,
configuration: configuration,
documentMetadata: documentMetadata,
trackingDelegate: trackingDelegate)
return screenCoordinator.startSDK(withDocuments: importedDocuments)
}

// MARK: - Screen API with Custom Networking - Initializers for 'UIViewController'

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ final class DigitalInvoiceBottomNavigationBar: UIView {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = configuration.textStyleFonts[.footnoteBold]
label.textColor = .giniColorScheme().chips.textSuggestionEnabled.uiColor()
label.textColor = .giniColorScheme().badge.content.uiColor()
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true
label.setContentHuggingPriority(.defaultLow, for: .horizontal)
Expand All @@ -80,7 +80,7 @@ final class DigitalInvoiceBottomNavigationBar: UIView {

private lazy var skontoBadgeView: UIView = {
let view = UIView()
view.backgroundColor = .giniColorScheme().chips.suggestionEnabled.uiColor()
view.backgroundColor = .giniColorScheme().badge.background.uiColor()
view.layer.cornerRadius = Constants.cornerRadius
view.layer.masksToBounds = true
view.isHidden = true
Expand All @@ -93,15 +93,15 @@ final class DigitalInvoiceBottomNavigationBar: UIView {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = configuration.textStyleFonts[.footnoteBold]
label.textColor = .giniColorScheme().chips.suggestionEnabled.uiColor()
label.textColor = .giniColorScheme().text.success.uiColor()
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true
return label
}()

private lazy var dividerView: UIView = {
let dividerView = UIView()
dividerView.backgroundColor = .giniColorScheme().bg.divider.uiColor()
dividerView.backgroundColor = .giniColorScheme().bottomBar.border.uiColor()
dividerView.translatesAutoresizingMaskIntoConstraints = false
return dividerView
}()
Expand Down Expand Up @@ -156,7 +156,7 @@ final class DigitalInvoiceBottomNavigationBar: UIView {
}

private func setupView() {
backgroundColor = .giniColorScheme().bg.surface.uiColor()
backgroundColor = .giniColorScheme().background.secondary.uiColor()

addSubview(contentView)
addSubview(dividerView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DigitalInvoiceProceedView: UIView {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = configuration.textStyleFonts[.footnoteBold]
label.textColor = .giniColorScheme().chips.textSuggestionEnabled.uiColor()
label.textColor = .giniColorScheme().badge.content.uiColor()
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true
label.setContentHuggingPriority(.defaultLow, for: .horizontal)
Expand All @@ -67,7 +67,7 @@ class DigitalInvoiceProceedView: UIView {

private lazy var skontoBadgeView: UIView = {
let view = UIView()
view.backgroundColor = .giniColorScheme().chips.suggestionEnabled.uiColor()
view.backgroundColor = .giniColorScheme().badge.background.uiColor()
view.layer.cornerRadius = Constants.cornerRadius
view.layer.masksToBounds = true
view.isHidden = true
Expand All @@ -80,15 +80,15 @@ class DigitalInvoiceProceedView: UIView {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = configuration.textStyleFonts[.footnoteBold]
label.textColor = .giniColorScheme().chips.suggestionEnabled.uiColor()
label.textColor = .giniColorScheme().badge.background.uiColor()
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true
return label
}()

private lazy var dividerView: UIView = {
let dividerView = UIView()
dividerView.backgroundColor = .giniColorScheme().bg.divider.uiColor()
dividerView.backgroundColor = .giniColorScheme().bottomBar.border.uiColor()
dividerView.translatesAutoresizingMaskIntoConstraints = false
return dividerView
}()
Expand All @@ -107,7 +107,7 @@ class DigitalInvoiceProceedView: UIView {
}

private func setupView() {
backgroundColor = .giniColorScheme().bg.surface.uiColor()
backgroundColor = .giniColorScheme().background.secondary.uiColor()
translatesAutoresizingMaskIntoConstraints = false

addSubview(contentView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DigitalInvoiceSkontoTableViewCell: UITableViewCell {
let label = UILabel()
label.adjustsFontForContentSizeCategory = true
label.font = GiniBankConfiguration.shared.textStyleFonts[.bodyBold]
label.textColor = .giniColorScheme().text.status.uiColor()
label.textColor = .giniColorScheme().text.success.uiColor()
return label
}()

Expand All @@ -51,6 +51,7 @@ class DigitalInvoiceSkontoTableViewCell: UITableViewCell {
button.setTitle(title, for: .normal)
button.setTitleColor(.GiniBank.accent1, for: .normal)
button.titleLabel?.font = GiniBankConfiguration.shared.textStyleFonts[.body]
button.contentHorizontalAlignment = .left
return button
}()

Expand Down Expand Up @@ -98,7 +99,7 @@ class DigitalInvoiceSkontoTableViewCell: UITableViewCell {
// MARK: - Setup Methods
private func setupViews() {
selectionStyle = .none
backgroundColor = .giniColorScheme().bg.surface.uiColor()
backgroundColor = .giniColorScheme().container.background.uiColor()
clipsToBounds = true
layer.cornerRadius = 8
layer.maskedCorners = [.layerMaxXMaxYCorner, .layerMinXMaxYCorner]
Expand All @@ -115,7 +116,8 @@ class DigitalInvoiceSkontoTableViewCell: UITableViewCell {
constant: Constants.stackViewVerticalSpacing),
mainStackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor,
constant: -Constants.stackViewVerticalSpacing),
titleLabel.heightAnchor.constraint(greaterThanOrEqualTo: toggleSwitch.heightAnchor)
titleLabel.heightAnchor.constraint(greaterThanOrEqualTo: toggleSwitch.heightAnchor),
editButton.widthAnchor.constraint(greaterThanOrEqualToConstant: Constants.editButtonMinWidth)
])
}

Expand Down Expand Up @@ -143,6 +145,9 @@ class DigitalInvoiceSkontoTableViewCell: UITableViewCell {
valueLabel.text = savingsPrice
toggleSwitch.isOn = viewModel.isSkontoApplied
edgeCaseLabel.text = viewModel.localizedBannerInfoMessage

editButton.alpha = viewModel.isSkontoApplied ? 1 : 0.5
editButton.isEnabled = viewModel.isSkontoApplied
delegate?.reloadCell(cell: self)
}

Expand All @@ -152,7 +157,7 @@ class DigitalInvoiceSkontoTableViewCell: UITableViewCell {
}

@objc private func editButtonTapped() {
self.delegate?.editTapped(cell: self)
delegate?.editTapped(cell: self)
}
}

Expand All @@ -163,5 +168,6 @@ private extension DigitalInvoiceSkontoTableViewCell {
static let toggleSwitchSpacing: CGFloat = 16.0
static let labelsEditButtonSpacing: CGFloat = 12.0
static let stackViewVerticalSpacing: CGFloat = 16.0
static let editButtonMinWidth: CGFloat = 80.0
}
}
Loading

0 comments on commit f433e38

Please sign in to comment.