Запускается ZBAR сканнер в iOS версии приложения
This commit is contained in:
@@ -2,5 +2,4 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface AppDelegate : FlutterAppDelegate
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
#include "AppDelegate.h"
|
||||
#include "GeneratedPluginRegistrant.h"
|
||||
#import "Runner-Swift.h"
|
||||
#import "ZBarSDK.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
[GeneratedPluginRegistrant registerWithRegistry:self];
|
||||
// Override point for customization after application launch.
|
||||
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
|
||||
[GeneratedPluginRegistrant registerWithRegistry:self];
|
||||
|
||||
FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
|
||||
|
||||
FlutterMethodChannel* scannerChannel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"com.yourcompany.checker/scanner"
|
||||
binaryMessenger:controller];
|
||||
|
||||
[scannerChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
||||
ScannerViewController *modalViewController = [ScannerViewController new];
|
||||
[controller presentViewController:modalViewController animated:YES completion:nil]; }];
|
||||
|
||||
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
}
|
||||
|
||||
- (void) showScanner {
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<device id="retina5_5" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Flutter View Controller-->
|
||||
@@ -14,9 +18,9 @@
|
||||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Просто потому что</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
|
||||
6
ios/Runner/Runner-Bridging-Header.h
Normal file
6
ios/Runner/Runner-Bridging-Header.h
Normal file
@@ -0,0 +1,6 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#import "ZBarSDK.h"
|
||||
#import "ZBarImageScanner.h"
|
||||
59
ios/Runner/ScannerViewController.swift
Normal file
59
ios/Runner/ScannerViewController.swift
Normal file
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// ScannerViewController.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by Ivan Murashov on 13/07/2017.
|
||||
// Copyright © 2017 The Chromium Authors. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
extension ZBarSymbolSet: Sequence {
|
||||
public typealias Element = ZBarSymbol
|
||||
public typealias Iterator = NSFastEnumerationIterator
|
||||
|
||||
public func makeIterator() -> NSFastEnumerationIterator {
|
||||
return NSFastEnumerationIterator(self)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Реализовать окно сканнера в этом контроллере, вместо вызова ZBarReaderViewController
|
||||
|
||||
@objc class ScannerViewController: UIViewController, ZBarReaderDelegate {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
let readerViewController = ZBarReaderViewController()
|
||||
readerViewController.readerDelegate = self
|
||||
readerViewController.readerView.zoom = 1.0
|
||||
readerViewController.showsZBarControls = false
|
||||
self.present(readerViewController, animated: true)
|
||||
}
|
||||
|
||||
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
|
||||
guard let symbols = info[ZBarReaderControllerResults] as? ZBarSymbolSet else { return }
|
||||
|
||||
for symbol in symbols {
|
||||
|
||||
if let symbol = symbol as? ZBarSymbol, let data = symbol.data {
|
||||
|
||||
let toast = UIAlertView()
|
||||
toast.message = data
|
||||
toast.show()
|
||||
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
}
|
||||
navigationController?.popViewController(animated: true)
|
||||
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
super.didReceiveMemoryWarning()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user