Skip to content

Commit

Permalink
User error view (#818)
Browse files Browse the repository at this point in the history
Updates DocumentCaptureView to use an ErrorView for its error state instead of a placeholder label
  • Loading branch information
mludowise-stripe authored Mar 1, 2022
1 parent f779291 commit b5939fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,20 @@ final class DocumentCaptureViewController: IdentityFlowViewController {
instructionalText: DocumentCaptureViewController.scannedInstructionalText
))
case .noCameraAccess:
// TODO(IDPROD-2747): Use `noCameraAccessErrorTitleText` for title
return .error(noCameraAccessErrorBodyText)
return .error(.init(
titleText: DocumentCaptureViewController.noCameraAccessErrorTitleText,
bodyText: noCameraAccessErrorBodyText
))
case .cameraError:
// TODO(IDPROD-2747): Use `cameraUnavailableErrorTitleText` for title
return .error(DocumentCaptureViewController.cameraUnavailableErrorBodyText)
return .error(.init(
titleText: DocumentCaptureViewController.cameraUnavailableErrorTitleText,
bodyText: DocumentCaptureViewController.cameraUnavailableErrorBodyText
))
case .timeout:
// TODO(IDPROD-2747): Use `timeoutErrorTitleText` for title
return .error(timeoutErrorBodyText)
return .error(.init(
titleText: DocumentCaptureViewController.timeoutErrorTitleText,
bodyText: timeoutErrorBodyText
))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,16 @@ final class DocumentCaptureView: UIView {

enum ViewModel {
case scan(InstructionalCameraScanningView.ViewModel)
case error(String)
case error(ErrorView.ViewModel)
}

private let scanningView = InstructionalCameraScanningView()

// TODO(mludowise|IDPROD-2747): Use error view instead of label
private let errorLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.textAlignment = .center
return label
}()
private let errorView = ErrorView()

private lazy var stackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.alignment = .fill
stackView.distribution = .fill
return stackView
Expand Down Expand Up @@ -56,11 +51,11 @@ final class DocumentCaptureView: UIView {
case .scan(let scanningViewModel):
scanningView.configure(with: scanningViewModel)
scanningView.isHidden = false
errorLabel.isHidden = true
case .error(let message):
errorLabel.text = message
errorView.isHidden = true
case .error(let errorViewModel):
errorView.configure(with: errorViewModel)
scanningView.isHidden = true
errorLabel.isHidden = false
errorView.isHidden = false
}
}
}
Expand All @@ -71,6 +66,6 @@ private extension DocumentCaptureView {
func installViews() {
addAndPinSubview(stackView)
stackView.addArrangedSubview(scanningView)
stackView.addArrangedSubview(errorLabel)
stackView.addArrangedSubview(errorView)
}
}

0 comments on commit b5939fc

Please sign in to comment.