Skip to content

Commit

Permalink
Merge pull request #110 from pangeachat/usability-testing
Browse files Browse the repository at this point in the history
refresh button tooltip + message explaining archive, direct chat with…
  • Loading branch information
ggurdin authored Mar 11, 2024
2 parents bc3a942 + 1623bdf commit 1f08188
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 77 deletions.
5 changes: 3 additions & 2 deletions assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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"
}
5 changes: 3 additions & 2 deletions assets/l10n/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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"
}
40 changes: 28 additions & 12 deletions lib/pages/chat_details/chat_details_view.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand Down
23 changes: 18 additions & 5 deletions lib/pages/chat_list/space_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,25 @@ class _SpaceViewState extends State<SpaceView> {
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(
Expand Down
29 changes: 22 additions & 7 deletions lib/pages/settings/settings_view.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions lib/pangea/config/environment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
1 change: 1 addition & 0 deletions lib/pangea/controllers/user_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SubscriptionManagementController extends State<SubscriptionManagement> {
"";

bool get showManagementOptions {
if (!currentSubscriptionAvailable) {
if (!currentSubscriptionAvailable || isNewUserTrial) {
return false;
}
if (subscriptionController.subscription!.purchasedOnWeb) {
Expand All @@ -102,7 +102,9 @@ class SubscriptionManagementController extends State<SubscriptionManagement> {
context,
isPromo: isPromo,
);
setState(() {});
setState(() {
selectedSubscription = null;
});
} catch (err) {
showOkAlertDialog(
context: context,
Expand Down Expand Up @@ -164,6 +166,11 @@ class SubscriptionManagementController extends State<SubscriptionManagement> {
setState(() => selectedSubscription = subscription);
}

bool isCurrentSubscription(SubscriptionDetails subscription) =>
subscriptionController.subscription?.currentSubscription ==
subscription ||
isNewUserTrial && subscription.isTrial;

@override
Widget build(BuildContext context) => SettingsSubscriptionView(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,44 @@ class SettingsSubscriptionView extends StatelessWidget {

@override
Widget build(BuildContext context) {
final List<Widget> 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,
Expand All @@ -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,
],
),
),
),
);
Expand Down
2 changes: 2 additions & 0 deletions lib/pangea/repo/user_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '../network/urls.dart';
class PUserRepo {
static Future<PUserModel> repoCreatePangeaUser({
required String userID,
required String dob,
required fullName,
required String matrixAccessToken,
}) async {
Expand All @@ -24,6 +25,7 @@ class PUserRepo {
final Map<String, dynamic> body = {
ModelKey.userFullName: fullName,
ModelKey.userPangeaUserId: userID,
ModelKey.userDateOfBirth: dob,
};
final Response res = await req.post(
url: PApiUrls.createUser,
Expand Down
3 changes: 2 additions & 1 deletion lib/pangea/widgets/subscription/subscription_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down

0 comments on commit 1f08188

Please sign in to comment.