2021-11-14 08:36:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2023-08-02 10:08:23 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
2021-11-14 08:36:35 +00:00
|
|
|
|
2023-11-11 18:54:31 +00:00
|
|
|
import 'package:fluffychat/config/themes.dart';
|
2021-11-14 08:36:35 +00:00
|
|
|
import 'package:fluffychat/pages/chat/chat.dart';
|
2023-11-11 16:56:23 +00:00
|
|
|
import 'package:fluffychat/utils/date_time_extension.dart';
|
2022-12-30 16:54:01 +00:00
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
2021-11-14 08:36:35 +00:00
|
|
|
import 'package:fluffychat/widgets/avatar.dart';
|
2023-11-11 16:56:23 +00:00
|
|
|
import 'package:fluffychat/widgets/presence_builder.dart';
|
2021-11-14 08:36:35 +00:00
|
|
|
|
|
|
|
class ChatAppBarTitle extends StatelessWidget {
|
|
|
|
final ChatController controller;
|
2023-10-28 11:03:16 +00:00
|
|
|
const ChatAppBarTitle(this.controller, {super.key});
|
2021-11-14 08:36:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-01-29 11:35:03 +00:00
|
|
|
final room = controller.room;
|
2021-11-14 08:36:35 +00:00
|
|
|
if (controller.selectedEvents.isNotEmpty) {
|
|
|
|
return Text(controller.selectedEvents.length.toString());
|
|
|
|
}
|
2022-02-17 11:52:58 +00:00
|
|
|
return InkWell(
|
2023-08-12 10:33:01 +00:00
|
|
|
hoverColor: Colors.transparent,
|
2022-02-17 11:52:58 +00:00
|
|
|
splashColor: Colors.transparent,
|
|
|
|
highlightColor: Colors.transparent,
|
2023-08-12 11:37:42 +00:00
|
|
|
onTap: controller.isArchived
|
|
|
|
? null
|
2024-04-07 08:30:21 +00:00
|
|
|
: () => FluffyThemes.isThreeColumnMode(context)
|
|
|
|
? controller.toggleDisplayChatDetailsColumn()
|
|
|
|
: context.go('/rooms/${room.id}/details'),
|
2022-02-17 11:52:58 +00:00
|
|
|
child: Row(
|
|
|
|
children: [
|
2022-07-08 08:41:36 +00:00
|
|
|
Hero(
|
|
|
|
tag: 'content_banner',
|
|
|
|
child: Avatar(
|
|
|
|
mxContent: room.avatar,
|
2023-01-20 15:59:50 +00:00
|
|
|
name: room.getLocalizedDisplayname(
|
2024-10-06 06:35:37 +00:00
|
|
|
MatrixLocals(L10n.of(context)),
|
2023-01-20 15:59:50 +00:00
|
|
|
),
|
2022-07-08 08:41:36 +00:00
|
|
|
size: 32,
|
|
|
|
),
|
2022-02-17 11:52:58 +00:00
|
|
|
),
|
|
|
|
const SizedBox(width: 12),
|
2022-02-17 13:16:39 +00:00
|
|
|
Expanded(
|
2023-11-11 18:54:31 +00:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
2024-10-06 06:35:37 +00:00
|
|
|
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context))),
|
2023-11-11 18:54:31 +00:00
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
2023-11-11 16:56:23 +00:00
|
|
|
),
|
2023-11-11 18:54:31 +00:00
|
|
|
AnimatedSize(
|
|
|
|
duration: FluffyThemes.animationDuration,
|
|
|
|
child: PresenceBuilder(
|
|
|
|
userId: room.directChatMatrixID,
|
|
|
|
builder: (context, presence) {
|
|
|
|
final lastActiveTimestamp = presence?.lastActiveTimestamp;
|
|
|
|
final style = Theme.of(context).textTheme.bodySmall;
|
|
|
|
if (presence?.currentlyActive == true) {
|
|
|
|
return Text(
|
2024-10-06 06:35:37 +00:00
|
|
|
L10n.of(context).currentlyActive,
|
2023-11-11 18:54:31 +00:00
|
|
|
style: style,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (lastActiveTimestamp != null) {
|
|
|
|
return Text(
|
2024-10-06 06:35:37 +00:00
|
|
|
L10n.of(context).lastActiveAgo(
|
2023-11-11 18:54:31 +00:00
|
|
|
lastActiveTimestamp.localizedTimeShort(context),
|
|
|
|
),
|
|
|
|
style: style,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-02-17 11:52:58 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2021-11-14 08:36:35 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|