Line data Source code
1 : import 'package:flutter/material.dart'; 2 : import 'package:provider/provider.dart'; 3 : import '../controllers/open_link_modal.dart'; 4 : import '../settings.dart'; 5 : import '../themes/opaque.dart'; 6 : import '../third_party/linkify/flutter_linkify.dart'; 7 : 8 0 : Widget compileSenderWidget(BuildContext context, BoxConstraints? constraints, bool fromMe, String senderDisplayStr) { 9 0 : return Container( 10 0 : height: 14 * Provider.of<Settings>(context).fontScaling, 11 : clipBehavior: Clip.hardEdge, 12 0 : decoration: BoxDecoration(), 13 0 : child: SelectableText(senderDisplayStr, 14 : maxLines: 1, 15 0 : style: TextStyle( 16 0 : fontSize: 9.0 * Provider.of<Settings>(context).fontScaling, 17 : fontWeight: FontWeight.bold, 18 : fontFamily: "Inter", 19 : overflow: TextOverflow.clip, 20 0 : color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor : Provider.of<Settings>(context).theme.messageFromOtherTextColor, 21 : ))); 22 : } 23 : 24 0 : Widget compileMessageContentWidget(BuildContext context, BoxConstraints constraints, fromMe, String content, FocusNode focus, bool formatMessages, bool showClickableLinks) { 25 0 : return SelectableLinkify( 26 0 : text: content + '\u202F', 27 : // TODO: onOpen breaks the "selectable" functionality. Maybe something to do with gesture handler? 28 0 : options: LinkifyOptions(messageFormatting: formatMessages, parseLinks: showClickableLinks, looseUrl: true, defaultToHttps: true), 29 0 : linkifiers: [UrlLinkifier()], 30 : onOpen: showClickableLinks 31 0 : ? (link) { 32 0 : modalOpenLink(context, link); 33 : } 34 : : null, 35 : focusNode: focus, 36 0 : style: Provider.of<Settings>(context) 37 0 : .scaleFonts(defaultMessageTextStyle.copyWith(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor : Provider.of<Settings>(context).theme.messageFromOtherTextColor)), 38 0 : linkStyle: Provider.of<Settings>(context) 39 0 : .scaleFonts(defaultMessageTextStyle.copyWith(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor : Provider.of<Settings>(context).theme.messageFromOtherTextColor)), 40 0 : codeStyle: Provider.of<Settings>(context).scaleFonts(defaultMessageTextStyle.copyWith( 41 : fontFamily: "RobotoMono", 42 0 : color: fromMe ? Provider.of<Settings>(context).theme.messageFromOtherTextColor : Provider.of<Settings>(context).theme.messageFromMeTextColor, 43 0 : backgroundColor: fromMe ? Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor : Provider.of<Settings>(context).theme.messageFromMeBackgroundColor)), 44 : textAlign: TextAlign.left, 45 : constraints: constraints, 46 : textWidthBasis: TextWidthBasis.longestLine, 47 : ); 48 : }