chore: Merge upstream changes --------- Signed-off-by: Krille <c.kussowski@famedly.com> Co-authored-by: krille-chan <christian-kussowski@posteo.de> Co-authored-by: Krille <c.kussowski@famedly.com> Co-authored-by: Linerly <linerly@proton.me> Co-authored-by: Priit Jõerüüt <hwlate@joeruut.com> Co-authored-by: 大王叫我来巡山 <hamburger2048@users.noreply.hosted.weblate.org> Co-authored-by: fadelkon <fadelkon@posteo.net> Co-authored-by: Aindriú Mac Giolla Eoin <aindriu80@gmail.com> Co-authored-by: Edgars Andersons <Edgars+Weblate@gaitenis.id.lv> Co-authored-by: josé m <correoxm@disroot.org> Co-authored-by: Bezruchenko Simon <worcposj44@gmail.com> Co-authored-by: Christian <christian-pauly@posteo.de> Co-authored-by: - <hitekex@yandex.ru> Co-authored-by: Angelo Schirinzi <Odi-3@users.noreply.hosted.weblate.org> Co-authored-by: xabirequejo <xabi.rn@gmail.com> Co-authored-by: Piotr Orzechowski <piotr@orzechowski.tech> Co-authored-by: Rex_sa <rex.sa@pm.me> Co-authored-by: Tewuzij <tenajeza@outlook.com> Co-authored-by: goknarbahceli <goknarbahceli@proton.me> Co-authored-by: தமிழ்நேரம் <anishprabu.t@gmail.com> Co-authored-by: Erin <erin@erindesu.cz> Co-authored-by: EpicKiwi <me@epickiwi.fr> Co-authored-by: Christian Tietze <me@christiantietze.de> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
101 lines
3.3 KiB
Dart
101 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
|
import '../../../config/app_config.dart';
|
|
|
|
class ReplyContent extends StatelessWidget {
|
|
final Event replyEvent;
|
|
final bool ownMessage;
|
|
final Timeline? timeline;
|
|
final Color? backgroundColor;
|
|
|
|
const ReplyContent(
|
|
this.replyEvent, {
|
|
this.ownMessage = false,
|
|
super.key,
|
|
this.timeline,
|
|
this.backgroundColor,
|
|
});
|
|
|
|
static const BorderRadius borderRadius = BorderRadius.only(
|
|
topRight: Radius.circular(AppConfig.borderRadius / 2),
|
|
bottomRight: Radius.circular(AppConfig.borderRadius / 2),
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
|
|
final timeline = this.timeline;
|
|
final displayEvent =
|
|
timeline != null ? replyEvent.getDisplayEvent(timeline) : replyEvent;
|
|
final fontSize = AppConfig.messageFontSize * AppConfig.fontSizeFactor;
|
|
final color = theme.brightness == Brightness.dark
|
|
? theme.colorScheme.onTertiaryContainer
|
|
: ownMessage
|
|
? theme.colorScheme.tertiaryContainer
|
|
: theme.colorScheme.tertiary;
|
|
|
|
return Material(
|
|
color: backgroundColor ??
|
|
theme.colorScheme.surface.withAlpha(ownMessage ? 50 : 80),
|
|
borderRadius: borderRadius,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Container(
|
|
width: 3,
|
|
height: fontSize * 2 + 16,
|
|
color: color,
|
|
),
|
|
const SizedBox(width: 6),
|
|
Flexible(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
FutureBuilder<User?>(
|
|
initialData: displayEvent.senderFromMemoryOrFallback,
|
|
future: displayEvent.fetchSenderUser(),
|
|
builder: (context, snapshot) {
|
|
return Text(
|
|
'${snapshot.data?.calcDisplayname() ?? displayEvent.senderFromMemoryOrFallback.calcDisplayname()}:',
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: color,
|
|
fontSize: fontSize,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
Text(
|
|
displayEvent.calcLocalizedBodyFallback(
|
|
MatrixLocals(L10n.of(context)),
|
|
withSenderNamePrefix: false,
|
|
hideReply: true,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
maxLines: 1,
|
|
style: TextStyle(
|
|
color: theme.brightness == Brightness.dark
|
|
? theme.colorScheme.onSurface
|
|
: ownMessage
|
|
? theme.colorScheme.onTertiary
|
|
: theme.colorScheme.onSurface,
|
|
fontSize: fontSize,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 6),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|