Skip to content

Commit

Permalink
Release version 3.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Team Mobile Schorsch committed Sep 4, 2024
1 parent 211f58a commit daedec8
Show file tree
Hide file tree
Showing 20 changed files with 298 additions and 70 deletions.
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: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.2.0"))
.package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.3.0"))
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
6 changes: 4 additions & 2 deletions Sources/GiniCaptureSDK/Core/Custom views/GiniBarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,15 @@ public final class GiniBarButton {
return attributes
}

public func setContentHuggingPriority(_ priority: UILayoutPriority, for axis: NSLayoutConstraint.Axis) {
public func setContentHuggingPriority(_ priority: UILayoutPriority,
for axis: NSLayoutConstraint.Axis) {
stackView.setContentHuggingPriority(priority, for: axis)
titleLabel.setContentHuggingPriority(priority, for: axis)
imageView.setContentHuggingPriority(priority, for: axis)
}

public func setContentCompressionResistancePriority(_ priority: UILayoutPriority, for axis: NSLayoutConstraint.Axis) {
public func setContentCompressionResistancePriority(_ priority: UILayoutPriority,
for axis: NSLayoutConstraint.Axis) {
stackView.setContentCompressionResistancePriority(priority, for: axis)
titleLabel.setContentCompressionResistancePriority(priority, for: axis)
imageView.setContentCompressionResistancePriority(priority, for: axis)
Expand Down
6 changes: 6 additions & 0 deletions Sources/GiniCaptureSDK/Core/Extensions/UILabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ extension UILabel {
attributes: [NSAttributedString.Key.font: font],
context: nil).size.height
}

func enableScaling() {
adjustsFontSizeToFitWidth = true
minimumScaleFactor = 10 / font.pointSize
adjustsFontForContentSizeCategory = true
}
}
5 changes: 3 additions & 2 deletions Sources/GiniCaptureSDK/Core/Helpers/ButtonConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ public extension UIButton {
self.layer.borderWidth = configuration.borderWidth
self.layer.shadowRadius = configuration.shadowRadius

// When switching from one ButtonConfiguration with a blur effect to another ButtonConfiguration with a blur effect,
// the previous blur effect should be removed.
self.removeBlurEffect()
if configuration.withBlurEffect {
self.addBlurEffect(cornerRadius: configuration.cornerRadius)
} else {
self.removeBlurEffect()
}
}
}
9 changes: 8 additions & 1 deletion Sources/GiniCaptureSDK/Core/Models/GiniCaptureDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,20 @@ private extension GiniCaptureDocumentBuilder {
final class InputDocument: UIDocument {
public var data: Data?

override public func load(fromContents contents: Any, ofType typeName: String?) throws {
override func load(fromContents contents: Any, ofType typeName: String?) throws {

guard let data = contents as? Data else {
throw DocumentError.unrecognizedContent
}

self.data = data
}

override func writeContents(_ contents: Any, to url: URL, for saveOperation: UIDocument.SaveOperation, originalContentsURL: URL?) throws {
if (contents as? Data) == nil, (contents as? FileWrapper) == nil {
throw DocumentError.unrecognizedContent
}
try super.writeContents(contents, to: url, for: saveOperation, originalContentsURL: originalContentsURL)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import UIKit
- parameter message: The error type to be displayed.
*/
func displayError(errorType: ErrorType,
animated: Bool
)
func displayError(errorType: ErrorType, animated: Bool)

/**
In case that the `GiniCaptureDocument` analysed is an image it will display a no results screen
Expand Down Expand Up @@ -85,8 +83,7 @@ import UIKit
}()

private lazy var loadingIndicatorContainer: UIView = {
let loadingIndicatorContainer = UIView(frame: CGRect(origin: .zero,
size: .zero))
let loadingIndicatorContainer = UIView(frame: CGRect.zero)
return loadingIndicatorContainer
}()

Expand Down Expand Up @@ -142,8 +139,9 @@ import UIKit
super.viewDidAppear(animated)
didShowAnalysis?()

let documentTypeAnalytics = GiniAnalyticsMapper.documentTypeAnalytics(from: document.type)
let eventProperties = [GiniAnalyticsProperty(key: .documentType,
value: GiniAnalyticsMapper.documentTypeAnalytics(from: document.type))]
value: documentTypeAnalytics)]
GiniAnalyticsManager.trackScreenShown(screenName: .analysis,
properties: eventProperties)
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/GiniCaptureSDK/Core/Screens/Camera/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ protocol CameraProtocol: AnyObject {
var didDetectIBANs: (([String]) -> Void)? { get set }
var isFlashSupported: Bool { get }
var isFlashOn: Bool { get set }
var hasInitialized: Bool { get }

func captureStillImage(completion: @escaping (Data?, CameraError?) -> Void)
func focus(withMode mode: AVCaptureDevice.FocusMode,
Expand Down Expand Up @@ -56,6 +57,7 @@ final class Camera: NSObject, CameraProtocol {
var videoDeviceInput: AVCaptureDeviceInput?
var videoDataOutput = AVCaptureVideoDataOutput()
let videoDataOutputQueue = DispatchQueue(label: "ocr queue")
var hasInitialized: Bool { !session.inputs.isEmpty }

lazy var isFlashSupported: Bool = {
#if targetEnvironment(simulator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ extension CameraViewController {
public func setupCamera() {
cameraPreviewViewController.setupCamera()
}

public func stopLoadingIndicater() {
cameraPreviewViewController.stopLoadingIndicator()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ final class CameraViewController: UIViewController {
*/
let giniConfiguration: GiniConfiguration
var detectedQRCodeDocument: GiniQRCodeDocument?
var cameraNeedsInitializing: Bool { !cameraPreviewViewController.hasInitialized }
var shouldShowHelp: Bool { isPresentedOnScreen && !validQRCodeProcessing }

lazy var cameraPreviewViewController: CameraPreviewViewController = {
let cameraPreviewViewController = CameraPreviewViewController()
Expand All @@ -40,6 +42,7 @@ final class CameraViewController: UIViewController {
private var resetQRCodeTask: DispatchWorkItem?
private var hideQRCodeTask: DispatchWorkItem?
private var validQRCodeProcessing: Bool = false
private var isPresentedOnScreen = false

private var isValidIBANDetected: Bool = false
// Analytics
Expand Down Expand Up @@ -108,6 +111,7 @@ final class CameraViewController: UIViewController {

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
isPresentedOnScreen = true
validQRCodeProcessing = false
delegate?.cameraDidAppear(self)

Expand Down Expand Up @@ -354,6 +358,7 @@ final class CameraViewController: UIViewController {

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
isPresentedOnScreen = false

qrCodeOverLay.viewWillDisappear()
ibanDetectionOverLay.viewWillDisappear()
Expand Down Expand Up @@ -450,6 +455,7 @@ final class CameraViewController: UIViewController {
}

fileprivate func didPick(_ document: GiniCaptureDocument) {
navigationItem.rightBarButtonItem?.isEnabled = true
delegate?.camera(self, didCapture: document)
}

Expand Down Expand Up @@ -532,6 +538,7 @@ final class CameraViewController: UIViewController {
// MARK: - QR Detection

private func showQRCodeFeedback(for document: GiniQRCodeDocument, isValid: Bool) {
guard isPresentedOnScreen else { return }
guard !validQRCodeProcessing else { return }
guard detectedQRCodeDocument != document else { return }

Expand Down Expand Up @@ -576,6 +583,7 @@ final class CameraViewController: UIViewController {
screenName: .camera,
properties: [GiniAnalyticsProperty(key: .qrCodeValid, value: true)])
qrCodeOverLay.configureQrCodeOverlay(withCorrectQrCode: true)
navigationItem.rightBarButtonItem?.isEnabled = false
}

private func showInvalidQRCodeFeedback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ final class CameraPreviewViewController: UIViewController {
}
}

var hasInitialized: Bool {
camera.hasInitialized
}

var isFlashSupported: Bool {
return camera.isFlashSupported && giniConfiguration.flashToggleEnabled
}
Expand Down Expand Up @@ -133,7 +137,9 @@ final class CameraPreviewViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
camera.start()
startLoadingIndicator()
if !hasInitialized {
startLoadingIndicator()
}
}

override func viewDidLoad() {
Expand Down Expand Up @@ -314,7 +320,6 @@ final class CameraPreviewViewController: UIViewController {
self.notAuthorizedView?.isHidden = true
self.delegate?.cameraDidSetUp(self, camera: self.camera)
}

self.stopLoadingIndicator()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class CorrectQRCodeTextContainer: UIView {
label.textColor = .GiniCapture.light1
label.text = NSLocalizedStringPreferredFormat("ginicapture.QRscanning.correct",
comment: "QR Detected")
label.adjustsFontForContentSizeCategory = true
label.enableScaling()
return label
}()

Expand Down Expand Up @@ -52,6 +52,7 @@ final class IncorrectQRCodeTextContainer: UIView {
label.textColor = .GiniCapture.dark1
label.text = NSLocalizedStringPreferredFormat("ginicapture.QRscanning.incorrect.title",
comment: "Unknown QR")
label.enableScaling()
label.numberOfLines = 0
return label
}()
Expand All @@ -63,6 +64,7 @@ final class IncorrectQRCodeTextContainer: UIView {
label.numberOfLines = 0
label.text = NSLocalizedStringPreferredFormat("ginicapture.QRscanning.incorrect.description",
comment: "No content")
label.enableScaling()
return label
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ final class ImagePickerViewController: UIViewController {
navigationBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
navigationBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
navigationBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
navigationBar.heightAnchor.constraint(equalToConstant: 114)
navigationBar.heightAnchor.constraint(equalToConstant: Constants.navigationBarHeight)
])
view.bringSubviewToFront(navigationBar)
view.layoutSubviews()
Expand Down Expand Up @@ -236,3 +236,9 @@ extension ImagePickerViewController: UICollectionViewDelegateFlowLayout {
}
}
}

private extension ImagePickerViewController {
enum Constants {
static let navigationBarHeight: CGFloat = 114
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ extension GiniScreenAPICoordinator {
// MARK: - ImageAnalysisNoResults screen

extension GiniScreenAPICoordinator {
func createImageAnalysisNoResultsScreen(
type: NoResultScreenViewController.NoResultType
) -> NoResultScreenViewController {
func createImageAnalysisNoResultsScreen(type: NoResultScreenViewController.NoResultType) -> NoResultScreenViewController {
let viewModel: BottomButtonsViewModel
let viewController: NoResultScreenViewController
switch type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ extension GiniScreenAPICoordinator: CameraViewControllerDelegate {
}

func cameraDidAppear(_ viewController: CameraViewController) {
// we should reinitialize camera when it's already initialized, otherwise camera behaves weird
guard viewController.cameraNeedsInitializing || shouldShowOnboarding() else {
viewController.stopLoadingIndicater()
return
}
if shouldShowOnboarding() {
showOnboardingScreen(cameraViewController: viewController, completion: {
viewController.setupCamera()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ open class GiniScreenAPICoordinator: NSObject, Coordinator {
public var giniConfiguration: GiniConfiguration
public var pages: [GiniCapturePage] = []
public weak var visionDelegate: GiniCaptureDelegate?

// Resources
fileprivate(set) lazy var cancelButtonResource =
giniConfiguration.cancelButtonResource ??
Expand Down Expand Up @@ -260,8 +259,8 @@ extension GiniScreenAPICoordinator {
}

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

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 @@
// Copyright © 2024 Gini GmbH. All rights reserved.
//

public let GiniCaptureSDKVersion = "3.9.0"
public let GiniCaptureSDKVersion = "3.10.0"
Loading

0 comments on commit daedec8

Please sign in to comment.