2021-11-13 10:20:09 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
2022-12-30 17:54:01 +01:00
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
2023-01-07 09:22:31 +01:00
|
|
|
import '../../config/themes.dart';
|
2021-11-13 10:20:09 +01:00
|
|
|
import 'chat.dart';
|
|
|
|
import 'events/reply_content.dart';
|
|
|
|
|
|
|
|
class ReplyDisplay extends StatelessWidget {
|
|
|
|
final ChatController controller;
|
2022-01-29 12:35:03 +01:00
|
|
|
const ReplyDisplay(this.controller, {Key? key}) : super(key: key);
|
2021-11-13 10:20:09 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AnimatedContainer(
|
2023-01-07 09:22:31 +01:00
|
|
|
duration: FluffyThemes.animationDuration,
|
|
|
|
curve: FluffyThemes.animationCurve,
|
2021-11-13 10:20:09 +01:00
|
|
|
height: controller.editEvent != null || controller.replyEvent != null
|
|
|
|
? 56
|
|
|
|
: 0,
|
2022-05-03 12:18:07 +02:00
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
decoration: const BoxDecoration(),
|
2021-11-13 10:20:09 +01:00
|
|
|
child: Material(
|
|
|
|
color: Theme.of(context).secondaryHeaderColor,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
IconButton(
|
2022-01-29 12:35:03 +01:00
|
|
|
tooltip: L10n.of(context)!.close,
|
2021-11-13 10:20:09 +01:00
|
|
|
icon: const Icon(Icons.close),
|
|
|
|
onPressed: controller.cancelReplyEventAction,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: controller.replyEvent != null
|
2023-03-02 10:57:52 +01:00
|
|
|
? ReplyContent(
|
|
|
|
controller.replyEvent!,
|
|
|
|
timeline: controller.timeline!,
|
|
|
|
)
|
|
|
|
: _EditContent(
|
|
|
|
controller.editEvent
|
|
|
|
?.getDisplayEvent(controller.timeline!),
|
|
|
|
),
|
2021-11-13 10:20:09 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _EditContent extends StatelessWidget {
|
2022-01-29 12:35:03 +01:00
|
|
|
final Event? event;
|
2021-11-13 10:20:09 +01:00
|
|
|
|
|
|
|
const _EditContent(this.event);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-05-30 13:44:05 +02:00
|
|
|
final event = this.event;
|
2021-11-13 10:20:09 +01:00
|
|
|
if (event == null) {
|
|
|
|
return Container();
|
|
|
|
}
|
|
|
|
return Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Icons.edit,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
),
|
|
|
|
Container(width: 15.0),
|
2022-05-30 13:44:05 +02:00
|
|
|
FutureBuilder<String>(
|
2023-03-02 10:57:52 +01:00
|
|
|
future: event.calcLocalizedBody(
|
|
|
|
MatrixLocals(L10n.of(context)!),
|
|
|
|
withSenderNamePrefix: false,
|
|
|
|
hideReply: true,
|
|
|
|
),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
return Text(
|
|
|
|
snapshot.data ??
|
|
|
|
event.calcLocalizedBodyFallback(
|
|
|
|
MatrixLocals(L10n.of(context)!),
|
|
|
|
withSenderNamePrefix: false,
|
|
|
|
hideReply: true,
|
|
|
|
),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 1,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).textTheme.bodyMedium!.color,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2021-11-13 10:20:09 +01:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|