2
0
mirror of https://gitlab.com/famedly/fluffychat.git synced 2024-12-27 16:42:37 +01:00
fluffychat/lib/pages/chat/chat_app_bar_title.dart

64 lines
2.3 KiB
Dart
Raw Normal View History

2021-12-13 09:40:53 +01:00
//@dart=2.12
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/pages/user_bottom_sheet/user_bottom_sheet.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
import 'package:fluffychat/utils/room_status_extension.dart';
import 'package:fluffychat/utils/stream_extension.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/matrix.dart';
class ChatAppBarTitle extends StatelessWidget {
final ChatController controller;
2021-12-13 09:40:53 +01:00
const ChatAppBarTitle(this.controller, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
if (controller.selectedEvents.isNotEmpty) {
return Text(controller.selectedEvents.length.toString());
}
2021-12-13 09:40:53 +01:00
final directChatMatrixID = controller.room.directChatMatrixID;
return ListTile(
2021-11-20 10:42:23 +01:00
leading: Avatar(
mxContent: controller.room.avatar,
name: controller.room.displayname,
),
contentPadding: EdgeInsets.zero,
2021-12-13 09:40:53 +01:00
onTap: directChatMatrixID != null
? () => showModalBottomSheet(
context: context,
builder: (c) => UserBottomSheet(
2021-12-13 09:40:53 +01:00
user: controller.room.getUserByMXIDSync(directChatMatrixID),
outerContext: context,
onMention: () => controller.sendController.text +=
2021-12-13 09:40:53 +01:00
'${controller.room.getUserByMXIDSync(directChatMatrixID).mention} ',
),
)
: () => VRouter.of(context)
.toSegments(['rooms', controller.room.id, 'details']),
title: Text(
controller.room
2021-12-13 09:40:53 +01:00
.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
maxLines: 1),
subtitle: StreamBuilder<Object>(
stream: Matrix.of(context)
.client
.onPresence
.stream
.where((p) => p.senderId == controller.room.directChatMatrixID)
.rateLimit(const Duration(seconds: 1)),
builder: (context, snapshot) => Text(
controller.room.getLocalizedStatus(context),
maxLines: 1,
//overflow: TextOverflow.ellipsis,
),
),
);
}
}