Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pp 391 add no results screen events #479

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class ErrorScreenViewController: UIViewController {

private func configureCustomTopNavigationBar() {
let cancelButton = GiniBarButton(ofType: .cancel)
cancelButton.addAction(viewModel, #selector(viewModel.didPressCancell))
cancelButton.addAction(viewModel, #selector(viewModel.didPressCancel))

if giniConfiguration.bottomNavigationBarEnabled {
navigationItem.rightBarButtonItem = cancelButton.barButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
import Foundation

final class BottomButtonsViewModel {
let retakePressed: (() -> Void)?
let enterManuallyPressed: (() -> Void)?
let cancelPressed: (() -> Void)

init(
retakeBlock: (() -> Void)? = nil,
manuallyPressed: (() -> Void)? = nil,
cancelPressed: @escaping(() -> Void)) {
private let retakePressed: (() -> Void)?
private let enterManuallyPressed: (() -> Void)?
private let cancelPressed: (() -> Void)

init(retakeBlock: (() -> Void)? = nil,
manuallyPressed: (() -> Void)? = nil,
cancelPressed: @escaping(() -> Void)) {
self.retakePressed = retakeBlock
self.enterManuallyPressed = manuallyPressed
self.cancelPressed = cancelPressed
Expand All @@ -32,7 +31,7 @@ final class BottomButtonsViewModel {
enterManuallyPressed?()
}

@objc func didPressCancell() {
@objc func didPressCancel() {
errorOccurred = false
cancelPressed()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ final class NoResultScreenViewController: UIViewController {
return text
}
}

var analyticsValue: String {
switch self {
case .pdf:
return "pdf"
case .image:
return "image"
case .qrCode:
return "qrCode"
default:
return "unknown"
}
}
}

lazy var tableView: UITableView = {
Expand Down Expand Up @@ -83,11 +96,9 @@ final class NoResultScreenViewController: UIViewController {
}).count
}

public init(
giniConfiguration: GiniConfiguration,
type: NoResultType,
viewModel: BottomButtonsViewModel
) {
public init(giniConfiguration: GiniConfiguration,
type: NoResultType,
viewModel: BottomButtonsViewModel) {
self.giniConfiguration = giniConfiguration
self.type = type
switch type {
Expand All @@ -113,6 +124,11 @@ final class NoResultScreenViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.setupView()

let eventProperties = [AnalyticsProperty(key: .noResultType,
value: type.analyticsValue)]
AnalyticsManager.trackScreenShown(screenName: .noResults,
properties: eventProperties)
}

override func viewDidLayoutSubviews() {
Expand Down Expand Up @@ -151,31 +167,26 @@ final class NoResultScreenViewController: UIViewController {
}

private func configureMainView() {
title = NSLocalizedStringPreferredFormat(
"ginicapture.noresult.title",
comment: "No result screen title")
header.iconImageView.accessibilityLabel = NSLocalizedStringPreferredFormat(
"ginicapture.noresult.title",
comment: "No result screen title")
title = NSLocalizedStringPreferredFormat("ginicapture.noresult.title",
comment: "No result screen title")
header.iconImageView.accessibilityLabel = NSLocalizedStringPreferredFormat("ginicapture.noresult.title",
comment: "No result screen title")
header.headerLabel.text = type.description
header.headerLabel.font = giniConfiguration.textStyleFonts[.subheadline]
header.headerLabel.textColor = GiniColor(
light: UIColor.GiniCapture.dark1,
dark: UIColor.GiniCapture.light1
).uiColor()
view.backgroundColor = GiniColor(light: UIColor.GiniCapture.light2, dark: UIColor.GiniCapture.dark2).uiColor()
header.headerLabel.textColor = GiniColor(light: UIColor.GiniCapture.dark1,
dark: UIColor.GiniCapture.light1).uiColor()
view.backgroundColor = GiniColor(light: UIColor.GiniCapture.light2,
dark: UIColor.GiniCapture.dark2).uiColor()
view.addSubview(header)
view.addSubview(tableView)
view.addSubview(buttonsView)
header.backgroundColor = GiniColor(
light: UIColor.GiniCapture.error4,
dark: UIColor.GiniCapture.error1
).uiColor()
header.backgroundColor = GiniColor(light: UIColor.GiniCapture.error4,
dark: UIColor.GiniCapture.error1).uiColor()
}

private func configureCustomTopNavigationBar() {
let cancelButton = GiniBarButton(ofType: .cancel)
cancelButton.addAction(viewModel, #selector(viewModel.didPressCancell))
cancelButton.addAction(self, #selector(didPressCancel))

if giniConfiguration.bottomNavigationBarEnabled {
navigationItem.rightBarButtonItem = cancelButton.barButton
Expand Down Expand Up @@ -240,14 +251,27 @@ final class NoResultScreenViewController: UIViewController {
}

private func configureButtons() {
buttonsView.enterButton.addTarget(
viewModel,
action: #selector(viewModel.didPressEnterManually),
for: .touchUpInside)
buttonsView.retakeButton.addTarget(
viewModel,
action: #selector(viewModel.didPressRetake),
for: .touchUpInside)
buttonsView.enterButton.addTarget(self,
action: #selector(didPressEnterManually),
for: .touchUpInside)
buttonsView.retakeButton.addTarget(self,
action: #selector(didPressRetake),
for: .touchUpInside)
}

@objc func didPressEnterManually() {
AnalyticsManager.track(event: .enterManuallyTapped, screenName: .noResults)
viewModel.didPressEnterManually()
}

@objc func didPressRetake() {
AnalyticsManager.track(event: .retakeImagesTapped, screenName: .noResults)
viewModel.didPressRetake()
}

@objc func didPressCancel() {
AnalyticsManager.track(event: .closeTapped, screenName: .noResults)
viewModel.didPressCancel()
}

private func configureHeaderContraints() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extension GiniScreenAPICoordinator {

extension GiniScreenAPICoordinator: AnalysisDelegate {

public func displayError(errorType: ErrorType,animated: Bool) {
public func displayError(errorType: ErrorType, animated: Bool) {
let viewModel: BottomButtonsViewModel
switch pages.type {
case .image:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ enum AnalyticsEvent: String {
case deletePagesTapped = "delete_pages_tapped"
case addPagesTapped = "add_pages_tapped"
case swipePages = "swipe_pages"

// MARK: - No Results and Error
case enterManuallyTapped = "enter_manually_tapped"
case retakeImagesTapped = "retake_images_tapped"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ enum AnalyticsPropertyKey: String {
case ibanDetectionLayerVisible = "iban_detection_layer_visible"

case errorMessage = "error_message"
case noResultType = "no_result_type"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ enum AnalyticsScreen: String {
case camera
case review
case analysis
case noResults = "no_results"
}
Loading