1
+ import 'package:core/presentation/extensions/color_extension.dart' ;
1
2
import 'package:flutter/material.dart' ;
3
+ import 'package:flutter_svg/flutter_svg.dart' ;
2
4
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart' ;
3
5
import 'package:tmail_ui_user/features/paywall/domain/model/paywall_url_pattern.dart' ;
4
6
import 'package:tmail_ui_user/features/paywall/domain/usecases/get_paywall_url_interactor.dart' ;
@@ -7,7 +9,7 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
7
9
import 'package:tmail_ui_user/main/routes/route_utils.dart' ;
8
10
import 'package:tmail_ui_user/main/utils/app_utils.dart' ;
9
11
10
- extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
12
+ extension HandlePaywallExtension on MailboxDashBoardController {
11
13
bool validatePremiumIsAvailable () {
12
14
if (accountId.value == null || sessionCurrent == null ) {
13
15
return false ;
@@ -26,19 +28,56 @@ extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
26
28
consumeState (getPaywallUrlInteractor.execute (jmapUrl));
27
29
} else {
28
30
paywallUrlPattern = null ;
31
+ if (isRetryGetPaywallUrl) {
32
+ _showMessagePaywallUrlNotAvailable ();
33
+ isRetryGetPaywallUrl = false ;
34
+ }
29
35
}
30
36
}
31
37
32
38
void loadPaywallUrlSuccess (PaywallUrlPattern newPattern) {
33
39
paywallUrlPattern = newPattern;
34
40
}
35
41
42
+ void loadPaywallUrlFailure () {
43
+ paywallUrlPattern = null ;
44
+ if (isRetryGetPaywallUrl) {
45
+ _showMessagePaywallUrlNotAvailable ();
46
+ isRetryGetPaywallUrl = false ;
47
+ }
48
+ }
49
+
50
+ void _showMessagePaywallUrlNotAvailable ({BuildContext ? context}) {
51
+ final overlayContext = context ?? currentOverlayContext;
52
+ AppLocalizations ? appLocalizations;
53
+ if (context != null ) {
54
+ appLocalizations = AppLocalizations .of (context);
55
+ } else if (currentContext != null ) {
56
+ appLocalizations = AppLocalizations .of (currentContext! );
57
+ }
58
+
59
+ if (overlayContext == null || appLocalizations == null ) return ;
60
+
61
+ appToast.showToastMessage (
62
+ overlayContext,
63
+ appLocalizations.paywallUrlNotAvailable,
64
+ actionName: appLocalizations.retry,
65
+ onActionClick: _handleRetryGetPaywallUrl,
66
+ leadingSVGIcon: imagePaths.icQuotasWarning,
67
+ leadingSVGIconColor: Colors .white,
68
+ backgroundColor: AppColor .toastErrorBackgroundColor,
69
+ textColor: Colors .white,
70
+ actionIcon: SvgPicture .asset (
71
+ imagePaths.icRefreshQuotas,
72
+ colorFilter: Colors .white.asFilter (),
73
+ ),
74
+ duration: const Duration (seconds: 5 ),
75
+ );
76
+ }
77
+
36
78
void navigateToPaywall (BuildContext context) {
37
79
if (paywallUrlPattern == null ) {
38
- appToast.showToastErrorMessage (
39
- context,
40
- AppLocalizations .of (context).paywallUrlNotAvailable,
41
- );
80
+ _showMessagePaywallUrlNotAvailable (context: context);
42
81
return ;
43
82
}
44
83
@@ -49,4 +88,9 @@ extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
49
88
50
89
AppUtils .launchLink (qualifiedPaywall);
51
90
}
91
+
92
+ void _handleRetryGetPaywallUrl () {
93
+ isRetryGetPaywallUrl = true ;
94
+ loadPaywallUrl ();
95
+ }
52
96
}
0 commit comments