44 lines
1.3 KiB
Dart
44 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:gap/gap.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:styled_widget/styled_widget.dart';
|
|
import 'package:surface/providers/user_directory.dart';
|
|
import 'package:surface/types/chat.dart';
|
|
import 'package:surface/widgets/account/account_image.dart';
|
|
import 'package:surface/widgets/markdown_content.dart';
|
|
|
|
class ChatMessage extends StatelessWidget {
|
|
final SnChatMessage data;
|
|
const ChatMessage({super.key, required this.data});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final ud = context.read<UserDirectoryProvider>();
|
|
final user = ud.getAccountFromCache(data.sender.accountId);
|
|
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
AccountImage(
|
|
content: user?.avatar,
|
|
),
|
|
const Gap(8),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
(data.sender.nick?.isNotEmpty ?? false)
|
|
? data.sender.nick!
|
|
: user!.nick,
|
|
).bold(),
|
|
if (data.body['text'] != null)
|
|
MarkdownTextContent(content: data.body['text']),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|