-
Notifications
You must be signed in to change notification settings - Fork 68
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
Unable to override ScanBaseViewController #74
Comments
Hi @PiotrPawlus can you explain what you're trying to do? Most common uses of CardScan don't need to create their own ViewController and even those that choose to do so don't need to implement the |
I need to set a custom color for corner view, custom torch button's image and also provide localized strings when the user hasn't granted access the camera. |
These are all pretty reasonable UI adjustments. If we were to put options to adjust all of these in our main |
Yes, sure. I also looked through requirements and we also need to handle no camera granted access by using our internal components. |
I was also trying to subclass // Child classes should override these three functions
@objc open func onScannedCard(number: String, expiryYear: String?, expiryMonth: String?, scannedImage: UIImage?) { }
@objc open func showCardNumber(_ number: String, expiry: String?) { }
@objc open func onCameraPermissionDenied(showedPrompt: Bool) { } Plus adding a @objc public class CustomViewController: ScanBaseViewController {
public weak var scanDelegate: ScanDelegate?
var blurView: BlurView!
var previewView: PreviewView!
var cornerView: CornerView!
var regionOfInterestLabel: UILabel!
override public func viewDidLoad() {
super.viewDidLoad()
previewView = PreviewView()
previewView.frame = CGRect.init(x: 30.0, y: 288.0, width:700.0, height: 450.0)
view.addSubview(previewView)
regionOfInterestLabel = UILabel()
regionOfInterestLabel.frame = CGRect.init(x: 30.0, y: 200.0, width:700.0, height: 450.0)
view.addSubview(regionOfInterestLabel)
blurView = BlurView()
blurView.frame = CGRect.init(x: 0.0, y: 0.0, width: view.bounds.size.width, height: view.bounds.size.height)
view.addSubview(blurView)
cornerView = CornerView()
cornerView.frame = CGRect.init(x: 30.0, y: 200.0, width:700.0, height: 450.0)//CGRect.init(x: 0.0, y: 0.0, width: (view.bounds.size.width / 2), height: (view.bounds.size.height / 3))
cornerView.center = view.center
view.addSubview(cornerView)
self.cornerView.layer.borderColor = UIColor.green.cgColor
setupOnViewDidLoad(regionOfInterestLabel: regionOfInterestLabel, blurView: blurView, previewView: previewView, cornerView: cornerView, debugImageView: nil)
self.startCameraPreview()
}
override public func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
cornerView.backgroundColor = .cyan
cornerView.layer.borderColor = UIColor.red.cgColor
regionOfInterestLabel.layer.borderColor = UIColor.red.cgColor
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
public override func onScannedCard(number: String, expiryYear: String?, expiryMonth: String?, scannedImage: UIImage?) {
dump(number)
let card = CreditCard(number: number)
card.expiryMonth = expiryMonth
card.expiryYear = expiryYear
card.image = scannedImage
dump(card.description)
}
} |
Here's the first PR: #77 |
And here's the second: #78 We'll do a deploy later today to bump the Cocoapod version, but I'm going to close this issue for now. Please re-open it if you have any changes you'd like for us to make. |
Both methods of protocol ScanEvents are marked as
public
in ScanBaseViewController. Due to this fact, we're not able to override these methods.Is the possibility to change these methods to open?
The text was updated successfully, but these errors were encountered: