2021-11-14 09:36:35 +01:00
|
|
|
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/widgets/avatar.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);
|
2021-11-14 09:36:35 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-01-29 12:35:03 +01:00
|
|
|
final room = controller.room;
|
|
|
|
if (room == null) {
|
|
|
|
return Container();
|
|
|
|
}
|
2021-11-14 09:36:35 +01:00
|
|
|
if (controller.selectedEvents.isNotEmpty) {
|
|
|
|
return Text(controller.selectedEvents.length.toString());
|
|
|
|
}
|
2022-01-29 12:35:03 +01:00
|
|
|
final directChatMatrixID = room.directChatMatrixID;
|
2022-02-17 12:52:58 +01:00
|
|
|
return InkWell(
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
highlightColor: Colors.transparent,
|
2021-12-13 09:40:53 +01:00
|
|
|
onTap: directChatMatrixID != null
|
2021-11-14 09:36:35 +01:00
|
|
|
? () => showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
builder: (c) => UserBottomSheet(
|
2022-01-29 12:35:03 +01:00
|
|
|
user: room.getUserByMXIDSync(directChatMatrixID),
|
2021-11-14 09:36:35 +01:00
|
|
|
outerContext: context,
|
|
|
|
onMention: () => controller.sendController.text +=
|
2022-01-29 12:35:03 +01:00
|
|
|
'${room.getUserByMXIDSync(directChatMatrixID).mention} ',
|
2021-11-14 09:36:35 +01:00
|
|
|
),
|
|
|
|
)
|
2022-01-29 12:35:03 +01:00
|
|
|
: () => VRouter.of(context).toSegments(['rooms', room.id, 'details']),
|
2022-02-17 12:52:58 +01:00
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Avatar(
|
|
|
|
mxContent: room.avatar,
|
|
|
|
name: room.displayname,
|
|
|
|
size: 32,
|
|
|
|
),
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
Text(
|
|
|
|
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
|
|
|
maxLines: 1,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2021-11-14 09:36:35 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|