fluffychat merge
This commit is contained in:
commit
61b239e37f
3 changed files with 149 additions and 97 deletions
|
|
@ -31,6 +31,7 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
|||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/utils/show_scaffold_dialog.dart';
|
||||
import 'package:fluffychat/utils/show_update_snackbar.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_modal_action_popup.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||
|
|
@ -139,54 +140,99 @@ class ChatListController extends State<ChatList>
|
|||
});
|
||||
context.go("/rooms");
|
||||
}
|
||||
|
||||
/// show alert dialog prompting user to accept invite or reject invite
|
||||
Future<void> showInviteDialog(Room room) async {
|
||||
final acceptInvite = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).youreInvited,
|
||||
message: room.isSpace
|
||||
? L10n.of(context).invitedToSpace(room.name, room.creatorId ?? "???")
|
||||
: L10n.of(context).invitedToChat(room.name, room.creatorId ?? "???"),
|
||||
okLabel: L10n.of(context).accept,
|
||||
cancelLabel: L10n.of(context).decline,
|
||||
);
|
||||
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
if (acceptInvite == OkCancelResult.ok) {
|
||||
await room.join();
|
||||
context.go(
|
||||
room.isSpace ? "/rooms?spaceId=${room.id}" : "/rooms/${room.id}",
|
||||
);
|
||||
return;
|
||||
}
|
||||
await room.leave();
|
||||
},
|
||||
);
|
||||
}
|
||||
// Pangea#
|
||||
|
||||
void onChatTap(Room room) async {
|
||||
if (room.membership == Membership.invite) {
|
||||
// #Pangea
|
||||
await showInviteDialog(room);
|
||||
return;
|
||||
// final joinResult = await showFutureLoadingDialog(
|
||||
// context: context,
|
||||
// future: () async {
|
||||
// final waitForRoom = room.client.waitForRoomInSync(
|
||||
// room.id,
|
||||
// join: true,
|
||||
// );
|
||||
// await room.join();
|
||||
// await waitForRoom;
|
||||
// },
|
||||
// exceptionContext: ExceptionContext.joinRoom,
|
||||
// );
|
||||
// if (joinResult.error != null) return;
|
||||
// Pangea#
|
||||
final theme = Theme.of(context);
|
||||
final inviteEvent = room.getState(
|
||||
EventTypes.RoomMember,
|
||||
room.client.userID!,
|
||||
);
|
||||
final matrixLocals = MatrixLocals(L10n.of(context));
|
||||
final action = await showAdaptiveDialog<InviteAction>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog.adaptive(
|
||||
title: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 256),
|
||||
child: Center(
|
||||
child: Text(
|
||||
room.getLocalizedDisplayname(matrixLocals),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
content: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 256, maxHeight: 256),
|
||||
child: Text(
|
||||
inviteEvent == null
|
||||
? L10n.of(context).inviteForMe
|
||||
: inviteEvent.content.tryGet<String>('reason') ??
|
||||
L10n.of(context).youInvitedBy(
|
||||
room
|
||||
.unsafeGetUserFromMemoryOrFallback(
|
||||
inviteEvent.senderId,
|
||||
)
|
||||
.calcDisplayname(i18n: matrixLocals),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
AdaptiveDialogAction(
|
||||
onPressed: () => Navigator.of(context).pop(InviteAction.accept),
|
||||
bigButtons: true,
|
||||
child: Text(L10n.of(context).accept),
|
||||
),
|
||||
AdaptiveDialogAction(
|
||||
onPressed: () => Navigator.of(context).pop(InviteAction.decline),
|
||||
bigButtons: true,
|
||||
child: Text(
|
||||
L10n.of(context).decline,
|
||||
style: TextStyle(color: theme.colorScheme.error),
|
||||
),
|
||||
),
|
||||
AdaptiveDialogAction(
|
||||
onPressed: () => Navigator.of(context).pop(InviteAction.block),
|
||||
bigButtons: true,
|
||||
child: Text(
|
||||
L10n.of(context).block,
|
||||
style: TextStyle(color: theme.colorScheme.error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
switch (action) {
|
||||
case null:
|
||||
return;
|
||||
case InviteAction.accept:
|
||||
break;
|
||||
case InviteAction.decline:
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.leave(),
|
||||
);
|
||||
return;
|
||||
case InviteAction.block:
|
||||
final userId = inviteEvent?.senderId;
|
||||
context.go('/rooms/settings/security/ignorelist', extra: userId);
|
||||
return;
|
||||
}
|
||||
if (!mounted) return;
|
||||
final joinResult = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
final waitForRoom = room.client.waitForRoomInSync(
|
||||
room.id,
|
||||
join: true,
|
||||
);
|
||||
await room.join();
|
||||
await waitForRoom;
|
||||
},
|
||||
exceptionContext: ExceptionContext.joinRoom,
|
||||
);
|
||||
if (joinResult.error != null) return;
|
||||
}
|
||||
|
||||
if (room.membership == Membership.ban) {
|
||||
|
|
@ -531,7 +577,6 @@ class ChatListController extends State<ChatList>
|
|||
spaceId,
|
||||
);
|
||||
|
||||
// #Pangea
|
||||
final String? justInputtedCode =
|
||||
MatrixState.pangeaController.classController.justInputtedCode();
|
||||
final newSpaceCode = space?.classCode;
|
||||
|
|
@ -849,24 +894,6 @@ class ChatListController extends State<ChatList>
|
|||
),
|
||||
// Pangea#
|
||||
],
|
||||
if (room.membership == Membership.invite)
|
||||
PopupMenuItem(
|
||||
value: ChatContextAction.block,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.block_outlined,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
L10n.of(context).block,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: ChatContextAction.leave,
|
||||
child: Row(
|
||||
|
|
@ -1075,10 +1102,6 @@ class ChatListController extends State<ChatList>
|
|||
}
|
||||
return;
|
||||
// Pangea#
|
||||
case ChatContextAction.block:
|
||||
final userId =
|
||||
room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId;
|
||||
context.go('/rooms/settings/security/ignorelist', extra: userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1160,34 +1183,34 @@ class ChatListController extends State<ChatList>
|
|||
});
|
||||
|
||||
// #Pangea
|
||||
// if (client.userDeviceKeys[client.userID!]?.deviceKeys.values
|
||||
// .any((device) => !device.verified && !device.blocked) ??
|
||||
// false) {
|
||||
// late final ScaffoldFeatureController controller;
|
||||
// final theme = Theme.of(context);
|
||||
// controller = ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// duration: const Duration(seconds: 15),
|
||||
// showCloseIcon: true,
|
||||
// backgroundColor: theme.colorScheme.errorContainer,
|
||||
// closeIconColor: theme.colorScheme.onErrorContainer,
|
||||
// content: Text(
|
||||
// L10n.of(context).oneOfYourDevicesIsNotVerified,
|
||||
// style: TextStyle(
|
||||
// color: theme.colorScheme.onErrorContainer,
|
||||
// if (client.userDeviceKeys[client.userID!]?.deviceKeys.values
|
||||
// .any((device) => !device.verified && !device.blocked) ??
|
||||
// false) {
|
||||
// late final ScaffoldFeatureController controller;
|
||||
// final theme = Theme.of(context);
|
||||
// controller = ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// duration: const Duration(seconds: 15),
|
||||
// showCloseIcon: true,
|
||||
// backgroundColor: theme.colorScheme.errorContainer,
|
||||
// closeIconColor: theme.colorScheme.onErrorContainer,
|
||||
// content: Text(
|
||||
// L10n.of(context).oneOfYourDevicesIsNotVerified,
|
||||
// style: TextStyle(
|
||||
// color: theme.colorScheme.onErrorContainer,
|
||||
// ),
|
||||
// ),
|
||||
// action: SnackBarAction(
|
||||
// onPressed: () {
|
||||
// controller.close();
|
||||
// router.go('/rooms/settings/devices');
|
||||
// },
|
||||
// textColor: theme.colorScheme.onErrorContainer,
|
||||
// label: L10n.of(context).settings,
|
||||
// ),
|
||||
// ),
|
||||
// action: SnackBarAction(
|
||||
// onPressed: () {
|
||||
// controller.close();
|
||||
// router.go('/rooms/settings/devices');
|
||||
// },
|
||||
// textColor: theme.colorScheme.onErrorContainer,
|
||||
// label: L10n.of(context).settings,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// Pangea#
|
||||
}
|
||||
|
||||
|
|
@ -1329,9 +1352,10 @@ enum ChatContextAction {
|
|||
mute,
|
||||
leave,
|
||||
addToSpace,
|
||||
block,
|
||||
// #Pangea
|
||||
removeFromSpace,
|
||||
delete,
|
||||
// Pangea#
|
||||
}
|
||||
|
||||
enum InviteAction { accept, decline, block }
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ class ImageViewerController extends State<ImageViewer> {
|
|||
|
||||
void onKeyEvent(KeyEvent event) {
|
||||
switch (event.logicalKey) {
|
||||
case LogicalKeyboardKey.arrowLeft:
|
||||
case LogicalKeyboardKey.arrowUp:
|
||||
if (canGoBack) prevImage();
|
||||
break;
|
||||
case LogicalKeyboardKey.arrowRight:
|
||||
case LogicalKeyboardKey.arrowDown:
|
||||
if (canGoNext) nextImage();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,40 @@ import 'package:go_router/go_router.dart';
|
|||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../common/utils/error_handler.dart';
|
||||
|
||||
Future<void> _showInviteDialog(Room room, BuildContext context) async {
|
||||
final acceptInvite = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).youreInvited,
|
||||
message: room.isSpace
|
||||
? L10n.of(context).invitedToSpace(room.name, room.creatorId ?? "???")
|
||||
: L10n.of(context).invitedToChat(room.name, room.creatorId ?? "???"),
|
||||
okLabel: L10n.of(context).accept,
|
||||
cancelLabel: L10n.of(context).decline,
|
||||
);
|
||||
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
if (acceptInvite == OkCancelResult.ok) {
|
||||
await room.join();
|
||||
context.go(
|
||||
room.isSpace ? "/rooms?spaceId=${room.id}" : "/rooms/${room.id}",
|
||||
);
|
||||
return;
|
||||
}
|
||||
await room.leave();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// ignore: curly_braces_in_flow_control_structures
|
||||
void chatListHandleSpaceTap(
|
||||
BuildContext context,
|
||||
|
|
@ -57,7 +85,7 @@ void chatListHandleSpaceTap(
|
|||
justInputtedCode == space.classCode) {
|
||||
// do nothing
|
||||
} else {
|
||||
controller.showInviteDialog(space);
|
||||
_showInviteDialog(space, context);
|
||||
}
|
||||
break;
|
||||
case Membership.leave:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue