mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-24 11:04:10 +01:00
acb8bfee8a
Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
111 lines
4.0 KiB
Dart
111 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
|
|
import 'package:vrouter/vrouter.dart';
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
|
import 'package:fluffychat/config/themes.dart';
|
|
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
|
import '../../widgets/matrix.dart';
|
|
import 'chat_list_body.dart';
|
|
import 'chat_list_header.dart';
|
|
import 'navigation_rail.dart';
|
|
import 'start_chat_fab.dart';
|
|
|
|
class ChatListView extends StatelessWidget {
|
|
final ChatListController controller;
|
|
|
|
const ChatListView(this.controller, {Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
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();
|
|
redirector.stopRedirection();
|
|
return;
|
|
}
|
|
if (controller.activeFilter !=
|
|
(AppConfig.separateChatTypes
|
|
? ActiveFilter.messages
|
|
: ActiveFilter.allChats)) {
|
|
controller
|
|
.onDestinationSelected(AppConfig.separateChatTypes ? 1 : 0);
|
|
redirector.stopRedirection();
|
|
return;
|
|
}
|
|
},
|
|
child: Row(
|
|
children: [
|
|
if (FluffyThemes.isColumnMode(context) &&
|
|
FluffyThemes.getDisplayNavigationRail(context) != null) ...[
|
|
ChatListNavigationRail(controller: controller),
|
|
Container(
|
|
color: Theme.of(context).dividerColor,
|
|
width: 1,
|
|
),
|
|
],
|
|
Expanded(
|
|
child: GestureDetector(
|
|
onTap: FocusManager.instance.primaryFocus?.unfocus,
|
|
excludeFromSemantics: true,
|
|
behavior: HitTestBehavior.translucent,
|
|
child: Scaffold(
|
|
appBar: ChatListHeader(controller: controller),
|
|
body: ChatListViewBody(controller),
|
|
bottomNavigationBar: controller.displayNavigationBar
|
|
? NavigationBar(
|
|
height: 64,
|
|
selectedIndex: controller.selectedIndex,
|
|
onDestinationSelected:
|
|
controller.onDestinationSelected,
|
|
destinations:
|
|
controller.getNavigationDestinations(context),
|
|
)
|
|
: null,
|
|
floatingActionButtonLocation:
|
|
controller.filteredRooms.isEmpty
|
|
? FloatingActionButtonLocation.centerFloat
|
|
: null,
|
|
floatingActionButton: selectMode == SelectMode.normal
|
|
? KeyBoardShortcuts(
|
|
keysToPress: {
|
|
LogicalKeyboardKey.controlLeft,
|
|
LogicalKeyboardKey.keyN
|
|
},
|
|
onKeysPressed: () =>
|
|
VRouter.of(context).to('/newprivatechat'),
|
|
helpLabel: L10n.of(context)!.newChat,
|
|
child: StartChatFloatingActionButton(
|
|
controller: controller,
|
|
),
|
|
)
|
|
: null,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
enum ChatListPopupMenuItemActions {
|
|
createGroup,
|
|
createSpace,
|
|
discover,
|
|
setStatus,
|
|
inviteContact,
|
|
settings,
|
|
}
|