mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-18 02:42:34 +01:00
69 lines
2.3 KiB
Dart
69 lines
2.3 KiB
Dart
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/adaptive_bottom_sheet.dart';
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
|
import 'package:fluffychat/widgets/avatar.dart';
|
|
|
|
class ChatAppBarTitle extends StatelessWidget {
|
|
final ChatController controller;
|
|
const ChatAppBarTitle(this.controller, {Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final room = controller.room;
|
|
if (controller.selectedEvents.isNotEmpty) {
|
|
return Text(controller.selectedEvents.length.toString());
|
|
}
|
|
final directChatMatrixID = room.directChatMatrixID;
|
|
return InkWell(
|
|
splashColor: Colors.transparent,
|
|
highlightColor: Colors.transparent,
|
|
onTap: directChatMatrixID != null
|
|
? () => showAdaptiveBottomSheet(
|
|
context: context,
|
|
builder: (c) => UserBottomSheet(
|
|
user: room
|
|
.unsafeGetUserFromMemoryOrFallback(directChatMatrixID),
|
|
outerContext: context,
|
|
onMention: () => controller.sendController.text +=
|
|
'${room.unsafeGetUserFromMemoryOrFallback(directChatMatrixID).mention} ',
|
|
),
|
|
)
|
|
: controller.isArchived
|
|
? null
|
|
: () =>
|
|
VRouter.of(context).toSegments(['rooms', room.id, 'details']),
|
|
child: Row(
|
|
children: [
|
|
Hero(
|
|
tag: 'content_banner',
|
|
child: Avatar(
|
|
mxContent: room.avatar,
|
|
name: room.getLocalizedDisplayname(
|
|
MatrixLocals(L10n.of(context)!),
|
|
),
|
|
size: 32,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|