Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
🐛 fixed text overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sou1maker committed Jun 1, 2022
1 parent 9d03559 commit e329444
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions lib/views/details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,23 @@ class _DetailsGrid extends StatelessWidget {
clipBehavior: Clip.antiAlias,
child: ListTile(
dense: true,
title: Text('${values[index].title ?? index}'),
title: Text(
'${values[index].title ?? index}',
style: const TextStyle(overflow: TextOverflow.ellipsis),
),
subtitle: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(timeAgo(values[index].readableAt)),
Text(values[index].scanlationGroup ?? ''),
Text(values[index].uploader ?? ''),
Text('共 ${values[index].pages} 页'),
_ExpandedText(timeAgo(values[index].readableAt)),
const Padding(padding: EdgeInsets.only(left: 5)),
_ExpandedText(values[index].scanlationGroup ?? ''),
const Padding(padding: EdgeInsets.only(left: 5)),
_ExpandedText(values[index].uploader ?? ''),
const Padding(padding: EdgeInsets.only(left: 5)),
_ExpandedText(
'共 ${values[index].pages} 页',
alignment: Alignment.centerRight,
),
],
),
onTap: () => Navigator.push(
Expand Down Expand Up @@ -377,3 +386,26 @@ class _DetailsGrid extends StatelessWidget {
);
}
}

class _ExpandedText extends StatelessWidget {
const _ExpandedText(this.text, {Key? key, this.alignment}) : super(key: key);

final String text;
final Alignment? alignment;

@override
Widget build(BuildContext context) {
if (alignment != null) {
return Expanded(
child: Container(
alignment: alignment,
child: Text(text, style: const TextStyle(overflow: TextOverflow.ellipsis)),
),
);
}

return Expanded(
child: Text(text, style: const TextStyle(overflow: TextOverflow.ellipsis)),
);
}
}

0 comments on commit e329444

Please sign in to comment.