ios added phone/card switch
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,9 +1,9 @@
|
||||
// This is a generated file; do not edit or check into version control.
|
||||
FLUTTER_ROOT=/Users/dinect/projects/flutter
|
||||
FLUTTER_APPLICATION_PATH=/Users/dinect/projects/checker
|
||||
FLUTTER_ROOT=/Users/ntrlab/flutter
|
||||
FLUTTER_APPLICATION_PATH=/Users/ntrlab/semyon/apps/dinect
|
||||
FLUTTER_TARGET=lib/main.dart
|
||||
FLUTTER_BUILD_MODE=release
|
||||
FLUTTER_BUILD_MODE=debug
|
||||
FLUTTER_BUILD_DIR=build
|
||||
SYMROOT=${SOURCE_ROOT}/../build/ios
|
||||
FLUTTER_FRAMEWORK_DIR=/Users/dinect/projects/flutter/bin/cache/artifacts/engine/ios-release
|
||||
FLUTTER_FRAMEWORK_DIR=/Users/ntrlab/flutter/bin/cache/artifacts/engine/ios
|
||||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
|
||||
Binary file not shown.
@@ -12,20 +12,20 @@ PODS:
|
||||
- FMDB
|
||||
|
||||
DEPENDENCIES:
|
||||
- Flutter (from `/Users/dinect/projects/flutter/bin/cache/artifacts/engine/ios-release`)
|
||||
- image_picker (from `/Users/dinect/.pub-cache/hosted/pub.dartlang.org/image_picker-0.1.3/ios`)
|
||||
- path_provider (from `/Users/dinect/.pub-cache/hosted/pub.dartlang.org/path_provider-0.2.1+1/ios`)
|
||||
- sqflite (from `/Users/dinect/.pub-cache/hosted/pub.dartlang.org/sqflite-0.2.4/ios`)
|
||||
- Flutter (from `/Users/ntrlab/flutter/bin/cache/artifacts/engine/ios`)
|
||||
- image_picker (from `/Users/ntrlab/.pub-cache/hosted/pub.dartlang.org/image_picker-0.1.3/ios`)
|
||||
- path_provider (from `/Users/ntrlab/.pub-cache/hosted/pub.dartlang.org/path_provider-0.2.1+1/ios`)
|
||||
- sqflite (from `/Users/ntrlab/.pub-cache/hosted/pub.dartlang.org/sqflite-0.2.4/ios`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Flutter:
|
||||
:path: "/Users/dinect/projects/flutter/bin/cache/artifacts/engine/ios-release"
|
||||
:path: /Users/ntrlab/flutter/bin/cache/artifacts/engine/ios
|
||||
image_picker:
|
||||
:path: "/Users/dinect/.pub-cache/hosted/pub.dartlang.org/image_picker-0.1.3/ios"
|
||||
:path: /Users/ntrlab/.pub-cache/hosted/pub.dartlang.org/image_picker-0.1.3/ios
|
||||
path_provider:
|
||||
:path: "/Users/dinect/.pub-cache/hosted/pub.dartlang.org/path_provider-0.2.1+1/ios"
|
||||
:path: /Users/ntrlab/.pub-cache/hosted/pub.dartlang.org/path_provider-0.2.1+1/ios
|
||||
sqflite:
|
||||
:path: "/Users/dinect/.pub-cache/hosted/pub.dartlang.org/sqflite-0.2.4/ios"
|
||||
:path: /Users/ntrlab/.pub-cache/hosted/pub.dartlang.org/sqflite-0.2.4/ios
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Flutter: d674e78c937094a75ac71dd77e921e840bea3dbf
|
||||
@@ -36,4 +36,4 @@ SPEC CHECKSUMS:
|
||||
|
||||
PODFILE CHECKSUM: 351e02e34b831289961ec3558a535cbd2c4965d2
|
||||
|
||||
COCOAPODS: 1.1.0.rc.2
|
||||
COCOAPODS: 1.2.1
|
||||
|
||||
@@ -80,8 +80,6 @@
|
||||
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
AC45BF491F9E3C56009713E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
AC45BF4A1F9E3C56009713E2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
AC45BF661F9E3F97009713E2 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
AC45BF911F9E408E009713E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = /Users/ntrlab/semyon/apps/checker/ios/Runner/Info.plist; sourceTree = "<absolute>"; };
|
||||
AC73A4241F9F7F920026EBA4 /* Dinect.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Dinect.plist; path = /Users/ntrlab/semyon/apps/checker/ios/Runner/Dinect.plist; sourceTree = "<absolute>"; };
|
||||
@@ -171,7 +169,6 @@
|
||||
ACE103BB1F8FCCA500D17794 /* ZBarSDK */,
|
||||
9740EEB11CF90186004384FC /* Flutter */,
|
||||
97C146F01CF9000F007C117D /* Runner */,
|
||||
AC45BF3A1F9E3C55009713E2 /* develop */,
|
||||
97C146EF1CF9000F007C117D /* Products */,
|
||||
BBA9BB001F1786510053B6EA /* Frameworks */,
|
||||
578B8FA7D56ACA2E56C02128 /* Pods */,
|
||||
@@ -214,15 +211,6 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
AC45BF3A1F9E3C55009713E2 /* develop */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AC45BF491F9E3C56009713E2 /* Info.plist */,
|
||||
AC45BF4A1F9E3C56009713E2 /* main.m */,
|
||||
);
|
||||
path = develop;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
ACE103BB1F8FCCA500D17794 /* ZBarSDK */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -321,7 +309,7 @@
|
||||
ORGANIZATIONNAME = "The Chromium Authors";
|
||||
TargetAttributes = {
|
||||
ACE861271F9F745B006FEF38 = {
|
||||
DevelopmentTeam = 926V94K5Q8;
|
||||
DevelopmentTeam = XU4S344HDL;
|
||||
SystemCapabilities = {
|
||||
com.apple.Push = {
|
||||
enabled = 1;
|
||||
@@ -381,7 +369,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
ACE861291F9F745B006FEF38 /* Run Script */ = {
|
||||
@@ -587,7 +575,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = 926V94K5Q8;
|
||||
DEVELOPMENT_TEAM = XU4S344HDL;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -626,7 +614,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = 926V94K5Q8;
|
||||
DEVELOPMENT_TEAM = XU4S344HDL;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
||||
Binary file not shown.
@@ -10,7 +10,7 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Runner/AppDelegate.m"
|
||||
timestampString = "530550700.366503"
|
||||
timestampString = "533131021.955531"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "78"
|
||||
@@ -26,7 +26,7 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Runner/AppDelegate.m"
|
||||
timestampString = "530550700.366692"
|
||||
timestampString = "533131021.956561"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "10"
|
||||
@@ -42,7 +42,7 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Runner/AppDelegate.m"
|
||||
timestampString = "530550700.366785"
|
||||
timestampString = "533131021.957304"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "13"
|
||||
@@ -58,7 +58,7 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Runner/AppDelegate.m"
|
||||
timestampString = "530550700.366865"
|
||||
timestampString = "533131021.957849"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "15"
|
||||
@@ -74,7 +74,7 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Runner/AppDelegate.m"
|
||||
timestampString = "530550700.366933"
|
||||
timestampString = "533131021.958377"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "9"
|
||||
@@ -90,11 +90,11 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Runner/ScannerViewController.swift"
|
||||
timestampString = "530550700.367155"
|
||||
timestampString = "533136853.177463"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "50"
|
||||
endingLineNumber = "50"
|
||||
startingLineNumber = "88"
|
||||
endingLineNumber = "88"
|
||||
landmarkName = "viewDidLoad()"
|
||||
landmarkType = "7">
|
||||
<Locations>
|
||||
@@ -138,11 +138,11 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Runner/ScannerViewController.swift"
|
||||
timestampString = "530550700.368435"
|
||||
timestampString = "533136853.177572"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "51"
|
||||
endingLineNumber = "51"
|
||||
startingLineNumber = "89"
|
||||
endingLineNumber = "89"
|
||||
landmarkName = "viewDidLoad()"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
@"appTitle" : @"Dinect",
|
||||
@"showBonus" : @YES,
|
||||
},
|
||||
@"com.dinect.develop" : @{
|
||||
@"com.dinect.develop-iOS" : @{
|
||||
@"locale" : @"ru",
|
||||
@"flavor" : @"autobonus",
|
||||
@"currency" : @643,
|
||||
|
||||
6
ios/Runner/Assets.xcassets/Contents.json
Normal file
6
ios/Runner/Assets.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
23
ios/Runner/Assets.xcassets/card.imageset/Contents.json
vendored
Normal file
23
ios/Runner/Assets.xcassets/card.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Icon-20.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Icon-40.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Icon-60.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
ios/Runner/Assets.xcassets/card.imageset/Icon-20.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/card.imageset/Icon-20.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 326 B |
BIN
ios/Runner/Assets.xcassets/card.imageset/Icon-40.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/card.imageset/Icon-40.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 464 B |
BIN
ios/Runner/Assets.xcassets/card.imageset/Icon-60.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/card.imageset/Icon-60.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 598 B |
23
ios/Runner/Assets.xcassets/phone.imageset/Contents.json
vendored
Normal file
23
ios/Runner/Assets.xcassets/phone.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Icon-20.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Icon-40.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Icon-60.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
ios/Runner/Assets.xcassets/phone.imageset/Icon-20.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/phone.imageset/Icon-20.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 484 B |
BIN
ios/Runner/Assets.xcassets/phone.imageset/Icon-40.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/phone.imageset/Icon-40.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 944 B |
BIN
ios/Runner/Assets.xcassets/phone.imageset/Icon-60.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/phone.imageset/Icon-60.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -19,9 +19,47 @@ extension ZBarSymbolSet: Sequence {
|
||||
}
|
||||
|
||||
@objc class ScannerViewController: UIViewController, ZBarReaderDelegate, UITextFieldDelegate {
|
||||
|
||||
enum ButtonState {
|
||||
case card
|
||||
case phone
|
||||
|
||||
var icon: UIImage {
|
||||
|
||||
switch self {
|
||||
case .card: return UIImage(named: "card")!
|
||||
case .phone: return UIImage(named: "phone")!
|
||||
}
|
||||
}
|
||||
|
||||
var inputText: String {
|
||||
switch self {
|
||||
case .card: return "Enter the barcode manualy"
|
||||
case .phone: return "Enter the phone manualy"
|
||||
}
|
||||
}
|
||||
|
||||
var errorText: String {
|
||||
switch self {
|
||||
case .card: return "User with card number %@ not found"
|
||||
case .phone: return "User with phone number %@ not found"
|
||||
}
|
||||
}
|
||||
|
||||
var searchType: String {
|
||||
switch self {
|
||||
case .card: return "card"
|
||||
case .phone: return "phone"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var buttonState: ButtonState = .card
|
||||
|
||||
var platformChannel: FlutterMethodChannel?
|
||||
let readerViewController = ZBarReaderViewController()
|
||||
|
||||
|
||||
//Вьюшка для верхнего меню
|
||||
let topView = UIView()
|
||||
|
||||
@@ -49,12 +87,15 @@ extension ZBarSymbolSet: Sequence {
|
||||
topView.addSubview(settingButton)
|
||||
|
||||
textField.delegate = self
|
||||
textField.keyboardType = .numberPad
|
||||
//textField.keyboardType = .numberPad
|
||||
|
||||
//Looks for single or multiple taps.
|
||||
let tap = UITapGestureRecognizer(target: self, action: #selector(ScannerViewController.hideKeyboard))
|
||||
readerViewController.view.addGestureRecognizer(tap)
|
||||
|
||||
settingButton.setImage(self.buttonState.icon, for: .normal)
|
||||
textField.placeholder = self.buttonState.inputText
|
||||
|
||||
}
|
||||
|
||||
func hideKeyboard() {
|
||||
@@ -63,8 +104,12 @@ extension ZBarSymbolSet: Sequence {
|
||||
|
||||
func buttonTouch(){
|
||||
|
||||
sendResult(textField.text!)
|
||||
|
||||
switch self.buttonState {
|
||||
case .card: self.buttonState = .phone
|
||||
case .phone: self.buttonState = .card
|
||||
}
|
||||
settingButton.setImage(self.buttonState.icon, for: .normal)
|
||||
textField.placeholder = self.buttonState.inputText
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
@@ -75,9 +120,9 @@ extension ZBarSymbolSet: Sequence {
|
||||
}
|
||||
|
||||
func sendResult(_ str: String) {
|
||||
platformChannel?.invokeMethod("findUserAndPurchase", arguments: [str], result: { (result: Any?) in
|
||||
platformChannel?.invokeMethod("findUserAndPurchase", arguments: [str, buttonState.searchType], result: { (result: Any?) in
|
||||
if result is FlutterError {
|
||||
self.showErrorAlert()
|
||||
self.showErrorAlert(str)
|
||||
} else {
|
||||
self.presentingViewController?.dismiss(animated: false, completion: { self.dismiss(animated: true) })
|
||||
}
|
||||
@@ -86,9 +131,12 @@ extension ZBarSymbolSet: Sequence {
|
||||
|
||||
}
|
||||
|
||||
func showErrorAlert() {
|
||||
let alertController = UIAlertController(title: "Error", message:
|
||||
"Wrong code", preferredStyle: UIAlertControllerStyle.alert)
|
||||
func showErrorAlert(_ str: String) {
|
||||
let alertController = UIAlertController(
|
||||
title: "Error",
|
||||
message: String(format: buttonState.errorText, str),
|
||||
preferredStyle: UIAlertControllerStyle.alert
|
||||
)
|
||||
alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.default,handler: nil))
|
||||
|
||||
self.present(alertController, animated: true, completion: nil)
|
||||
@@ -96,14 +144,8 @@ extension ZBarSymbolSet: Sequence {
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
|
||||
topView.backgroundColor = UIColor.white
|
||||
settingButton.setTitle("+", for: .normal)
|
||||
textField.placeholder = "Enter code"
|
||||
textField.borderStyle = .roundedRect
|
||||
|
||||
//self.present(readerViewController, animated: true)
|
||||
|
||||
super.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
@@ -115,8 +157,8 @@ extension ZBarSymbolSet: Sequence {
|
||||
|
||||
readerViewController.view.frame = view.bounds
|
||||
topView.frame = CGRect(x: 0, y: 0, width: readerViewController.view.frame.size.width, height: 40)
|
||||
textField.frame = CGRect(x: 8, y: 5, width: readerViewController.view.frame.size.width - 50, height: 30)
|
||||
settingButton.frame = CGRect(x: textField.frame.maxX + 8, y: 10, width: 20, height: 20)
|
||||
textField.frame = CGRect(x: settingButton.frame.maxX + 8, y: 5, width: readerViewController.view.frame.size.width - 50, height: 30)
|
||||
settingButton.frame = CGRect(x: 8, y: 10, width: 20, height: 20)
|
||||
|
||||
}
|
||||
|
||||
@@ -127,32 +169,9 @@ extension ZBarSymbolSet: Sequence {
|
||||
|
||||
if let symbol = symbol as? ZBarSymbol, let data = symbol.data {
|
||||
sendResult(data)
|
||||
/*
|
||||
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: \(result ?? "")")
|
||||
self.presentingViewController?.dismiss(animated: false, completion: { self.dismiss(animated: true) })
|
||||
})
|
||||
// })
|
||||
// })
|
||||
// let result = platformChannel.invokeMethod("getUserByCode", arguments: [data], handleResult(result: FlutterResult))
|
||||
// print(result);
|
||||
}
|
||||
/*
|
||||
let toast = UIAlertController()
|
||||
toast.message = data
|
||||
toast.add
|
||||
toast.show()
|
||||
*/
|
||||
//navigationController?.popViewController(animated: true)
|
||||
*/
|
||||
}
|
||||
}
|
||||
//navigationController?.popViewController(animated: true)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -104,8 +104,18 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
|
||||
} else if (call.method == 'findUserAndPurchase') {
|
||||
|
||||
var userResponse;
|
||||
print(call.arguments[1]);
|
||||
|
||||
try {
|
||||
switch (call.arguments[1]) {
|
||||
case 'card':
|
||||
userResponse = await getUserByCard(call.arguments[0],token);
|
||||
break;
|
||||
case 'phone':
|
||||
userResponse = await getUserByPhone(call.arguments[0],token);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
print(error.toString());
|
||||
}
|
||||
@@ -127,13 +137,8 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
|
||||
print(userString);
|
||||
print(card);
|
||||
pushRoute(context, new PurchaseScreen(helper, app, JSON.encode(users[0]), card));
|
||||
// var route = new MaterialPageRoute<Null>(
|
||||
// builder: (BuildContext context) =>
|
||||
// new PurchaseScreen(helper, app,));
|
||||
// while (Navigator.of(context).canPop()) {
|
||||
// Navigator.of(context).pop();
|
||||
// }
|
||||
// Navigator.of(context).pushReplacement(route);
|
||||
} else {
|
||||
throw new FlutterError("Users not found");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -82,6 +82,21 @@ getUserByCard(String card, String token) async {
|
||||
return httpClient.get(finalEndpoint, headers: headers);
|
||||
}
|
||||
|
||||
getUserByPhone(String phone, String token) async {
|
||||
|
||||
var headers = {
|
||||
'DM-Authorization': 'dmapptoken ${await getToken()}',
|
||||
'Authorization': 'dmtoken ${token}',
|
||||
'Accept-Language': Intl.defaultLocale
|
||||
};
|
||||
|
||||
|
||||
var finalEndpoint = "${await getEndpoint()}users/?phone=$phone";
|
||||
print(finalEndpoint);
|
||||
|
||||
return httpClient.get(finalEndpoint, headers: headers);
|
||||
}
|
||||
|
||||
getEndpoint() async {
|
||||
return await platform.invokeMethod('getEndpoint');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user