Получение информации о пользователе, разные исправления

This commit is contained in:
Ivan Murashov
2017-07-25 21:27:50 +03:00
parent 8738fbfd39
commit 313dc307dc
16 changed files with 290 additions and 161 deletions

View File

@@ -23,7 +23,9 @@ const String splash_png = 'assets/splash.png';
const String logout_png = 'assets/logout.png';
const String activate_token_bg_png = 'assets/activate_token_message_background.png';
const String active_token_bg_png = 'assets/active_token_message_background.png';
const String expansion_icon_png = 'assets/expansion_icon.png';
const String powered_by_dinect_splash_png = 'assets/powered_by_dinect_splash.png';
const String powered_by_dinect_png = 'assets/powered_by_dinect.png';
// Colors
const Color primaryColor = const Color(0xffeb0004);
const Color greyTextColor = const Color(0xffa5a5a5);
@@ -31,7 +33,8 @@ const Color textBorderColor = const Color(0xffcfd8dc);
const Color tokenActiveTextColor = const Color(0xff1f5a1f);
const Color tokenActivateTextColor = const Color(0xff4e3a19);
const Color greenBackground = const Color(0xff8ae28a);
const Color faqGrey = const Color(0xff5b5b5b);
const Color faqTitlesColor = const Color(0xff404040);
// Dimens
const double verticalMargin = 28.0;
const double buttonVerticalMargin = 42.0;
@@ -62,44 +65,68 @@ startScanner(BuildContext context) async {
// Канал ловит вызовы методов из "нативной" части приложения.
// Могут быть вызваны либо logaut либо faq, либо purchase.
platform.setMethodCallHandler((MethodCall call) async {
if (call.method == 'foo') {
logout(context);
} else {
pushRoute(context, new PurchaseScreen());
}
if (token != null) {
platform.setMethodCallHandler((MethodCall call) async {
return result;
if (call.method == 'foo') {
logout(context);
} else {
});
var card = call.arguments;
print('card: ' + card);
String url = 'http://pos-api-int.dinect.com/20130701/users/?auto=${card}';
print('url: ' + url);
var headers = {
'DM-Authorization': 'dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08',
'Authorization': 'dmtoken ${token}'
};
httpClient.get(url, headers: headers).then((response) {
print(response.body);
List usersList = JSON.decode(response.body);
if (usersList.length > 0) {
pushRoute(context, new PurchaseScreen(usersList[0], card));
}
}).catchError((error) {
print(error.toString());
});
}
});
}
Navigator.of(context).pop();
await platform.invokeMethod('startScanner');
}
logout(BuildContext context) {
String url = intUrl + 'tokens/' + token + '?_dmapptoken=' + intToken;
print(url);
httpClient.delete(url).then((response) {
print(response.body);
const platform = const MethodChannel('com.dinect.checker/instance_id');
platform.invokeMethod('removeKeys');
pushRoute(context, new RegistrationScreen());
}).catchError((error) {
print(error.toString());
});
if (token != null) {
String url = intUrl + 'tokens/' + token + '?_dmapptoken=' + intToken;
print(url);
httpClient.delete(url).then((response) {
print(response.body);
const platform = const MethodChannel('com.dinect.checker/instance_id');
platform.invokeMethod('removeKeys');
Navigator.of(context).pop();
pushRoute(context, new RegistrationScreen());
}).catchError((error) {
print(error.toString());
});
} else {
Navigator.of(context).pop();
}
}
/// Навигация по приложению.
/// widget - следующий экран приложения.
pushRoute(BuildContext context, Widget widget) {
Navigator.of(context).pushReplacement(new MaterialPageRoute<Null>(
builder: (BuildContext context) {
return widget;
}));
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => widget);
Navigator.of(context).pushReplacement(route);
}
class Checker extends StatelessWidget {
@@ -111,4 +138,6 @@ class Checker extends StatelessWidget {
accentColor: primaryColor
));
}
}
}