Kaynağa Gözat

Show toast when subscription refresh is triggered/failed

Neeraj Gupta 4 yıl önce
ebeveyn
işleme
00988de60c

+ 4 - 2
lib/ui/payment/payment_web_page.dart

@@ -163,8 +163,8 @@ class _PaymentWebPage extends State<PaymentWebPage> {
 
   Future<void> handlePaymentResponse(Uri uri) async {
     var queryParams = uri.queryParameters;
-    // success or fail
     var paymentStatus = uri.queryParameters['status'] ?? '';
+    _logger.fine('handle payment response with status $paymentStatus');
     if ('fail' == paymentStatus) {
       var reason = queryParams['reason'] ?? '';
       showDialog(
@@ -223,12 +223,14 @@ class _PaymentWebPage extends State<PaymentWebPage> {
   Future<dynamic> _showExitPageDialog({String title, String content}) {
     return showDialog(
         context: context,
+        barrierDismissible: false,
         builder: (context) => AlertDialog(
                 title: Text(title),
                 content: Text(content),
                 actions: <Widget>[
                   TextButton(
-                      child: Text('ok'),
+                      child: Text('ok',
+                      style: TextStyle(color: Theme.of(context).buttonColor),),
                       onPressed: () {
                         Navigator.of(context).pop('dialog');
                         Navigator.of(context).pop(true);

+ 8 - 5
lib/ui/payment/subscription_page.dart

@@ -95,14 +95,17 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
     }).toList();
   }
 
-  FutureOr onWebPaymentGoBack(dynamic value) {
-    // refresh subscription
+  FutureOr onWebPaymentGoBack(dynamic value) async {
     if (widget.isOnboarding) {
       Navigator.of(context).popUntil((route) => route.isFirst);
     } else {
-      _dialog
-          .show()
-          .then((value) => _fetchSub().then((value) => _dialog.hide()));
+      // refresh subscription
+      try {
+        showToast("refreshing subscription status");
+        await _fetchSub();
+      } catch (e) {
+        showToast("failed to refresh subscription");
+      }
     }
   }