Line data Source code
1 : import 'package:flutter/material.dart'; 2 : import 'package:provider/provider.dart'; 3 : import '../models/redaction.dart'; 4 : import '../settings.dart'; 5 : import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 6 : 7 : // Provides message decorations (acks/errors/dates etc.) for generic message bubble overlays (chats, invites etc.) 8 : class MessageBubbleDecoration extends StatefulWidget { 9 0 : MessageBubbleDecoration({required this.ackd, required this.errored, required this.messageDate, required this.fromMe}); 10 : final DateTime messageDate; 11 : final bool fromMe; 12 : final bool ackd; 13 : final bool errored; 14 : 15 0 : @override 16 0 : _MessageBubbleDecoration createState() => _MessageBubbleDecoration(); 17 : } 18 : 19 : class _MessageBubbleDecoration extends State<MessageBubbleDecoration> { 20 0 : @override 21 : Widget build(BuildContext context) { 22 0 : var prettyDate = prettyDateString(context, widget.messageDate.toLocal()); 23 : 24 0 : return FittedBox( 25 0 : child: Row( 26 : mainAxisSize: MainAxisSize.min, 27 0 : children: [ 28 0 : Text(prettyDate, 29 : overflow: TextOverflow.ellipsis, 30 : textWidthBasis: TextWidthBasis.longestLine, 31 0 : style: TextStyle( 32 0 : fontSize: 9.0 * Provider.of<Settings>(context).fontScaling, 33 : fontWeight: FontWeight.w200, 34 : fontFamily: "Inter", 35 0 : color: widget.fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor : Provider.of<Settings>(context).theme.messageFromOtherTextColor), 36 0 : textAlign: widget.fromMe ? TextAlign.right : TextAlign.left), 37 0 : !widget.fromMe 38 0 : ? SizedBox(width: 1, height: 1) 39 0 : : Padding( 40 0 : padding: EdgeInsets.all(1.0), 41 0 : child: widget.ackd == true 42 0 : ? Tooltip( 43 0 : message: AppLocalizations.of(context)!.acknowledgedLabel, child: Icon(Icons.check_circle_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16)) 44 0 : : (widget.errored == true 45 0 : ? Tooltip( 46 0 : message: AppLocalizations.of(context)!.couldNotSendMsgError, child: Icon(Icons.error_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16)) 47 0 : : Tooltip( 48 0 : message: AppLocalizations.of(context)!.pendingLabel, 49 0 : child: Icon(Icons.hourglass_bottom_outlined, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16)))) 50 : ], 51 : )); 52 : } 53 : }