mirror of
https://github.com/openfoodfacts/smooth-app.git
synced 2025-08-26 03:01:45 +08:00
feat: Tagline V3 (#5350)
* New JSON * Tagline V3 * Refresh the tagline on language change * Fix Lint errors * Revert `SmoothScaffold` changes * Filter news with startDate/endDate
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension StringExtensions on String {
|
||||
/// Returns a list containing all positions of a [charCode]
|
||||
@ -93,3 +93,41 @@ class TextHelper {
|
||||
return parts;
|
||||
}
|
||||
}
|
||||
|
||||
class FormattedText extends StatelessWidget {
|
||||
const FormattedText({
|
||||
required this.text,
|
||||
this.textStyle,
|
||||
this.textAlign,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final TextStyle? textStyle;
|
||||
final TextAlign? textAlign;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextStyle defaultTextStyle = textStyle ?? const TextStyle();
|
||||
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
children: TextHelper.getPartsBetweenSymbol(
|
||||
text: text,
|
||||
symbol: r'\*\*',
|
||||
symbolLength: 2,
|
||||
defaultStyle: defaultTextStyle,
|
||||
highlightedStyle: const TextStyle(fontWeight: FontWeight.bold))
|
||||
.map(
|
||||
((String, TextStyle?) part) {
|
||||
return TextSpan(
|
||||
text: part.$1,
|
||||
style: defaultTextStyle.merge(part.$2),
|
||||
);
|
||||
},
|
||||
).toList(growable: false),
|
||||
),
|
||||
textAlign: textAlign ?? TextAlign.start,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user