From 388d68271a95eadb340524eb32166fa10f5703c9 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 8 Feb 2022 00:17:35 +0000 Subject: [PATCH 1/3] v5.7.1 - updates --- .../lib/resources/pages/account_detail.dart | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/LabelStoreMax/lib/resources/pages/account_detail.dart b/LabelStoreMax/lib/resources/pages/account_detail.dart index 52e8712..f152e80 100644 --- a/LabelStoreMax/lib/resources/pages/account_detail.dart +++ b/LabelStoreMax/lib/resources/pages/account_detail.dart @@ -18,6 +18,7 @@ import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/safearea_widget.dart'; import 'package:flutter_app/resources/widgets/woosignal_ui.dart'; import 'package:nylo_framework/nylo_framework.dart'; +import 'package:wp_json_api/exceptions/invalid_user_token_exception.dart'; import 'package:wp_json_api/models/responses/wc_customer_info_response.dart'; import 'package:wp_json_api/wp_json_api.dart'; @@ -49,6 +50,14 @@ class _AccountDetailPageState extends State try { wcCustomerInfoResponse = await WPJsonAPI.instance .api((request) => request.wcCustomerInfo(userToken)); + } on InvalidUserTokenException catch (_) { + showToastNotification( + context, + title: trans("Oops!"), + description: trans("Something went wrong"), + style: ToastNotificationStyleType.DANGER, + ); + await authLogout(context); } on Exception catch (_) { showToastNotification( context, @@ -89,7 +98,10 @@ class _AccountDetailPageState extends State if (activeBody == null) { return SizedBox.shrink(); } - + if (_wcCustomerInfoResponse != null) { + print('here'); + print(_wcCustomerInfoResponse.data.avatar); + } return Scaffold( appBar: AppBar( leading: widget.showLeadingBackButton @@ -123,13 +135,11 @@ class _AccountDetailPageState extends State children: [ Container( margin: EdgeInsets.only(top: 10), - child: CircleAvatar( + child: _wcCustomerInfoResponse != null ? CircleAvatar( backgroundImage: NetworkImage( - _wcCustomerInfoResponse != null - ? _wcCustomerInfoResponse.data.avatar - : "", + _wcCustomerInfoResponse.data.avatar, ), - ), + ) : Icon(Icons.account_circle_rounded, size: 65,), height: 90, width: 90, ), From 6ac676c60b456dfc91dcc078e1d845cf8cc9753f Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 8 Feb 2022 00:30:23 +0000 Subject: [PATCH 2/3] v5.7.1 - updates --- .../lib/resources/pages/account_detail.dart | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/LabelStoreMax/lib/resources/pages/account_detail.dart b/LabelStoreMax/lib/resources/pages/account_detail.dart index f152e80..8e12f3d 100644 --- a/LabelStoreMax/lib/resources/pages/account_detail.dart +++ b/LabelStoreMax/lib/resources/pages/account_detail.dart @@ -98,9 +98,16 @@ class _AccountDetailPageState extends State if (activeBody == null) { return SizedBox.shrink(); } - if (_wcCustomerInfoResponse != null) { - print('here'); - print(_wcCustomerInfoResponse.data.avatar); + String userAvatar; + String userFirstName = ""; + String userLastName = ""; + if (_wcCustomerInfoResponse != null && _wcCustomerInfoResponse.data != null) { + userAvatar = _wcCustomerInfoResponse.data.avatar; + + userFirstName = _wcCustomerInfoResponse + .data.firstName; + userLastName = _wcCustomerInfoResponse + .data.lastName; } return Scaffold( appBar: AppBar( @@ -135,10 +142,8 @@ class _AccountDetailPageState extends State children: [ Container( margin: EdgeInsets.only(top: 10), - child: _wcCustomerInfoResponse != null ? CircleAvatar( - backgroundImage: NetworkImage( - _wcCustomerInfoResponse.data.avatar, - ), + child: userAvatar != null ? CircleAvatar( + backgroundImage: NetworkImage(userAvatar), ) : Icon(Icons.account_circle_rounded, size: 65,), height: 90, width: 90, @@ -156,18 +161,13 @@ class _AccountDetailPageState extends State MainAxisAlignment.spaceAround, children: [ Text( - (_wcCustomerInfoResponse == null - ? "" - : [ - _wcCustomerInfoResponse - .data.firstName, - _wcCustomerInfoResponse - .data.lastName - ] - .where((t) => - (t != null || t != "")) - .toList() - .join(" ")), + [ + userFirstName, + userLastName + ].where((t) => + (t != null || t != "")) + .toList() + .join(" "), style: TextStyle( fontSize: 20, fontWeight: FontWeight.w600, From 6ee4a2afb27d89358b3df5bde01b37ae39b91a99 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 8 Feb 2022 00:32:00 +0000 Subject: [PATCH 3/3] v5.7.1 - updates --- LabelStoreMax/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md index 24d81ca..d711119 100644 --- a/LabelStoreMax/CHANGELOG.md +++ b/LabelStoreMax/CHANGELOG.md @@ -1,9 +1,10 @@ ## [5.7.1] - 2022-02-07 * Refactor account order detail page -* Fix continuous loading if users has no orders +* Fix continuous loading if a user has no orders * New styling for tabs in the account order detail page * Small refactor to controller loading +* Handle invalid tokens on the account page * Pubspec.yaml dependency updates ## [5.7.0] - 2022-01-29