Support profiles sort
Support windows country flags display Optimize proxies page and profiles page columns
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:emoji_regex/emoji_regex.dart';
|
||||
|
||||
import '../state.dart';
|
||||
|
||||
@@ -30,3 +31,63 @@ class TooltipText extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EmojiText extends StatelessWidget {
|
||||
final String text;
|
||||
final TextStyle? style;
|
||||
final int? maxLines;
|
||||
final TextOverflow? overflow;
|
||||
|
||||
const EmojiText(
|
||||
this.text, {
|
||||
super.key,
|
||||
this.maxLines,
|
||||
this.overflow,
|
||||
this.style,
|
||||
});
|
||||
|
||||
List<TextSpan> _buildTextSpans(String emojis) {
|
||||
final List<TextSpan> spans = [];
|
||||
final matches = emojiRegex().allMatches(text);
|
||||
|
||||
int lastMatchEnd = 0;
|
||||
for (final match in matches) {
|
||||
if (match.start > lastMatchEnd) {
|
||||
spans.add(
|
||||
TextSpan(
|
||||
text: text.substring(lastMatchEnd, match.start), style: style),
|
||||
);
|
||||
}
|
||||
spans.add(
|
||||
TextSpan(
|
||||
text:match.group(0),
|
||||
style: style?.copyWith(
|
||||
fontFamily: "Twemoji",
|
||||
),
|
||||
),
|
||||
);
|
||||
lastMatchEnd = match.end;
|
||||
}
|
||||
if (lastMatchEnd < text.length) {
|
||||
spans.add(
|
||||
TextSpan(
|
||||
text: text.substring(lastMatchEnd),
|
||||
style: style,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return spans;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RichText(
|
||||
maxLines: maxLines,
|
||||
overflow: overflow ?? TextOverflow.clip,
|
||||
text: TextSpan(
|
||||
children: _buildTextSpans(text),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user