105 lines
3.4 KiB
Dart
105 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import 'package:fluffychat/config/setting_keys.dart';
|
|
import 'package:fluffychat/l10n/l10n.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;
|
|
|
|
const ReplyContent(
|
|
this.replyEvent, {
|
|
this.ownMessage = false,
|
|
super.key,
|
|
this.timeline,
|
|
});
|
|
|
|
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 * AppSettings.fontSizeFactor.value;
|
|
final color = theme.brightness == Brightness.dark
|
|
? theme.colorScheme.onTertiaryContainer
|
|
: ownMessage
|
|
? theme.colorScheme.tertiaryContainer
|
|
: theme.colorScheme.tertiary;
|
|
|
|
return Material(
|
|
color: Colors.transparent,
|
|
borderRadius: borderRadius,
|
|
child: Row(
|
|
mainAxisSize: .min,
|
|
children: <Widget>[
|
|
Container(
|
|
width: 5,
|
|
height: fontSize * 2 + 16,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
color: color,
|
|
),
|
|
),
|
|
const SizedBox(width: 6),
|
|
Flexible(
|
|
child: Column(
|
|
crossAxisAlignment: .start,
|
|
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,
|
|
plaintextBody: 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),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|