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(
|
"size": FormatAction(
|
||||||
style: (param, baseStyle) {
|
style: (param, baseStyle) {
|
||||||
if (param == null) return baseStyle;
|
if (param == null) return baseStyle;
|
||||||
|
final baseSize = baseStyle.fontSize ?? 12;
|
||||||
if (param.endsWith("%")) {
|
if (param.endsWith("%")) {
|
||||||
final percentage = int.tryParse(param.replaceAll("%", ""));
|
final percentage = int.tryParse(param.replaceAll("%", ""));
|
||||||
if (percentage == null || percentage <= 0) return baseStyle;
|
if (percentage == null || percentage <= 0) return baseStyle;
|
||||||
final baseSize = baseStyle.fontSize ?? 12;
|
|
||||||
return baseStyle.copyWith(fontSize: baseSize * (percentage / 100));
|
return baseStyle.copyWith(fontSize: baseSize * (percentage / 100));
|
||||||
} else {
|
} else {
|
||||||
final size = num.tryParse(param);
|
final size = num.tryParse(param);
|
||||||
if (size == null || size <= 0) return baseStyle;
|
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,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(session.name),
|
FormattedText(session.formattedName),
|
||||||
Text("${session.sessionUsers.length}/${session.maxUsers} active users")
|
Text("${session.sessionUsers.length}/${session.maxUsers} active users")
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue