Files
tatuchat/lib/pages/chat/reply_display.dart
Welton Moura 0037b0b9cf
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
Initial commit
2026-09-11 15:59:56 -03:00

96 lines
3.0 KiB
Dart

// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:tatchat/l10n/l10n.dart';
import 'package:tatchat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:material_ui/material_ui.dart';
import 'package:matrix/matrix.dart';
import '../../config/themes.dart';
import 'chat.dart';
import 'events/reply_content.dart';
class ReplyDisplay extends StatelessWidget {
final ChatController controller;
const ReplyDisplay(this.controller, {super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return AnimatedSize(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
clipBehavior: Clip.hardEdge,
child: controller.editEvent != null || controller.replyEvent != null
? Material(
color: theme.colorScheme.surfaceContainer,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: IconButton(
tooltip: L10n.of(context).close,
icon: const Icon(Icons.close),
onPressed: controller.cancelReplyEventAction,
),
),
Expanded(
child: controller.replyEvent != null
? ReplyContent(
controller.replyEvent!,
timeline: controller.timeline,
)
: _EditContent(
controller.editEvent?.getDisplayEvent(
controller.timeline!,
),
),
),
],
),
),
)
: SizedBox.shrink(),
);
}
}
class _EditContent extends StatelessWidget {
final Event? event;
const _EditContent(this.event);
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final event = this.event;
if (event == null) {
return const SizedBox.shrink();
}
return Row(
children: <Widget>[
Icon(Icons.edit, color: theme.colorScheme.primary),
Container(width: 15.0),
Text(
event
.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)),
withSenderNamePrefix: false,
hideReply: true,
)
.trim()
.replaceAll('\n', ' '),
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(color: theme.textTheme.bodyMedium!.color),
),
],
);
}
}