ios demo version
This commit is contained in:
@@ -6,24 +6,55 @@
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
|
||||
[GeneratedPluginRegistrant registerWithRegistry:self];
|
||||
|
||||
|
||||
FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
|
||||
|
||||
FlutterMethodChannel* scannerChannel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"com.yourcompany.checker/scanner"
|
||||
FlutterMethodChannel* platformChannel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"com.dinect.checker/instance_id"
|
||||
binaryMessenger:controller];
|
||||
|
||||
[scannerChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
||||
ScannerViewController *modalViewController = [ScannerViewController new];
|
||||
[controller presentViewController:modalViewController animated:YES completion:nil]; }];
|
||||
|
||||
|
||||
__weak FlutterMethodChannel* weekPlatformChannel = platformChannel;
|
||||
|
||||
[platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
||||
NSLog(@"%@", call.method);
|
||||
|
||||
// NSDictionary *dict = [[NSProcessInfo processInfo] environment];
|
||||
// NSLog(@"%@", dict);
|
||||
|
||||
if ([@"getLocale" isEqualToString:call.method]) {
|
||||
result(@"ru");
|
||||
} else if ([@"getFlavor" isEqualToString:call.method]) {
|
||||
result(@"autobonus");
|
||||
} else if ([@"getCurrency" isEqualToString:call.method]) {
|
||||
result(@643);
|
||||
} else if ([@"startScanner" isEqualToString:call.method]) {
|
||||
ScannerViewController *modalViewController = [ScannerViewController new];
|
||||
modalViewController.platformChannel = weekPlatformChannel;
|
||||
[controller presentViewController:modalViewController animated:YES completion:nil];
|
||||
// [weekPlatformChannel invokeMethod:@"purchase" arguments:@[@"semyon", @"49492872388755"]];
|
||||
} else if ([@"isOnline" isEqualToString:call.method]) {
|
||||
result(@YES);
|
||||
} else if ([@"getSupportPhone" isEqualToString:call.method]) {
|
||||
result(@"8 800 555 35 35");
|
||||
} else if ([@"getSupportUrl" isEqualToString:call.method]) {
|
||||
result(@"http://yandex.ru/");
|
||||
} else if ([@"getEndpoint" isEqualToString:call.method]) {
|
||||
result(@"https://pos-api-int.dinect.com/20130701/");
|
||||
} else if ([@"getAppToken" isEqualToString:call.method]) {
|
||||
result(@"9fec83cdca38c357e6b65dbb17514cdd36bf2a08");
|
||||
} else if ([@"getAppTitle" isEqualToString:call.method]) {
|
||||
result(@"Autobonus");
|
||||
} else if ([@"showBonus" isEqualToString:call.method]) {
|
||||
result(@YES);
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
}
|
||||
|
||||
- (void) showScanner {
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -107,10 +107,15 @@
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-83.5x83.5@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"size" : "1024x1024",
|
||||
"scale" : "1x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
<?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">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" 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="12089"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Flutter
|
||||
|
||||
extension ZBarSymbolSet: Sequence {
|
||||
public typealias Element = ZBarSymbol
|
||||
public typealias Iterator = NSFastEnumerationIterator
|
||||
//public typealias Element = ZBarSymbol
|
||||
//public typealias Iterator = NSFastEnumerationIterator
|
||||
|
||||
public func makeIterator() -> NSFastEnumerationIterator {
|
||||
return NSFastEnumerationIterator(self)
|
||||
@@ -18,7 +19,8 @@ extension ZBarSymbolSet: Sequence {
|
||||
}
|
||||
|
||||
@objc class ScannerViewController: UIViewController, ZBarReaderDelegate {
|
||||
|
||||
var platformChannel: FlutterMethodChannel?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
}
|
||||
@@ -28,20 +30,35 @@ extension ZBarSymbolSet: Sequence {
|
||||
let readerViewController = ZBarReaderViewController()
|
||||
readerViewController.readerDelegate = self
|
||||
readerViewController.readerView.zoom = 1.0
|
||||
readerViewController.showsZBarControls = false
|
||||
readerViewController.showsZBarControls = true
|
||||
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()
|
||||
|
||||
if let platformChannel = self.platformChannel {
|
||||
self.dismiss(animated: true, completion: {
|
||||
self.presentingViewController?.dismiss(animated: true, completion: {
|
||||
platformChannel.invokeMethod("findUserAndPurchase", arguments: [data], result: { (result: Any?) in
|
||||
print("\(result ?? "")")
|
||||
})
|
||||
})
|
||||
})
|
||||
// let result = platformChannel.invokeMethod("getUserByCode", arguments: [data], handleResult(result: FlutterResult))
|
||||
// print(result);
|
||||
}
|
||||
|
||||
// let toast = UIAlertView()
|
||||
// toast.message = data
|
||||
// toast.show()
|
||||
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user