downsize text only for long values

This commit is contained in:
Vadim 2024-09-23 15:49:22 +02:00
parent 6ee6c81164
commit e8785b234a

View file

@ -50,15 +50,25 @@ class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWid
class _Title<T extends PhotographyStopValue> extends StatelessWidget { class _Title<T extends PhotographyStopValue> extends StatelessWidget {
final T value; final T value;
late final String _title = value.toString();
const _Title(this.value, {super.key}); _Title(this.value, {super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Flexible( return Flexible(
child: AutoSizeText( child: _title.length > 5 // downsize text only for long values like 1/4000
? AutoSizeText(
value.toString(), value.toString(),
stepGranularity: 0.5, stepGranularity: 0.5,
minFontSize: 10,
style: labelTextStyle(context).copyWith(color: Theme.of(context).colorScheme.onBackground),
softWrap: false,
overflow: TextOverflow.fade,
maxLines: 1,
)
: Text(
value.toString(),
style: labelTextStyle(context).copyWith(color: Theme.of(context).colorScheme.onBackground), style: labelTextStyle(context).copyWith(color: Theme.of(context).colorScheme.onBackground),
softWrap: false, softWrap: false,
overflow: TextOverflow.fade, overflow: TextOverflow.fade,