Merge pull request #451 from pangeachat/delete-subscription-with-account
warn subscribed users to delete their subscription before deleting th…
This commit is contained in:
commit
6dd189c38f
3 changed files with 46 additions and 5 deletions
|
|
@ -4105,5 +4105,9 @@
|
|||
"placeholders": {}
|
||||
},
|
||||
"changeAnalyticsView": "Change Analytics View",
|
||||
"l1TranslationBody": "Oops! It looks like this message wasn't sent in your target language. Messages not sent in your target language will not be translated."
|
||||
"l1TranslationBody": "Oops! It looks like this message wasn't sent in your target language. Messages not sent in your target language will not be translated.",
|
||||
"continueText": "Continue",
|
||||
"deleteSubscriptionWarningTitle": "You have an active subscription",
|
||||
"deleteSubscriptionWarningBody": "Deleting your account will not automatically cancel your subscription.",
|
||||
"manageSubscription": "Manage Subscription"
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:fluffychat/widgets/app_lock.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'package:fluffychat/widgets/app_lock.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../bootstrap/bootstrap_dialog.dart';
|
||||
import 'settings_security_view.dart';
|
||||
|
||||
|
|
@ -51,6 +51,28 @@ class SettingsSecurityController extends State<SettingsSecurity> {
|
|||
}
|
||||
|
||||
void deleteAccountAction() async {
|
||||
// #Pangea
|
||||
final subscriptionController =
|
||||
MatrixState.pangeaController.subscriptionController;
|
||||
if (subscriptionController.subscription?.isPaidSubscription == true &&
|
||||
subscriptionController.subscription?.defaultManagementURL != null) {
|
||||
final resp = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.deleteSubscriptionWarningTitle,
|
||||
message: L10n.of(context)!.deleteSubscriptionWarningBody,
|
||||
okLabel: L10n.of(context)!.manageSubscription,
|
||||
cancelLabel: L10n.of(context)!.continueText,
|
||||
);
|
||||
if (resp == OkCancelResult.ok) {
|
||||
launchUrlString(
|
||||
subscriptionController.subscription!.defaultManagementURL!,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Pangea#
|
||||
if (await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/config/environment.dart';
|
||||
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/controllers/subscription_controller.dart';
|
||||
import 'package:fluffychat/pangea/repo/subscription_repo.dart';
|
||||
|
|
@ -51,6 +52,11 @@ class SubscriptionInfo {
|
|||
bool get currentSubscriptionIsPromotional =>
|
||||
currentSubscriptionId?.startsWith("rc_promo") ?? false;
|
||||
|
||||
bool get isPaidSubscription =>
|
||||
(currentSubscription != null || currentSubscriptionId != null) &&
|
||||
!isNewUserTrial &&
|
||||
!currentSubscriptionIsPromotional;
|
||||
|
||||
bool get isLifetimeSubscription =>
|
||||
currentSubscriptionIsPromotional &&
|
||||
expirationDate != null &&
|
||||
|
|
@ -86,4 +92,13 @@ class SubscriptionInfo {
|
|||
}
|
||||
|
||||
Future<void> setCustomerInfo() async {}
|
||||
|
||||
String? get defaultManagementURL {
|
||||
final String? purchaseAppId = currentSubscription?.appId;
|
||||
return purchaseAppId == appIds?.androidId
|
||||
? AppConfig.googlePlayMangementUrl
|
||||
: purchaseAppId == appIds?.appleId
|
||||
? AppConfig.appleMangementUrl
|
||||
: Environment.stripeManagementUrl;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue