All done. Need fix logout.
This commit is contained in:
Binary file not shown.
@@ -27,6 +27,11 @@
|
|||||||
<key>primary</key>
|
<key>primary</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>FB8CCC12204C8249002BBFDA</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
Binary file not shown.
@@ -78,19 +78,14 @@
|
|||||||
|
|
||||||
NSDictionary *buildSettings = settings[bundleIdentifier];
|
NSDictionary *buildSettings = settings[bundleIdentifier];
|
||||||
|
|
||||||
NSLog(@"%@", bundleIdentifier);
|
|
||||||
|
|
||||||
if (!buildSettings) {
|
if (!buildSettings) {
|
||||||
NSLog(@"Settings for this bunndle id not defined (%@)", bundleIdentifier);
|
NSLog(@"Settings for this bunndle id not defined (%@)", bundleIdentifier);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
[platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
||||||
NSLog(@"%@", call.method);
|
NSLog(@"%@", call.method);
|
||||||
|
|
||||||
NSLog(@"%@", buildSettings[@"supportPhone"]);
|
|
||||||
|
|
||||||
if ([@"getLocale" isEqualToString:call.method]) {
|
if ([@"getLocale" isEqualToString:call.method]) {
|
||||||
result(buildSettings[@"locale"]);
|
result(buildSettings[@"locale"]);
|
||||||
} else if ([@"getFlavor" isEqualToString:call.method]) {
|
} else if ([@"getFlavor" isEqualToString:call.method]) {
|
||||||
|
|||||||
@@ -73,6 +73,13 @@ import Flutter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setButtonState() {
|
||||||
|
switch self.buttonState {
|
||||||
|
case .card: self.buttonState = .phone
|
||||||
|
case .phone: self.buttonState = .card
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let capture: ZXCapture = ZXCapture()
|
let capture: ZXCapture = ZXCapture()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
@@ -97,7 +104,7 @@ import Flutter
|
|||||||
|
|
||||||
settingButton.setImage(self.buttonState.icon, for: .normal)
|
settingButton.setImage(self.buttonState.icon, for: .normal)
|
||||||
textField.placeholder = self.getInputHint()
|
textField.placeholder = self.getInputHint()
|
||||||
|
textField.text = "79087654321"
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
@@ -121,36 +128,29 @@ import Flutter
|
|||||||
}
|
}
|
||||||
|
|
||||||
func buttonTouch(){
|
func buttonTouch(){
|
||||||
|
setButtonState()
|
||||||
switch self.buttonState {
|
|
||||||
case .card: self.buttonState = .phone
|
|
||||||
case .phone: self.buttonState = .card
|
|
||||||
}
|
|
||||||
settingButton.setImage(self.buttonState.icon, for: .normal)
|
settingButton.setImage(self.buttonState.icon, for: .normal)
|
||||||
textField.placeholder = self.getInputHint()
|
textField.placeholder = self.getInputHint()
|
||||||
}
|
}
|
||||||
|
|
||||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||||
|
print("User from manual input: \(textField.text)")
|
||||||
sendResult(textField.text!)
|
sendResult(textField.text!)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendResult(_ str: String) {
|
func sendResult(_ str: String) {
|
||||||
print("result: \(str)")
|
|
||||||
platformChannel?.invokeMethod("findUser", arguments: [str, buttonState.searchType], result: { (result: Any?) in
|
platformChannel?.invokeMethod("findUser", arguments: [str, buttonState.searchType], result: { (result: Any?) in
|
||||||
if result is FlutterError {
|
if result is FlutterError {
|
||||||
|
print("Result is nil (ios code)");
|
||||||
self.showErrorAlert(str)
|
self.showErrorAlert(str)
|
||||||
} else {
|
} else {
|
||||||
|
print("Result is not nil (ios code)");
|
||||||
self.dismiss(animated: true) {
|
self.dismiss(animated: true) {
|
||||||
self.platformChannel?.invokeMethod("purchase", arguments: [result, str])
|
self.platformChannel?.invokeMethod("purchase", arguments: [result, str])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("result: \(result.debugDescription )")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func showErrorAlert(_ str: String) {
|
func showErrorAlert(_ str: String) {
|
||||||
@@ -297,6 +297,7 @@ import Flutter
|
|||||||
location = "\(location) (\(transformedPoint.x), \(transformedPoint.y))"
|
location = "\(location) (\(transformedPoint.x), \(transformedPoint.y))"
|
||||||
points.append(windowPointValue)
|
points.append(windowPointValue)
|
||||||
}
|
}
|
||||||
|
print("User from scanner: \(result.text)")
|
||||||
sendResult(result.text)
|
sendResult(result.text)
|
||||||
print(result.text)
|
print(result.text)
|
||||||
self.capture.stop()
|
self.capture.stop()
|
||||||
|
|||||||
@@ -34,7 +34,13 @@ class RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return getMainWidget();
|
return new WillPopScope(onWillPop: () => onWillPop(), child: getMainWidget());
|
||||||
|
}
|
||||||
|
|
||||||
|
onWillPop() {
|
||||||
|
if (Theme.of(context).platform != TargetPlatform.iOS) {
|
||||||
|
platform.invokeMethod('finish');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override String getTitle() {
|
@override String getTitle() {
|
||||||
@@ -62,7 +68,9 @@ class RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
handleTap() {
|
handleTap() {
|
||||||
print('tokenActive: $_tokenActive');
|
print('tokenActive: $_tokenActive');
|
||||||
if (_tokenActive) {
|
if (_tokenActive) {
|
||||||
Navigator.of(context).pop(true);
|
helper.getToken().then((token) {
|
||||||
|
Navigator.of(context).pop(token);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
platform.invokeMethod('isOnline').then((isOnline) {
|
platform.invokeMethod('isOnline').then((isOnline) {
|
||||||
if (isOnline ) {
|
if (isOnline ) {
|
||||||
|
|||||||
@@ -46,11 +46,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
||||||
setState(() {
|
|
||||||
requestAsyncData(user);
|
requestAsyncData(user);
|
||||||
});
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +62,6 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
String loyalty = '';
|
String loyalty = '';
|
||||||
String bonus = '';
|
String bonus = '';
|
||||||
List<Map> coupons = [];
|
List<Map> coupons = [];
|
||||||
bool dataRequested = false;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget getScreenContent() {
|
Widget getScreenContent() {
|
||||||
@@ -190,7 +185,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
height: buttonHeight,
|
height: buttonHeight,
|
||||||
child: new FlatButton(
|
child: new FlatButton(
|
||||||
child: new Text(title, style: new TextStyle(color: textColor)),
|
child: new Text(title, style: new TextStyle(color: textColor)),
|
||||||
onPressed: () => Navigator.of(context).pop(true)),
|
onPressed: () => Navigator.of(context).pop()),
|
||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
border: new Border.all(
|
border: new Border.all(
|
||||||
color: Resources.getButtonColor(app), width: 1.0),
|
color: Resources.getButtonColor(app), width: 1.0),
|
||||||
@@ -230,9 +225,11 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
requestAsyncData(Map user) async {
|
requestAsyncData(Map user) async {
|
||||||
|
setState(() {
|
||||||
|
loading = true;
|
||||||
|
});
|
||||||
bool showBonus = await platform.invokeMethod('showBonus');
|
bool showBonus = await platform.invokeMethod('showBonus');
|
||||||
if (await platform.invokeMethod('isOnline') && !this.dataRequested) {
|
if (await platform.invokeMethod('isOnline')) {
|
||||||
this.dataRequested = true;
|
|
||||||
var response, couponResponse;
|
var response, couponResponse;
|
||||||
print(user['coupons_url']);
|
print(user['coupons_url']);
|
||||||
try {
|
try {
|
||||||
@@ -407,7 +404,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
|
|
||||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||||
print('show purchase success!');
|
print('show purchase success!');
|
||||||
var route = new MaterialPageRoute<bool>(builder: (BuildContext context) => new PurchaseSuccessScreen(
|
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => new PurchaseSuccessScreen(
|
||||||
sumTotal,
|
sumTotal,
|
||||||
user['first_name'] == null ? '' : user['first_name'],
|
user['first_name'] == null ? '' : user['first_name'],
|
||||||
helper,
|
helper,
|
||||||
@@ -415,8 +412,8 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
purchase,
|
purchase,
|
||||||
coupons['results']
|
coupons['results']
|
||||||
), fullscreenDialog: true);
|
), fullscreenDialog: true);
|
||||||
Navigator.of(context).push(route).then((b) {
|
Navigator.of(context).push(route).then((_) {
|
||||||
print('finish registration closed: $b');
|
Navigator.of(context).pop();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
|||||||
|
|
||||||
getScanButton() {
|
getScanButton() {
|
||||||
String title = StringsLocalization.scan();
|
String title = StringsLocalization.scan();
|
||||||
return buildRaisedButton(title, () => Navigator.of(context).pop(true));
|
return buildRaisedButton(title, () => Navigator.of(context).pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -113,9 +113,10 @@ class RegistrationScreenState extends BaseState<RegistrationScreen> {
|
|||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
helper.createSession(merchantID, posID, parsedMap['token']).then((_) {
|
helper.createSession(merchantID, posID, parsedMap['token']).then((_) {
|
||||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||||
var route = new MaterialPageRoute<bool>(builder: (BuildContext context) => new FinishRegistrationScreen(helper, app), fullscreenDialog: true);
|
print('start finish registration!');
|
||||||
Navigator.of(context).push(route).then((b) {
|
var route = new MaterialPageRoute<String>(builder: (BuildContext context) => new FinishRegistrationScreen(helper, app), fullscreenDialog: true);
|
||||||
print('finish registration closed: $b');
|
Navigator.of(context).push(route).then((token) {
|
||||||
|
Navigator.of(context).pop(token);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -55,9 +55,6 @@ class SettingsState extends BaseState<SettingsScreen> {
|
|||||||
@override Widget build(BuildContext ctx) {
|
@override Widget build(BuildContext ctx) {
|
||||||
helper.getSettings(true).then((info) {
|
helper.getSettings(true).then((info) {
|
||||||
setState(() {
|
setState(() {
|
||||||
// print('currency: ${info['currency']}');
|
|
||||||
// print('locale: ${info['locale']}');
|
|
||||||
// print('token: ${info['token']}');
|
|
||||||
menuItems[0].title = StringsLocalization.currency();
|
menuItems[0].title = StringsLocalization.currency();
|
||||||
menuItems[1].title = StringsLocalization.locale();
|
menuItems[1].title = StringsLocalization.locale();
|
||||||
menuItems[2].title = StringsLocalization.logout();
|
menuItems[2].title = StringsLocalization.logout();
|
||||||
|
|||||||
@@ -173,31 +173,39 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
|||||||
SqliteHelper helper) {
|
SqliteHelper helper) {
|
||||||
// Канал ловит вызовы методов из "нативной" части приложения.
|
// Канал ловит вызовы методов из "нативной" части приложения.
|
||||||
// Могут быть вызваны либо exit либо faq, либо purchase.
|
// Могут быть вызваны либо exit либо faq, либо purchase.
|
||||||
platform.setMethodCallHandler((MethodCall call) {
|
platform.setMethodCallHandler((MethodCall call) async {
|
||||||
print(this.toString());
|
print(this.toString());
|
||||||
if (call.method == 'findUser') {
|
if (call.method == 'findUser') {
|
||||||
String cardPhone = call.arguments[0];
|
|
||||||
var userResponse = getUser(call.arguments[1], cardPhone, token);
|
|
||||||
|
|
||||||
if (userResponse != null) {
|
|
||||||
userResponse.then((response) {
|
|
||||||
List<Map> users;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
users = JSON.decode(response.body);
|
|
||||||
} catch (error) {
|
Response userResponse;
|
||||||
print(error);
|
|
||||||
|
switch (call.arguments[1]) {
|
||||||
|
case 'card':
|
||||||
|
userResponse = await getUserByCard(call.arguments[0], token);
|
||||||
|
break;
|
||||||
|
case 'phone':
|
||||||
|
userResponse = await getUserByPhone(call.arguments[0], token);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userResponse != null) {
|
||||||
|
print('I have user in method handler!');
|
||||||
|
List<Map> users = JSON.decode(userResponse.body);
|
||||||
if (users.length > 0) {
|
if (users.length > 0) {
|
||||||
return users[0];
|
return users[0];
|
||||||
} else {
|
} else {
|
||||||
throw new FlutterError("Users not found");
|
throw new FlutterError("Users not found");
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
throw new FlutterError("Users not found");
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
print(error.toString());
|
||||||
|
throw new FlutterError("Users not found");
|
||||||
|
}
|
||||||
|
|
||||||
} else if (call.method == 'faq') {
|
} else if (call.method == 'faq') {
|
||||||
faq(helper, app, context, true);
|
faq(helper, app, context, true);
|
||||||
} else if (call.method == 'settings') {
|
} else if (call.method == 'settings') {
|
||||||
@@ -209,20 +217,12 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
String userString;
|
String userString = call.arguments[0] is String
|
||||||
|
? call.arguments[0]
|
||||||
if (call.arguments[0] is String) {
|
: JSON.encode(call.arguments[0]);
|
||||||
userString = call.arguments[0];
|
|
||||||
} else {
|
|
||||||
userString = JSON.encode(call.arguments[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
print(userString);
|
print(userString);
|
||||||
|
|
||||||
String card = call.arguments[1];
|
String card = call.arguments[1];
|
||||||
print('$userString, $card');
|
purchase(token, userString, card);
|
||||||
|
|
||||||
startScanner(token, userString, card);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
startScanner(String token, String userString, String card) {
|
purchase(String token, String userString, String card) {
|
||||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||||
var route = new MaterialPageRoute<Null>(
|
var route = new MaterialPageRoute<Null>(
|
||||||
builder: (BuildContext context) => new PurchaseScreen(helper, app, userString, card), fullscreenDialog: true);
|
builder: (BuildContext context) => new PurchaseScreen(helper, app, userString, card), fullscreenDialog: true);
|
||||||
@@ -251,22 +251,4 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Response> getUser(String type, String cardPhone, String token) {
|
|
||||||
try {
|
|
||||||
switch (type) {
|
|
||||||
case 'card':
|
|
||||||
return getUserByCard(cardPhone, token);
|
|
||||||
break;
|
|
||||||
case 'phone':
|
|
||||||
return getUserByPhone(cardPhone, token);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
print(error.toString());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user