| | |
| | | public static class QRCode |
| | | { |
| | | static ZXing.Mobile.MobileBarcodeScanner scanner; |
| | | public static async System.Threading.Tasks.Task ScanQRcode(Action<string> action, string topText = "", string bottomText = "", string cancel = "Cancel") |
| | | public static async System.Threading.Tasks.Task ScanQRcode(Action<string> action, string cancel = "取消", string flashText = "闪光灯", string titleText = "二维码扫描") |
| | | { |
| | | if (scanner == null) |
| | | { |
| | | scanner = new ZXing.Mobile.MobileBarcodeScanner(Home.IOS.AppDelegate.rootViewController) { FlashButtonText = "", TopText = topText, BottomText = bottomText, CancelButtonText = cancel }; |
| | | var mZXingOverlayView = new Home.IOS.ZXingOverlayView(cancel, flashText, titleText); |
| | | scanner = new ZXing.Mobile.MobileBarcodeScanner(Home.IOS.AppDelegate.rootViewController) { FlashButtonText = flashText, TopText = titleText, BottomText = "", CancelButtonText = cancel }; |
| | | scanner.UseCustomOverlay = true; |
| | | |
| | | scanner.CustomOverlay = mZXingOverlayView; |
| | | var bOn = false; |
| | | mZXingOverlayView.OnCancel += () => { |
| | | |
| | | scanner?.Cancel(); |
| | | }; |
| | | |
| | | mZXingOverlayView.OnTorch += () => |
| | | { |
| | | bOn = !bOn; |
| | | scanner?.Torch(bOn); |
| | | }; |
| | | |
| | | } |
| | | |
| | | var result = await scanner.Scan(); |