fluffychat/lib/pages/chat_list/chat_list_view.dart

66 lines
2.2 KiB
Dart
Raw Normal View History

2021-10-26 18:50:34 +02:00
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
2021-10-26 18:50:34 +02:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
2021-10-26 18:50:34 +02:00
import 'package:vrouter/vrouter.dart';
2021-11-09 21:32:16 +01:00
import 'package:fluffychat/pages/chat_list/chat_list.dart';
2022-07-07 18:50:13 +02:00
import 'package:fluffychat/pages/chat_list/chat_list_drawer.dart';
import 'package:fluffychat/widgets/connection_status_header.dart';
2021-10-26 18:50:34 +02:00
import '../../widgets/matrix.dart';
import 'chat_list_body.dart';
import 'chat_list_header.dart';
import 'start_chat_fab.dart';
2021-04-14 14:09:46 +02:00
2021-05-22 09:13:47 +02:00
class ChatListView extends StatelessWidget {
2021-04-14 14:09:46 +02:00
final ChatListController controller;
2022-01-29 12:35:03 +01:00
const ChatListView(this.controller, {Key? key}) : super(key: key);
2021-04-14 14:09:46 +02:00
@override
Widget build(BuildContext context) {
2022-01-29 12:35:03 +01:00
return StreamBuilder<Object?>(
stream: Matrix.of(context).onShareContentChanged.stream,
builder: (_, __) {
final selectMode = controller.selectMode;
return VWidgetGuard(
onSystemPop: (redirector) async {
final selMode = controller.selectMode;
if (selMode != SelectMode.normal) controller.cancelAction();
if (selMode == SelectMode.select) redirector.stopRedirection();
},
child: Scaffold(
appBar: ChatListHeader(controller: controller),
2022-07-07 18:50:13 +02:00
body: ChatListViewBody(controller),
drawer: ChatListDrawer(controller),
bottomNavigationBar: const ConnectionStatusHeader(),
floatingActionButton: selectMode == SelectMode.normal
2022-07-07 18:50:13 +02:00
? KeyBoardShortcuts(
child:
StartChatFloatingActionButton(controller: controller),
2022-07-07 18:50:13 +02:00
keysToPress: {
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.keyN
},
onKeysPressed: () =>
VRouter.of(context).to('/newprivatechat'),
helpLabel: L10n.of(context)!.newChat,
)
: null,
),
);
},
);
2021-04-14 14:09:46 +02:00
}
}
enum ChatListPopupMenuItemActions {
createGroup,
2021-08-01 08:05:40 +02:00
createSpace,
2021-04-14 14:09:46 +02:00
discover,
setStatus,
inviteContact,
settings,
}