Separate archive and leave buttons
This commit is contained in:
parent
14c25c0ec0
commit
1bce016140
7 changed files with 210 additions and 66 deletions
|
|
@ -3724,7 +3724,7 @@
|
|||
},
|
||||
"noTeachersFound": "No teachers found to report to",
|
||||
"pleaseEnterANumber": "Please enter a number greater than 0",
|
||||
"archiveRoomDescription": "The chat will be moved to the archive. Other users will be able to see that you have left the chat.",
|
||||
"archiveRoomDescription": "The chat will be moved to the archive for all participants.",
|
||||
"roomUpgradeDescription": "The chat will then be recreated with the new room version. All participants will be notified that they need to switch to the new chat. You can find out more about room versions at https://spec.matrix.org/latest/rooms/",
|
||||
"removeDevicesDescription": "You will be logged out of this device and will no longer be able to receive messages.",
|
||||
"banUserDescription": "The user will be banned from the chat and will not be able to enter the chat again until they are unbanned.",
|
||||
|
|
@ -3963,5 +3963,6 @@
|
|||
"studentAnalyticsNotAvailable": "Student data not currently available",
|
||||
"roomDataMissing": "Some data may be missing from rooms in which you are not a member.",
|
||||
"updatePhoneOS": "You may need to update your device's OS version.",
|
||||
"wordsPerMinute": "Words per minute"
|
||||
"wordsPerMinute": "Words per minute",
|
||||
"leaveRoomDescription": "The chat will be moved to the archive. Other users will be able to see that you have left the chat."
|
||||
}
|
||||
|
|
@ -228,6 +228,18 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
context.go('/rooms');
|
||||
}
|
||||
|
||||
// #Pangea
|
||||
void archiveChat() async {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: room
|
||||
.leave, // Edit - Add room.archive method in pangea_room_extension.dart
|
||||
);
|
||||
if (success.error != null) return;
|
||||
context.go('/rooms');
|
||||
}
|
||||
// Pangea#
|
||||
|
||||
EmojiPickerType emojiPickerType = EmojiPickerType.keyboard;
|
||||
|
||||
// #Pangea
|
||||
|
|
|
|||
|
|
@ -116,8 +116,10 @@ class ChatView extends StatelessWidget {
|
|||
// #Pangea
|
||||
} else {
|
||||
return [
|
||||
ChatSettingsPopupMenu(controller.room,
|
||||
(!controller.room.isDirectChat && !controller.room.isArchived)),
|
||||
ChatSettingsPopupMenu(
|
||||
controller.room,
|
||||
(!controller.room.isDirectChat && !controller.room.isArchived),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -361,6 +363,29 @@ class ChatView extends StatelessWidget {
|
|||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
// #Pangea
|
||||
if (controller.room.isRoomAdmin)
|
||||
TextButton.icon(
|
||||
style: TextButton.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets.all(
|
||||
16,
|
||||
),
|
||||
foregroundColor:
|
||||
Theme.of(context)
|
||||
.colorScheme
|
||||
.error,
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.archive_outlined,
|
||||
),
|
||||
onPressed:
|
||||
controller.archiveChat,
|
||||
label: Text(
|
||||
L10n.of(context)!.archive,
|
||||
),
|
||||
),
|
||||
// Pangea#
|
||||
TextButton.icon(
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.all(
|
||||
|
|
@ -372,7 +397,10 @@ class ChatView extends StatelessWidget {
|
|||
.error,
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.archive_outlined,
|
||||
// #Pangea
|
||||
// Icons.archive_outlined,
|
||||
Icons.arrow_forward,
|
||||
// Pangea#
|
||||
),
|
||||
onPressed: controller.leaveChat,
|
||||
label: Text(
|
||||
|
|
|
|||
|
|
@ -522,52 +522,101 @@ class ChatDetailsView extends StatelessWidget {
|
|||
),
|
||||
const Divider(height: 1),
|
||||
if (!room.isDirectChat)
|
||||
ListTile(
|
||||
title: Text(
|
||||
room.isSpace
|
||||
? L10n.of(context)!.archiveSpace
|
||||
: L10n.of(context)!.archive,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
if (room.isRoomAdmin)
|
||||
ListTile(
|
||||
title: Text(
|
||||
room.isSpace
|
||||
? L10n.of(context)!.archiveSpace
|
||||
: L10n.of(context)!.archive,
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor: iconColor,
|
||||
child: const Icon(
|
||||
Icons.archive_outlined,
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor: iconColor,
|
||||
child: const Icon(
|
||||
Icons.archive_outlined,
|
||||
),
|
||||
),
|
||||
),
|
||||
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(
|
||||
onTap: () async {
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
future: () async {
|
||||
room.isSpace
|
||||
? await archiveSpace(
|
||||
room,
|
||||
Matrix.of(context).client,
|
||||
)
|
||||
: await room.leave();
|
||||
},
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message:
|
||||
L10n.of(context)!.archiveRoomDescription,
|
||||
);
|
||||
if (success.error == null) {
|
||||
context.go('/rooms');
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
room.isSpace
|
||||
? await archiveSpace(
|
||||
// Edit - contents
|
||||
room,
|
||||
Matrix.of(context).client,
|
||||
)
|
||||
: await room
|
||||
.leave(); // Edit - archive, not leave
|
||||
},
|
||||
);
|
||||
if (success.error == null) {
|
||||
context.go('/rooms');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!.leave,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor: iconColor,
|
||||
child: const Icon(
|
||||
Icons.arrow_forward,
|
||||
),
|
||||
),
|
||||
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, // Edit
|
||||
);
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
room.isSpace
|
||||
? await archiveSpace(
|
||||
// Edit = leaveSpace
|
||||
room,
|
||||
Matrix.of(context).client,
|
||||
)
|
||||
: await room.leave();
|
||||
},
|
||||
);
|
||||
if (success.error == null) {
|
||||
context.go('/rooms');
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
if (room.isRoomAdmin && !room.isDirectChat)
|
||||
SwitchListTile.adaptive(
|
||||
activeColor: AppConfig.activeToggleColor,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
||||
import 'package:fluffychat/pages/chat_list/client_chooser_button.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
|
|
@ -168,14 +170,30 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||
tooltip: L10n.of(context)!.toggleMuted,
|
||||
onPressed: controller.toggleMuted,
|
||||
),
|
||||
IconButton(
|
||||
// #Pangea
|
||||
// icon: const Icon(Icons.delete_outlined),
|
||||
icon: const Icon(Icons.archive_outlined),
|
||||
// #Pangea
|
||||
if (controller.selectedRoomIds.length == 1 &&
|
||||
(Matrix.of(context)
|
||||
.client
|
||||
.getRoomById(controller.selectedRoomIds.single)
|
||||
?.isRoomAdmin ??
|
||||
false))
|
||||
// Pangea#
|
||||
tooltip: L10n.of(context)!.archive,
|
||||
onPressed: controller.archiveAction,
|
||||
IconButton(
|
||||
// #Pangea
|
||||
// icon: const Icon(Icons.delete_outlined),
|
||||
icon: const Icon(Icons.archive_outlined),
|
||||
// Pangea#
|
||||
tooltip: L10n.of(context)!.archive,
|
||||
onPressed: controller.archiveAction,
|
||||
),
|
||||
// #Pangea
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
tooltip: L10n.of(context)!.leave,
|
||||
onPressed:
|
||||
controller.archiveAction, // Edit - make leaveAction
|
||||
),
|
||||
// Pangea#
|
||||
]
|
||||
: null,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
if (room!.isUnread) {
|
||||
await room.markUnread(false);
|
||||
}
|
||||
await room.leave();
|
||||
await room.leave(); // Edit - use leaveAction?
|
||||
if (Matrix.of(context).activeRoomId == room.id) {
|
||||
context.go('/rooms');
|
||||
}
|
||||
|
|
@ -306,7 +306,8 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
);
|
||||
break;
|
||||
// #Pangea
|
||||
case SpaceChildContextAction.archive:
|
||||
case SpaceChildContextAction
|
||||
.archive: // Edit - change behavior to archive space for all users
|
||||
widget.controller.cancelAction();
|
||||
// #Pangea
|
||||
if (room == null) return;
|
||||
|
|
|
|||
|
|
@ -85,20 +85,31 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
),
|
||||
// #Pangea
|
||||
if (!widget.room.isArchived)
|
||||
// Pangea#
|
||||
PopupMenuItem<String>(
|
||||
value: 'leave',
|
||||
child: Row(
|
||||
children: [
|
||||
// #Pangea
|
||||
// const Icon(Icons.delete_outlined),
|
||||
const Icon(Icons.arrow_forward),
|
||||
// Pangea#
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.leave),
|
||||
],
|
||||
if (widget.room.isRoomAdmin)
|
||||
PopupMenuItem<String>(
|
||||
value: 'archive',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.archive_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.archive),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Pangea#
|
||||
PopupMenuItem<String>(
|
||||
value: 'leave',
|
||||
child: Row(
|
||||
children: [
|
||||
// #Pangea
|
||||
// const Icon(Icons.delete_outlined),
|
||||
const Icon(Icons.arrow_forward),
|
||||
// Pangea#
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.leave),
|
||||
],
|
||||
),
|
||||
),
|
||||
// #Pangea
|
||||
if (classSettings != null)
|
||||
PopupMenuItem<String>(
|
||||
|
|
@ -167,6 +178,29 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
PopupMenuButton(
|
||||
onSelected: (String choice) async {
|
||||
switch (choice) {
|
||||
// #Pangea
|
||||
case 'archive':
|
||||
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, // Edit - contents
|
||||
);
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
widget.room.leave(), // Edit - archive, not leave
|
||||
);
|
||||
if (success.error == null) {
|
||||
context.go('/rooms');
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Pangea#
|
||||
case 'leave':
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
|
|
@ -174,7 +208,8 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message: L10n.of(context)!.archiveRoomDescription,
|
||||
message: L10n.of(context)!
|
||||
.archiveRoomDescription, // Edit - leave, not archive
|
||||
);
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue