import 'package:flutter/material.dart'; import '../../about/internal/application/TextType.dart'; import '../../utils/Colors.dart'; import '../Component.dart'; /// The only way display copy is rendered. Raw Text/TextStyle is never used for /// user-facing copy. Widget text( String text, double textSize, TextType type, { Color? color, TextAlign? align, int? maxLines, TextOverflow? overflow, double? letterSpacing, double? height, double? wordSpacing, TextDecoration? decoration, FontWeight? weight, }) { return Text( text, textAlign: align ?? TextAlign.left, maxLines: maxLines, overflow: overflow, style: TextStyle( decoration: decoration ?? TextDecoration.none, color: color ?? colorPrimaryDark, fontSize: textSize, fontFamily: getTextType(type), letterSpacing: letterSpacing, height: height, wordSpacing: wordSpacing, fontWeight: weight, ), ); } /// Copy with **bold** phrases marked inline, for answers that need to stress /// a number. Regular for the body, Medium for the marked parts. Widget markedText( String marked, double textSize, { Color? color, double? height, }) { final List parts = marked.split("**"); return Text.rich( TextSpan( children: [ for (int index = 0; index < parts.length; index++) TextSpan( text: parts[index], style: TextStyle( fontFamily: getTextType( index.isOdd ? TextType.Medium : TextType.Regular), ), ), ], ), style: TextStyle( color: color ?? colorPrimaryDark, fontSize: textSize, height: height, ), ); }