Improve text formatting with extreme size values and fix session header not getting formatted
This commit is contained in:
parent
d51eba5009
commit
5e267b7ff0
2 changed files with 4 additions and 3 deletions
|
@ -166,15 +166,16 @@ class FormatData {
|
|||
"size": FormatAction(
|
||||
style: (param, baseStyle) {
|
||||
if (param == null) return baseStyle;
|
||||
final baseSize = baseStyle.fontSize ?? 12;
|
||||
if (param.endsWith("%")) {
|
||||
final percentage = int.tryParse(param.replaceAll("%", ""));
|
||||
if (percentage == null || percentage <= 0) return baseStyle;
|
||||
final baseSize = baseStyle.fontSize ?? 12;
|
||||
return baseStyle.copyWith(fontSize: baseSize * (percentage / 100));
|
||||
} else {
|
||||
final size = num.tryParse(param);
|
||||
if (size == null || size <= 0) return baseStyle;
|
||||
return baseStyle.copyWith(fontSize: size.toDouble());
|
||||
final realSize = baseSize * (size / 1000);
|
||||
return baseStyle.copyWith(fontSize: realSize.toDouble().clamp(8, 400));
|
||||
}
|
||||
}
|
||||
),
|
||||
|
|
|
@ -131,7 +131,7 @@ class SessionTile extends StatelessWidget {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(session.name),
|
||||
FormattedText(session.formattedName),
|
||||
Text("${session.sessionUsers.length}/${session.maxUsers} active users")
|
||||
],
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue