2022-03-01 06:35:09 +00:00
|
|
|
import 'dart:io';
|
|
|
|
import 'package:intl/intl.dart';
|
2021-06-24 23:10:45 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../settings.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
|
|
|
// Provides message decorations (acks/errors/dates etc.) for generic message bubble overlays (chats, invites etc.)
|
|
|
|
class MessageBubbleDecoration extends StatefulWidget {
|
2022-03-01 06:35:09 +00:00
|
|
|
MessageBubbleDecoration({required this.ackd, required this.errored, required this.messageDate, required this.fromMe});
|
|
|
|
final DateTime messageDate;
|
2021-06-24 23:10:45 +00:00
|
|
|
final bool fromMe;
|
|
|
|
final bool ackd;
|
|
|
|
final bool errored;
|
|
|
|
|
|
|
|
@override
|
|
|
|
_MessageBubbleDecoration createState() => _MessageBubbleDecoration();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MessageBubbleDecoration extends State<MessageBubbleDecoration> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-03-01 06:35:09 +00:00
|
|
|
var prettyDate = DateFormat.yMd(Platform.localeName).add_jm().format(widget.messageDate.toLocal());
|
|
|
|
|
2021-06-24 23:10:45 +00:00
|
|
|
return Center(
|
|
|
|
widthFactor: 1.0,
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
2022-03-01 06:35:09 +00:00
|
|
|
Text(prettyDate,
|
2021-12-15 22:29:27 +00:00
|
|
|
style: TextStyle(fontSize: 9.0, color: widget.fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor : Provider.of<Settings>(context).theme.messageFromOtherTextColor),
|
2021-06-24 23:10:45 +00:00
|
|
|
textAlign: widget.fromMe ? TextAlign.right : TextAlign.left),
|
|
|
|
!widget.fromMe
|
|
|
|
? SizedBox(width: 1, height: 1)
|
|
|
|
: Padding(
|
|
|
|
padding: EdgeInsets.all(1.0),
|
|
|
|
child: widget.ackd == true
|
|
|
|
? Tooltip(
|
|
|
|
message: AppLocalizations.of(context)!.acknowledgedLabel,
|
2021-12-10 04:22:55 +00:00
|
|
|
child: Icon(Icons.check_circle_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16))
|
2021-06-24 23:10:45 +00:00
|
|
|
: (widget.errored == true
|
|
|
|
? Tooltip(
|
|
|
|
message: AppLocalizations.of(context)!.couldNotSendMsgError,
|
2021-12-10 04:22:55 +00:00
|
|
|
child: Icon(Icons.error_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16))
|
2021-06-24 23:10:45 +00:00
|
|
|
: Tooltip(
|
|
|
|
message: AppLocalizations.of(context)!.pendingLabel,
|
2021-12-10 04:22:55 +00:00
|
|
|
child: Icon(Icons.hourglass_bottom_outlined, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16))))
|
2021-06-24 23:10:45 +00:00
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|