chore: add separate button to end activity for all (#3727)
This commit is contained in:
parent
0e3d4fadf9
commit
34e1229835
4 changed files with 57 additions and 41 deletions
|
|
@ -5150,7 +5150,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"endActivityTitle": "I'm Done",
|
||||
"endActivityTitle": "I'm done",
|
||||
"endActivityDesc": "Did you complete the objectives?\nThis is your confirmation that you're stepping back from texting. But don’t worry, the fun continues in the chat! Feel free to hang out and enjoy the show until everyone clicks 'Done'.",
|
||||
"archiveToAnalytics": "Add to my Completed Activities",
|
||||
"activitySummaryError": "Activity summaries unavailable",
|
||||
|
|
@ -5193,5 +5193,6 @@
|
|||
}
|
||||
},
|
||||
"noDataFound": "No data found",
|
||||
"activityFinishedMessage": "All Finished!"
|
||||
"activityFinishedMessage": "All Finished!",
|
||||
"endForAll": "End for all"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import 'package:fluffychat/pages/chat/chat_app_bar_list_tile.dart';
|
|||
import 'package:fluffychat/pangea/activity_sessions/activity_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/activity_suggestions/activity_suggestions_constants.dart';
|
||||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
|
||||
class ActivityPinnedMessage extends StatefulWidget {
|
||||
|
|
@ -45,21 +46,18 @@ class ActivityPinnedMessageState extends State<ActivityPinnedMessage> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> _finishActivity() async {
|
||||
final resp = await showFutureLoadingDialog(
|
||||
Future<void> _finishActivity({bool forAll = false}) async {
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
await room.finishActivity();
|
||||
forAll
|
||||
? await room.finishActivityForAll()
|
||||
: await room.finishActivity();
|
||||
if (mounted) {
|
||||
_setShowDropdown(false);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (resp.isError) return;
|
||||
if (room.activityIsFinished) {
|
||||
await room.fetchSummaries();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -149,27 +147,54 @@ class ActivityPinnedMessageState extends State<ActivityPinnedMessage> {
|
|||
"${AppConfig.assetsBaseURL}/${ActivitySuggestionsConstants.endActivityAssetPath}",
|
||||
width: isColumnMode ? 240.0 : 120.0,
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
vertical: 8.0,
|
||||
),
|
||||
foregroundColor: theme.colorScheme.onSecondary,
|
||||
backgroundColor: theme.colorScheme.secondary,
|
||||
),
|
||||
onPressed: _finishActivity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
L10n.of(context).endActivityTitle,
|
||||
style: TextStyle(
|
||||
fontSize: isColumnMode ? 16.0 : 12.0,
|
||||
Row(
|
||||
spacing: 12.0,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
vertical: 8.0,
|
||||
),
|
||||
foregroundColor:
|
||||
theme.colorScheme.onSecondary,
|
||||
backgroundColor:
|
||||
theme.colorScheme.secondary,
|
||||
),
|
||||
onPressed: _finishActivity,
|
||||
child: Text(
|
||||
L10n.of(context).endActivityTitle,
|
||||
style: TextStyle(
|
||||
fontSize: isColumnMode ? 16.0 : 12.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (room.isRoomAdmin)
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
vertical: 8.0,
|
||||
),
|
||||
foregroundColor:
|
||||
theme.colorScheme.onErrorContainer,
|
||||
backgroundColor:
|
||||
theme.colorScheme.errorContainer,
|
||||
),
|
||||
onPressed: () =>
|
||||
_finishActivity(forAll: true),
|
||||
child: Text(
|
||||
L10n.of(context).endForAll,
|
||||
style: TextStyle(
|
||||
fontSize: isColumnMode ? 16.0 : 12.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import 'package:fluffychat/pangea/common/config/environment.dart';
|
|||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
|
||||
extension ActivityRoomExtension on Room {
|
||||
Future<void> sendActivityPlan(
|
||||
|
|
@ -71,11 +70,6 @@ extension ActivityRoomExtension on Room {
|
|||
}
|
||||
|
||||
Future<void> finishActivity() async {
|
||||
if (isRoomAdmin) {
|
||||
await _finishActivityForAll();
|
||||
return;
|
||||
}
|
||||
|
||||
final currentRoles = activityRoles ?? ActivityRolesModel.empty;
|
||||
final role = ownRole;
|
||||
if (role == null || role.isFinished) return;
|
||||
|
|
@ -90,7 +84,7 @@ extension ActivityRoomExtension on Room {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> _finishActivityForAll() async {
|
||||
Future<void> finishActivityForAll() async {
|
||||
final currentRoles = activityRoles ?? ActivityRolesModel.empty;
|
||||
currentRoles.finishAll();
|
||||
await client.setRoomStateWithKey(
|
||||
|
|
|
|||
|
|
@ -33,11 +33,7 @@ class LoadActivitySummaryWidgetState extends State<LoadActivitySummaryWidget> {
|
|||
// The summary state event is null
|
||||
// Wait for 5 seconds. If still null (or not loading), run request.
|
||||
if (_summaryEvent == null) {
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
|
||||
if (_summaryEvent == null || !_summaryEvent!.isLoading) {
|
||||
await widget.room.fetchSummaries();
|
||||
}
|
||||
await widget.room.fetchSummaries();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue