diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 0a636a5667..9b9204947b 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3790,7 +3790,7 @@ } }, "freeTrialDesc": "New users recieve a one week free trial of Pangea Chat", - "activateTrial": "Activate Trial", + "activateTrial": "Activate Free Trial", "inNoSpaces": "You are not a member of any classes or exchanges", "successfullySubscribed": "You have successfully subscribed!", "clickToManageSubscription": "Click here to manage your subscription.", @@ -3948,5 +3948,6 @@ "age": {} } }, - "kickBotWarning": "Kicking Pangea Bot will remove the conversation bot from this chat." + "kickBotWarning": "Kicking Pangea Bot will remove the conversation bot from this chat.", + "refresh": "Refresh" } \ No newline at end of file diff --git a/assets/l10n/intl_es.arb b/assets/l10n/intl_es.arb index 791a070694..4f6ba040e9 100644 --- a/assets/l10n/intl_es.arb +++ b/assets/l10n/intl_es.arb @@ -4469,7 +4469,6 @@ } }, "freeTrialDesc": "Los nuevos usuarios reciben una semana de prueba gratuita de Pangea Chat", - "activateTrial": "Activar prueba", "successfullySubscribed": "Se ha suscrito correctamente.", "clickToManageSubscription": "Haga clic aquí para gestionar su suscripción.", "emptyInviteWarning": "Añade este chat a una clase o intercambio para invitar a otros usuarios.", @@ -4582,5 +4581,7 @@ } }, "selectToDefine": "Haga doble clic en una palabra para ver su definición.", - "kickBotWarning": "Patear Pangea Bot eliminará el bot de conversación de este chat." + "kickBotWarning": "Patear Pangea Bot eliminará el bot de conversación de este chat.", + "activateTrial": "Activar prueba gratuita", + "refresh": "Actualizar" } diff --git a/lib/pages/chat_details/chat_details_view.dart b/lib/pages/chat_details/chat_details_view.dart index ca4816da0d..434e1e41db 100644 --- a/lib/pages/chat_details/chat_details_view.dart +++ b/lib/pages/chat_details/chat_details_view.dart @@ -1,3 +1,4 @@ +import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/pages/chat_details/chat_details.dart'; import 'package:fluffychat/pages/chat_details/participant_list_item.dart'; @@ -531,18 +532,33 @@ class ChatDetailsView extends StatelessWidget { Icons.archive_outlined, ), ), - onTap: () => showFutureLoadingDialog( - context: context, - future: () async { - room.isSpace - ? await archiveSpace( - room, - Matrix.of(context).client, - ) - : await room.leave(); - context.go('/rooms'); - }, - ), + onTap: () async { + final confirmed = await showOkCancelAlertDialog( + useRootNavigator: false, + context: context, + title: L10n.of(context)!.areYouSure, + okLabel: L10n.of(context)!.ok, + cancelLabel: L10n.of(context)!.cancel, + message: + L10n.of(context)!.archiveRoomDescription, + ); + if (confirmed == OkCancelResult.ok) { + final success = await showFutureLoadingDialog( + context: context, + future: () async { + room.isSpace + ? await archiveSpace( + room, + Matrix.of(context).client, + ) + : await room.leave(); + }, + ); + if (success.error == null) { + context.go('/rooms'); + } + } + }, ), if (room.isRoomAdmin && !room.isDirectChat) SwitchListTile.adaptive( diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 417e1165c6..906c3af71b 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -523,12 +523,25 @@ class _SpaceViewState extends State { MatrixLocals(L10n.of(context)!), ), ), - trailing: IconButton( - icon: loading - ? const CircularProgressIndicator.adaptive(strokeWidth: 2) - : const Icon(Icons.refresh_outlined), - onPressed: loading ? null : _refresh, + // #Pangea + // trailing: IconButton( + // icon: loading + // ? const CircularProgressIndicator.adaptive(strokeWidth: 2) + // : const Icon(Icons.refresh_outlined), + // onPressed: loading ? null : _refresh, + // ), + trailing: Tooltip( + message: L10n.of(context)!.refresh, + child: IconButton( + icon: loading + ? const CircularProgressIndicator.adaptive( + strokeWidth: 2, + ) + : const Icon(Icons.refresh_outlined), + onPressed: loading ? null : _refresh, + ), ), + // Pangea# ), ), Builder( diff --git a/lib/pages/settings/settings_view.dart b/lib/pages/settings/settings_view.dart index 6025e480b8..36766ea65f 100644 --- a/lib/pages/settings/settings_view.dart +++ b/lib/pages/settings/settings_view.dart @@ -1,15 +1,15 @@ +import 'package:fluffychat/config/app_config.dart'; +import 'package:fluffychat/pangea/config/environment.dart'; +import 'package:fluffychat/utils/fluffy_share.dart'; +import 'package:fluffychat/widgets/avatar.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:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; import 'package:url_launcher/url_launcher_string.dart'; -import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/pangea/config/environment.dart'; -import 'package:fluffychat/utils/fluffy_share.dart'; -import 'package:fluffychat/widgets/avatar.dart'; -import 'package:fluffychat/widgets/matrix.dart'; import 'settings.dart'; class SettingsView extends StatelessWidget { @@ -208,7 +208,22 @@ class SettingsView extends StatelessWidget { ListTile( leading: const Icon(Icons.help_outline_outlined), title: Text(L10n.of(context)!.help), - onTap: () => launchUrlString(AppConfig.supportUrl), + // #Pangea + // onTap: () => launchUrlString(AppConfig.supportUrl), + onTap: () async { + await showFutureLoadingDialog( + context: context, + future: () async { + final String roomId = + await Matrix.of(context).client.startDirectChat( + Environment.supportUserId, + enableEncryption: false, + ); + context.go('/rooms/$roomId'); + }, + ); + }, + // Pangea# trailing: const Icon(Icons.open_in_new_outlined), ), ListTile( diff --git a/lib/pangea/config/environment.dart b/lib/pangea/config/environment.dart index a95b3db3d3..4d43789996 100644 --- a/lib/pangea/config/environment.dart +++ b/lib/pangea/config/environment.dart @@ -68,4 +68,8 @@ class Environment { return dotenv.env["STRIPE_MANAGEMENT_LINK"] ?? 'https://billing.stripe.com/p/login/dR6dSkf5p6rBc4EcMM'; } + + static String get supportUserId { + return isStaging ? '@support:staging.pangea.chat' : '@support:pangea.chat'; + } } diff --git a/lib/pangea/controllers/user_controller.dart b/lib/pangea/controllers/user_controller.dart index cff86c9de3..e1b326eaba 100644 --- a/lib/pangea/controllers/user_controller.dart +++ b/lib/pangea/controllers/user_controller.dart @@ -260,6 +260,7 @@ class UserController extends BaseController { final PUserModel newUserModel = await PUserRepo.repoCreatePangeaUser( userID: userId!, fullName: fullname, + dob: dob, matrixAccessToken: _matrixAccessToken!, ); await _savePUserModel(newUserModel); diff --git a/lib/pangea/pages/settings_subscription/settings_subscription.dart b/lib/pangea/pages/settings_subscription/settings_subscription.dart index b517d32a24..86c43ff47c 100644 --- a/lib/pangea/pages/settings_subscription/settings_subscription.dart +++ b/lib/pangea/pages/settings_subscription/settings_subscription.dart @@ -85,7 +85,7 @@ class SubscriptionManagementController extends State { ""; bool get showManagementOptions { - if (!currentSubscriptionAvailable) { + if (!currentSubscriptionAvailable || isNewUserTrial) { return false; } if (subscriptionController.subscription!.purchasedOnWeb) { @@ -102,7 +102,9 @@ class SubscriptionManagementController extends State { context, isPromo: isPromo, ); - setState(() {}); + setState(() { + selectedSubscription = null; + }); } catch (err) { showOkAlertDialog( context: context, @@ -164,6 +166,11 @@ class SubscriptionManagementController extends State { setState(() => selectedSubscription = subscription); } + bool isCurrentSubscription(SubscriptionDetails subscription) => + subscriptionController.subscription?.currentSubscription == + subscription || + isNewUserTrial && subscription.isTrial; + @override Widget build(BuildContext context) => SettingsSubscriptionView(this); } diff --git a/lib/pangea/pages/settings_subscription/settings_subscription_view.dart b/lib/pangea/pages/settings_subscription/settings_subscription_view.dart index 5e0d1da3ad..9d9f21bf73 100644 --- a/lib/pangea/pages/settings_subscription/settings_subscription_view.dart +++ b/lib/pangea/pages/settings_subscription/settings_subscription_view.dart @@ -13,6 +13,44 @@ class SettingsSubscriptionView extends StatelessWidget { @override Widget build(BuildContext context) { + final List managementButtons = [ + if (controller.currentSubscriptionAvailable) + ListTile( + title: Text(L10n.of(context)!.currentSubscription), + subtitle: Text(controller.currentSubscriptionTitle), + trailing: Text(controller.currentSubscriptionPrice), + ), + Column( + children: [ + ListTile( + title: Text(L10n.of(context)!.cancelSubscription), + enabled: controller.showManagementOptions, + onTap: () => controller.launchMangementUrl( + ManagementOption.cancel, + ), + trailing: const Icon(Icons.cancel_outlined), + ), + const Divider(height: 1), + ListTile( + title: Text(L10n.of(context)!.paymentMethod), + trailing: const Icon(Icons.credit_card), + onTap: () => controller.launchMangementUrl( + ManagementOption.paymentMethod, + ), + enabled: controller.showManagementOptions, + ), + ListTile( + title: Text(L10n.of(context)!.paymentHistory), + trailing: const Icon(Icons.keyboard_arrow_right_outlined), + onTap: () => controller.launchMangementUrl( + ManagementOption.history, + ), + enabled: controller.showManagementOptions, + ), + ], + ), + ]; + return Scaffold( appBar: AppBar( centerTitle: true, @@ -23,53 +61,19 @@ class SettingsSubscriptionView extends StatelessWidget { body: ListTileTheme( iconColor: Theme.of(context).textTheme.bodyLarge!.color, child: MaxWidthBody( - child: !(controller.subscriptionController.isSubscribed) - ? ChangeSubscription(controller: controller) - : Column( - children: [ - if (controller.currentSubscriptionAvailable) - ListTile( - title: Text(L10n.of(context)!.currentSubscription), - subtitle: Text(controller.currentSubscriptionTitle), - trailing: Text(controller.currentSubscriptionPrice), - ), - Column( - children: [ - ListTile( - title: Text(L10n.of(context)!.cancelSubscription), - enabled: controller.showManagementOptions, - onTap: () => controller.launchMangementUrl( - ManagementOption.cancel, - ), - trailing: const Icon(Icons.cancel_outlined), - ), - const Divider(height: 1), - ListTile( - title: Text(L10n.of(context)!.paymentMethod), - trailing: const Icon(Icons.credit_card), - onTap: () => controller.launchMangementUrl( - ManagementOption.paymentMethod, - ), - enabled: controller.showManagementOptions, - ), - ListTile( - title: Text(L10n.of(context)!.paymentHistory), - trailing: - const Icon(Icons.keyboard_arrow_right_outlined), - onTap: () => controller.launchMangementUrl( - ManagementOption.history, - ), - enabled: controller.showManagementOptions, - ), - ], - ), - const SizedBox(height: 50), - if (!(controller.showManagementOptions)) - ManagementNotAvailableWarning( - controller: controller, - ), - ], + child: Column( + children: [ + if (controller.subscriptionController.isSubscribed && + !controller.showManagementOptions) + ManagementNotAvailableWarning( + controller: controller, ), + if (!(controller.subscriptionController.isSubscribed) || + controller.isNewUserTrial) + ChangeSubscription(controller: controller), + if (controller.showManagementOptions) ...managementButtons, + ], + ), ), ), ); diff --git a/lib/pangea/repo/user_repo.dart b/lib/pangea/repo/user_repo.dart index 70ab06704a..8f3b5a67f5 100644 --- a/lib/pangea/repo/user_repo.dart +++ b/lib/pangea/repo/user_repo.dart @@ -13,6 +13,7 @@ import '../network/urls.dart'; class PUserRepo { static Future repoCreatePangeaUser({ required String userID, + required String dob, required fullName, required String matrixAccessToken, }) async { @@ -24,6 +25,7 @@ class PUserRepo { final Map body = { ModelKey.userFullName: fullName, ModelKey.userPangeaUserId: userID, + ModelKey.userDateOfBirth: dob, }; final Response res = await req.post( url: PApiUrls.createUser, diff --git a/lib/pangea/widgets/subscription/subscription_buttons.dart b/lib/pangea/widgets/subscription/subscription_buttons.dart index 9292e41a40..2af95056a3 100644 --- a/lib/pangea/widgets/subscription/subscription_buttons.dart +++ b/lib/pangea/widgets/subscription/subscription_buttons.dart @@ -40,7 +40,8 @@ class SubscriptionButtons extends StatelessWidget { selected: controller.selectedSubscription == subscription, selectedTileColor: Theme.of(context).colorScheme.secondary.withAlpha(16), - enabled: !subscription.isTrial || inTrialWindow, + enabled: (!subscription.isTrial || inTrialWindow) && + !controller.isCurrentSubscription(subscription), onTap: () { controller.selectSubscription(subscription); },