-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from doo/develop
[EPIC-4283]- Xamarin Document SDK 4.2.0
- Loading branch information
Showing
24 changed files
with
1,159 additions
and
415 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ers.Example.Forms/Native.Renderers.Example.Forms.iOS/Delegates/BarcodeScannerDelegates.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Native.Renderers.Example.Forms.iOS.Utils; | ||
using ScanbotSDK.iOS; | ||
using ScanbotSDK.Xamarin.Forms; | ||
|
||
namespace Native.Renderers.Example.Forms.iOS | ||
{ | ||
// Since we cannot directly inherit from SBSDKBarcodeScannerViewControllerDelegate in our ViewRenderer, | ||
// we have created this wrapper class to allow binding to its events through the use of delegates | ||
class BarcodeScannerDelegate : SBSDKBarcodeScannerViewControllerDelegate | ||
{ | ||
internal bool isScanning = true; | ||
public delegate void OnDetectHandler(SBSDKBarcodeScannerResult[] codes); | ||
public OnDetectHandler OnDetect; | ||
|
||
public override void DidDetectBarcodes(SBSDKBarcodeScannerViewController controller, SBSDKBarcodeScannerResult[] codes) | ||
{ | ||
if (controller.BarcodeImageGenerationType == SBSDKBarcodeImageGenerationType.CapturedImage) | ||
{ | ||
isScanning = false; // it will restrict further scans and stop scanning when the image is captured. | ||
} | ||
OnDetect?.Invoke(codes); | ||
} | ||
|
||
public override bool ShouldDetectBarcodes(SBSDKBarcodeScannerViewController controller) | ||
{ | ||
if (!SBSDK.IsLicenseValid) | ||
{ | ||
ViewUtils.ShowAlert("License Expired!", "Ok"); | ||
return false; | ||
} | ||
|
||
return isScanning; | ||
} | ||
} | ||
|
||
internal class BarcodeTrackingOverlayDelegate : SBSDKBarcodeTrackingOverlayControllerDelegate | ||
{ | ||
public delegate void DidTapOnBarcodeAROverlay(SBSDKBarcodeScannerResult barcode); | ||
public DidTapOnBarcodeAROverlay DidTapBarcodeOverlay; | ||
|
||
public override void DidTapOnBarcode(SBSDKBarcodeTrackingOverlayController controller, SBSDKBarcodeScannerResult barcode) | ||
{ | ||
DidTapBarcodeOverlay?.Invoke(barcode); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ers.Example.Forms/Native.Renderers.Example.Forms.iOS/Renderers/BarcodeScannerDelegates.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Foundation; | ||
using ScanbotSDK.iOS; | ||
|
||
namespace Native.Renderers.Example.Forms.iOS.Renderers | ||
{ | ||
// Since we cannot directly inherit from SBSDKBarcodeScannerViewControllerDelegate in our ViewRenderer, | ||
// we have created this wrapper class to allow binding to its events through the use of delegates | ||
class BarcodeScannerDelegate : SBSDKBarcodeScannerViewControllerDelegate | ||
{ | ||
internal bool isScanning = true; | ||
public delegate void OnDetectHandler(SBSDKBarcodeScannerResult[] codes); | ||
public OnDetectHandler OnDetect; | ||
|
||
public override void DidDetectBarcodes(SBSDKBarcodeScannerViewController controller, SBSDKBarcodeScannerResult[] codes) | ||
{ | ||
if (controller.BarcodeImageGenerationType == SBSDKBarcodeImageGenerationType.CapturedImage) | ||
{ | ||
isScanning = false; // it will restrict further scans and stop scanning when the image is captured. | ||
} | ||
OnDetect?.Invoke(codes); | ||
} | ||
|
||
public override bool ShouldDetectBarcodes(SBSDKBarcodeScannerViewController controller) | ||
{ | ||
return isScanning; | ||
} | ||
} | ||
|
||
class BarcodeTrackingOverlayDelegate : SBSDKBarcodeTrackingOverlayControllerDelegate | ||
{ | ||
public delegate void DidTapOnBarcodeAROverlay(SBSDKBarcodeScannerResult barcode); | ||
public DidTapOnBarcodeAROverlay DidTapBarcodeOverlay; | ||
|
||
[Export("barcodeTrackingOverlay:didTapOnBarcode:")] | ||
public override void DidTapOnBarcode(SBSDKBarcodeTrackingOverlayController controller, SBSDKBarcodeScannerResult barcode) | ||
{ | ||
DidTapBarcodeOverlay?.Invoke(barcode); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Native.Renderers.Example.Forms/Native.Renderers.Example.Forms.iOS/Renderers/Extensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using ScanbotSDK.iOS; | ||
using ScanbotSDK.Xamarin.Forms; | ||
|
||
namespace Native.Renderers.Example.Forms.iOS.Renderers | ||
{ | ||
public static class Extension | ||
{ | ||
public static SBSDKBarcodeOverlayFormat ToNative(this OverlayFormat overlayTextFormat) | ||
{ | ||
switch (overlayTextFormat) | ||
{ | ||
case OverlayFormat.None: | ||
return SBSDKBarcodeOverlayFormat.None; | ||
case OverlayFormat.Code: | ||
return SBSDKBarcodeOverlayFormat.Code; | ||
default: | ||
return SBSDKBarcodeOverlayFormat.CodeAndType; | ||
} | ||
} | ||
|
||
public static SBSDKBarcodeImageGenerationType ToNative(this BarcodeImageGenerationType imageGenerationType) | ||
{ | ||
switch (imageGenerationType) | ||
{ | ||
case BarcodeImageGenerationType.None: | ||
return SBSDKBarcodeImageGenerationType.None; | ||
case BarcodeImageGenerationType.CapturedImage: | ||
return SBSDKBarcodeImageGenerationType.CapturedImage; | ||
case BarcodeImageGenerationType.FromVideoFrame: | ||
return SBSDKBarcodeImageGenerationType.FromVideoFrame; | ||
default: | ||
return SBSDKBarcodeImageGenerationType.None; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.