Redth / ZXing.Net.Mobile

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen
MIT License
1.07k stars 701 forks source link

Add HasScannerSetUpProperty to ZXing.Net.Mobile.Forms.ZXingScannerView #879

Open mourke opened 4 years ago

mourke commented 4 years ago

It would be great if you could add a property to the Xamarin forms ZXingScannerView allowing us to know when the scanner has been set up.

You'd simply have to add these properties inside the ZXing.Net.Mobile/ZXing.Net.Mobile.Forms/ZXingScannerView.shared.cs file:

public static readonly BindableProperty HasScannerSetUpProperty =
        BindableProperty.Create(nameof(HasScannerSetUp), typeof(bool), typeof(ZXingScannerView), false);

public bool HasScannerSetUp => (bool)GetValue(HasScannerSetUpProperty);

And add something like this in the OnElementChanged method of the ZXing.Net.Mobile/ZXing.Net.Mobile.Forms/ZXingScannerViewRenderer.ios.cs and ZXing.Net.Mobile/ZXing.Net.Mobile.Forms/ZXingScannerViewRenderer.android.cs` files

zxingView.OnScannerSetupComplete += () => {
    Element.SetValue(ScannerView.HasScannerSetUpProperty, true);
};

Thanks for all your hard work thus far! :)

knocte commented 4 years ago

@mourke hey why do you need this?

mourke commented 4 years ago

To know when the camera has been setup to update custom UI