fluffychat merge - resolve conflicts
commit
40768f9859
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,125 +0,0 @@
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../config/themes.dart';
|
||||
import 'chat_list.dart';
|
||||
|
||||
class StartChatFloatingActionButton extends StatelessWidget {
|
||||
final ActiveFilter activeFilter;
|
||||
final ValueNotifier<bool> scrolledToTop;
|
||||
final bool roomsIsEmpty;
|
||||
// #Pangea
|
||||
final ChatListController controller;
|
||||
// Pangea#
|
||||
final void Function() createNewSpace;
|
||||
|
||||
const StartChatFloatingActionButton({
|
||||
super.key,
|
||||
required this.activeFilter,
|
||||
required this.scrolledToTop,
|
||||
required this.roomsIsEmpty,
|
||||
required this.createNewSpace,
|
||||
// #Pangea
|
||||
required this.controller,
|
||||
// Pangea#
|
||||
});
|
||||
|
||||
void _onPressed(BuildContext context) async {
|
||||
//#Pangea
|
||||
if (controller.activeSpaceId != null) {
|
||||
context.go(
|
||||
'/rooms/newgroup${controller.activeSpaceId != null ? '?spaceId=${controller.activeSpaceId}' : ''}',
|
||||
);
|
||||
return;
|
||||
}
|
||||
//Pangea#
|
||||
switch (activeFilter) {
|
||||
case ActiveFilter.allChats:
|
||||
case ActiveFilter.messages:
|
||||
// #Pangea
|
||||
// context.go('/rooms/newprivatechat');
|
||||
// break;
|
||||
// Pangea#
|
||||
case ActiveFilter.groups:
|
||||
// #Pangea
|
||||
// context.go('/rooms/newgroup');
|
||||
context.go(
|
||||
'/rooms/newgroup${controller.activeSpaceId != null ? '?spaceId=${controller.activeSpaceId}' : ''}',
|
||||
);
|
||||
// Pangea#
|
||||
break;
|
||||
case ActiveFilter.spaces:
|
||||
// #Pangea
|
||||
// createNewSpace();
|
||||
context.go('/rooms/newspace');
|
||||
// Pangea#
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IconData get icon {
|
||||
// #Pangea
|
||||
if (controller.activeSpaceId != null) {
|
||||
return Icons.group_add_outlined;
|
||||
}
|
||||
// Pangea#
|
||||
switch (activeFilter) {
|
||||
case ActiveFilter.allChats:
|
||||
case ActiveFilter.messages:
|
||||
// #Pangea
|
||||
// return Icons.add_outlined;
|
||||
// Pangea#
|
||||
case ActiveFilter.groups:
|
||||
return Icons.group_add_outlined;
|
||||
case ActiveFilter.spaces:
|
||||
return Icons.workspaces_outlined;
|
||||
}
|
||||
}
|
||||
|
||||
String getLabel(BuildContext context) {
|
||||
// #Pangea
|
||||
if (controller.activeSpaceId != null) {
|
||||
return L10n.of(context)!.newGroup;
|
||||
}
|
||||
// Pangea#
|
||||
switch (activeFilter) {
|
||||
case ActiveFilter.allChats:
|
||||
case ActiveFilter.messages:
|
||||
return roomsIsEmpty
|
||||
? L10n.of(context)!.startFirstChat
|
||||
: L10n.of(context)!.newChat;
|
||||
case ActiveFilter.groups:
|
||||
return L10n.of(context)!.newGroup;
|
||||
case ActiveFilter.spaces:
|
||||
return L10n.of(context)!.newSpace;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<bool>(
|
||||
valueListenable: scrolledToTop,
|
||||
builder: (context, scrolledToTop, _) => AnimatedSize(
|
||||
duration: FluffyThemes.animationDuration,
|
||||
curve: FluffyThemes.animationCurve,
|
||||
clipBehavior: Clip.none,
|
||||
child: scrolledToTop
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: () => _onPressed(context),
|
||||
icon: Icon(icon),
|
||||
label: Text(
|
||||
getLabel(context),
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
)
|
||||
: FloatingActionButton(
|
||||
onPressed: () => _onPressed(context),
|
||||
child: Icon(icon),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,136 +0,0 @@
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:fluffychat/pages/chat/send_file_dialog.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.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';
|
||||
|
||||
void onChatTap(Room room, BuildContext context) async {
|
||||
if (room.membership == Membership.invite) {
|
||||
final inviterId =
|
||||
room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId;
|
||||
final inviteAction = await showModalActionSheet<InviteActions>(
|
||||
context: context,
|
||||
message: room.isDirectChat
|
||||
? L10n.of(context)!.invitePrivateChat
|
||||
: L10n.of(context)!.inviteGroupChat,
|
||||
title: room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
||||
actions: [
|
||||
SheetAction(
|
||||
key: InviteActions.accept,
|
||||
label: L10n.of(context)!.accept,
|
||||
icon: Icons.check_outlined,
|
||||
isDefaultAction: true,
|
||||
),
|
||||
SheetAction(
|
||||
key: InviteActions.decline,
|
||||
label: L10n.of(context)!.decline,
|
||||
icon: Icons.close_outlined,
|
||||
isDestructiveAction: true,
|
||||
),
|
||||
SheetAction(
|
||||
key: InviteActions.block,
|
||||
label: L10n.of(context)!.block,
|
||||
icon: Icons.block_outlined,
|
||||
isDestructiveAction: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
if (inviteAction == null) return;
|
||||
if (inviteAction == InviteActions.block) {
|
||||
context.go('/rooms/settings/security/ignorelist', extra: inviterId);
|
||||
return;
|
||||
}
|
||||
if (inviteAction == InviteActions.decline) {
|
||||
// #Pangea
|
||||
if (!room.isSpace &&
|
||||
room.membership == Membership.join &&
|
||||
room.isUnread) {
|
||||
await room.markUnread(false);
|
||||
}
|
||||
// Pangea#
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: room.leave,
|
||||
);
|
||||
return;
|
||||
}
|
||||
final joinResult = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
final waitForRoom = room.client.waitForRoomInSync(
|
||||
room.id,
|
||||
join: true,
|
||||
);
|
||||
if (await room.leaveIfFull()) {
|
||||
throw L10n.of(context)!.roomFull;
|
||||
}
|
||||
await room.join();
|
||||
await waitForRoom;
|
||||
},
|
||||
);
|
||||
if (joinResult.error != null) return;
|
||||
}
|
||||
|
||||
if (room.membership == Membership.ban) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(L10n.of(context)!.youHaveBeenBannedFromThisChat),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (room.membership == Membership.leave) {
|
||||
context.go('/rooms/archive/${room.id}');
|
||||
return;
|
||||
}
|
||||
|
||||
// Share content into this room
|
||||
final shareContent = Matrix.of(context).shareContent;
|
||||
if (shareContent != null) {
|
||||
final shareFile = shareContent.tryGet<MatrixFile>('file');
|
||||
if (shareContent.tryGet<String>('msgtype') == 'chat.fluffy.shared_file' &&
|
||||
shareFile != null) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => SendFileDialog(
|
||||
files: [shareFile],
|
||||
room: room,
|
||||
),
|
||||
);
|
||||
Matrix.of(context).shareContent = null;
|
||||
} else {
|
||||
final consent = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context)!.forward,
|
||||
message: L10n.of(context)!.forwardMessageTo(
|
||||
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
||||
),
|
||||
okLabel: L10n.of(context)!.forward,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
);
|
||||
if (consent == OkCancelResult.cancel) {
|
||||
Matrix.of(context).shareContent = null;
|
||||
return;
|
||||
}
|
||||
if (consent == OkCancelResult.ok) {
|
||||
room.sendEvent(shareContent);
|
||||
Matrix.of(context).shareContent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.go('/rooms/${room.id}');
|
||||
}
|
||||
|
||||
enum InviteActions {
|
||||
accept,
|
||||
decline,
|
||||
block,
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
||||
import 'package:fluffychat/pages/chat_list/chat_list_header.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A wrapper around ChatListHeader to allow rebuilding on state changes.
|
||||
/// Prevents having to rebuild the entire ChatList when a single item changes.
|
||||
class ChatListHeaderWrapper extends StatefulWidget {
|
||||
final ChatListController controller;
|
||||
final bool globalSearch;
|
||||
|
||||
const ChatListHeaderWrapper({
|
||||
super.key,
|
||||
required this.controller,
|
||||
this.globalSearch = true,
|
||||
});
|
||||
|
||||
@override
|
||||
ChatListHeaderWrapperState createState() => ChatListHeaderWrapperState();
|
||||
}
|
||||
|
||||
class ChatListHeaderWrapperState extends State<ChatListHeaderWrapper> {
|
||||
StreamSubscription? stateSub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
stateSub = widget.controller.selectionsStream.stream.listen((roomID) {
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
stateSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChatListHeader(
|
||||
controller: widget.controller,
|
||||
globalSearch: widget.globalSearch,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
||||
import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
|
||||
import 'package:fluffychat/pages/chat_list/utils/on_chat_tap.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
/// A wrapper around ChatListItem to allow rebuilding on state changes.
|
||||
/// Prevents having to rebuild the entire ChatList when a single item changes.
|
||||
class ChatListItemWrapper extends StatefulWidget {
|
||||
final Room room;
|
||||
final bool activeChat;
|
||||
final void Function()? onForget;
|
||||
final String? filter;
|
||||
final ChatListController controller;
|
||||
|
||||
final void Function()? onLongPress;
|
||||
final void Function()? onTap;
|
||||
|
||||
const ChatListItemWrapper(
|
||||
this.room, {
|
||||
this.activeChat = false,
|
||||
this.onForget,
|
||||
this.filter,
|
||||
required this.controller,
|
||||
this.onLongPress,
|
||||
this.onTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
ChatListItemWrapperState createState() => ChatListItemWrapperState();
|
||||
}
|
||||
|
||||
class ChatListItemWrapperState extends State<ChatListItemWrapper> {
|
||||
StreamSubscription? stateSub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
stateSub = widget.controller.selectionsStream.stream.listen((roomID) {
|
||||
if (roomID == widget.room.id) {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
stateSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChatListItem(
|
||||
widget.room,
|
||||
activeChat: widget.activeChat,
|
||||
selected: widget.controller.selectedRoomIds.contains(widget.room.id),
|
||||
onTap: widget.onTap ??
|
||||
(widget.controller.selectMode == SelectMode.select
|
||||
? () => widget.controller.toggleSelection(widget.room.id)
|
||||
: () => onChatTap(widget.room, context)),
|
||||
onLongPress: widget.onLongPress ??
|
||||
() => widget.controller.toggleSelection(widget.room.id),
|
||||
onForget: widget.onForget,
|
||||
filter: widget.filter,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue