| | |
| | | set; |
| | | } |
| | | |
| | | internal static UINavigationController rootViewController; |
| | | |
| | | public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) |
| | | { |
| | | base.FinishedLaunching(application, launchOptions); |
| | | //base.FinishedLaunching(application, launchOptions); |
| | | Shared.Application.FontSize = 12; |
| | | Window = new UIWindow(UIScreen.MainScreen.Bounds); |
| | | var root = new UINavigationController(new MainViewController()) { NavigationBarHidden = true }; |
| | | Window.RootViewController = root; |
| | | rootViewController = new UINavigationController(new MainViewController()) { NavigationBarHidden = true }; |
| | | Window.RootViewController = rootViewController; |
| | | Window.MakeKeyAndVisible(); |
| | | |
| | | DeviceTokenAction += (deviceToken) => |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | namespace Shared |
| | | { |
| | | 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") |
| | | { |
| | | if (scanner == null) |
| | | { |
| | | scanner = new ZXing.Mobile.MobileBarcodeScanner(GateWay.Ios.AppDelegate.rootViewController) { FlashButtonText = "", TopText = topText, BottomText = bottomText, CancelButtonText = cancel }; |
| | | } |
| | | |
| | | var result = await scanner.Scan(); |
| | | |
| | | if (result != null) |
| | | action?.Invoke(result.Text); |
| | | else |
| | | action?.Invoke(null); |
| | | } |
| | | |
| | | public static byte[] BytesFromText(string text, int width = 300, int height = 300) |
| | | { |
| | | var barcodeWriter = new ZXing.Mobile.BarcodeWriter |
| | | { |
| | | Format = ZXing.BarcodeFormat.QR_CODE, |
| | | Options = new ZXing.Common.EncodingOptions |
| | | { |
| | | Width = width, |
| | | Height = height, |
| | | Margin = 10 |
| | | } |
| | | }; |
| | | |
| | | barcodeWriter.Renderer = new ZXing.Mobile.BitmapRenderer(); |
| | | var uiImage = barcodeWriter.Write(text); |
| | | var data = uiImage.AsJPEG(); |
| | | |
| | | var resultBytes = new byte[data.Length]; |
| | | System.Runtime.InteropServices.Marshal.Copy(data.Bytes, resultBytes, 0, resultBytes.Length); |
| | | |
| | | return resultBytes; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |