Toggle current sub active flag based on add-on
Signed-off-by: Neeraj Gupta <254676+ua741@users.noreply.github.com>
This commit is contained in:
parent
81079ac7dc
commit
3fbf7be3ab
2 changed files with 15 additions and 3 deletions
|
@ -52,6 +52,7 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
|
|||
late ProgressDialog _dialog;
|
||||
late UserDetails _userDetails;
|
||||
late bool _hasActiveSubscription;
|
||||
bool _hideCurrentPlanSelection = false;
|
||||
late FreePlan _freePlan;
|
||||
late List<BillingPlan> _plans;
|
||||
bool _hasLoadedData = false;
|
||||
|
@ -177,7 +178,10 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
|
|||
_userService.getUserDetailsV2(memoryCount: false).then((userDetails) async {
|
||||
_userDetails = userDetails;
|
||||
_currentSubscription = userDetails.subscription;
|
||||
|
||||
_hasActiveSubscription = _currentSubscription!.isValid();
|
||||
_hideCurrentPlanSelection =
|
||||
_currentSubscription?.attributes?.isCancelled ?? false;
|
||||
showYearlyPlan = _currentSubscription!.isYearlyPlan();
|
||||
final billingPlans = await _billingService.getBillingPlans();
|
||||
_isActiveStripeSubscriber =
|
||||
|
@ -458,7 +462,7 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
|
|||
storage: plan.storage,
|
||||
price: plan.price,
|
||||
period: plan.period,
|
||||
isActive: isActive,
|
||||
isActive: isActive && !_hideCurrentPlanSelection,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -53,6 +53,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
|
||||
// indicates if user's subscription plan is still active
|
||||
late bool _hasActiveSubscription;
|
||||
bool _hideCurrentPlanSelection = false;
|
||||
late FreePlan _freePlan;
|
||||
List<BillingPlan> _plans = [];
|
||||
bool _hasLoadedData = false;
|
||||
|
@ -73,7 +74,11 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
.then((userDetails) async {
|
||||
_userDetails = userDetails;
|
||||
_currentSubscription = userDetails.subscription;
|
||||
|
||||
_showYearlyPlan = _currentSubscription!.isYearlyPlan();
|
||||
_hideCurrentPlanSelection =
|
||||
(_currentSubscription?.attributes?.isCancelled ?? false) &&
|
||||
userDetails.hasPaidAddon();
|
||||
_hasActiveSubscription = _currentSubscription!.isValid();
|
||||
_isStripeSubscriber = _currentSubscription!.paymentProvider == stripe;
|
||||
return _filterStripeForUI().then((value) {
|
||||
|
@ -340,6 +345,9 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
Widget _stripeRenewOrCancelButton() {
|
||||
final bool isRenewCancelled =
|
||||
_currentSubscription!.attributes?.isCancelled ?? false;
|
||||
if (isRenewCancelled && _userDetails.hasPaidAddon()) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final String title = isRenewCancelled
|
||||
? S.of(context).renewSubscription
|
||||
: S.of(context).cancelSubscription;
|
||||
|
@ -503,7 +511,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
storage: plan.storage,
|
||||
price: plan.price,
|
||||
period: plan.period,
|
||||
isActive: isActive,
|
||||
isActive: isActive && !_hideCurrentPlanSelection,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -594,7 +602,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
storage: _currentSubscription!.storage,
|
||||
price: _currentSubscription!.price,
|
||||
period: _currentSubscription!.period,
|
||||
isActive: true,
|
||||
isActive: !_hasActiveSubscription,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue