From c31ca03806ddefc3fe60d983fce5cece94568cd2 Mon Sep 17 00:00:00 2001 From: Freek van de Ven Date: Thu, 25 Jul 2024 11:20:24 +0200 Subject: [PATCH] fix: handle really long template names by adding textoverflow.ellipsis everywhere --- .../lib/src/ui/screens/template_overview.dart | 10 +++++-- .../screens/template_week_modification.dart | 16 +++++++++-- .../availability_template_selection.dart | 27 ++++++++++++------- .../lib/src/ui/widgets/template_legend.dart | 8 +++++- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/packages/flutter_availability/lib/src/ui/screens/template_overview.dart b/packages/flutter_availability/lib/src/ui/screens/template_overview.dart index a062fe8..51afe6a 100644 --- a/packages/flutter_availability/lib/src/ui/screens/template_overview.dart +++ b/packages/flutter_availability/lib/src/ui/screens/template_overview.dart @@ -217,8 +217,14 @@ class _TemplateListSectionItem extends StatelessWidget { width: 20, ), const SizedBox(width: 8), - Text(template.name, style: theme.textTheme.bodyLarge), - const Spacer(), + Expanded( + child: Text( + template.name, + style: theme.textTheme.bodyLarge, + overflow: TextOverflow.ellipsis, + ), + ), + const SizedBox(width: 4), InkWell( onTap: () => onEditTemplate(template), child: const Icon(Icons.edit), diff --git a/packages/flutter_availability/lib/src/ui/screens/template_week_modification.dart b/packages/flutter_availability/lib/src/ui/screens/template_week_modification.dart index d6c5755..1cd142a 100644 --- a/packages/flutter_availability/lib/src/ui/screens/template_week_modification.dart +++ b/packages/flutter_availability/lib/src/ui/screens/template_week_modification.dart @@ -182,7 +182,13 @@ class _WeekTemplateModificationScreenState var overviewPage = _WeekTemplateSidePadding( child: Column( children: [ - Text(translations.templateTitleLabel, style: textTheme.titleMedium), + Align( + alignment: Alignment.centerLeft, + child: Text( + translations.templateTitleLabel, + style: textTheme.titleMedium, + ), + ), const SizedBox(height: 8), Container( padding: const EdgeInsets.all(12), @@ -204,7 +210,13 @@ class _WeekTemplateModificationScreenState height: 20, ), const SizedBox(width: 12), - Text(_viewModel.name ?? "", style: textTheme.bodyLarge), + Expanded( + child: Text( + _viewModel.name ?? "", + style: textTheme.bodyLarge, + overflow: TextOverflow.ellipsis, + ), + ), ], ), ), diff --git a/packages/flutter_availability/lib/src/ui/widgets/availability_template_selection.dart b/packages/flutter_availability/lib/src/ui/widgets/availability_template_selection.dart index 58954ff..51b6a12 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/availability_template_selection.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/availability_template_selection.dart @@ -103,17 +103,20 @@ class _TemplateList extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - for (var template in selectedTemplates) ...[ - _TemplateListItem(template: template), - if (template != selectedTemplates.last) ...[ - const SizedBox(height: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + for (var template in selectedTemplates) ...[ + _TemplateListItem(template: template), + if (template != selectedTemplates.last) ...[ + const SizedBox(height: 12), + ], ], ], - ], + ), ), + const SizedBox(width: 8), InkWell( onTap: onTemplatesRemoved, child: const Icon(Icons.remove), @@ -146,7 +149,13 @@ class _TemplateListItem extends StatelessWidget { height: 20, ), const SizedBox(width: 12), - Text(template.name, style: theme.textTheme.bodyLarge), + Expanded( + child: Text( + template.name, + style: theme.textTheme.bodyLarge, + overflow: TextOverflow.ellipsis, + ), + ), ], ); } diff --git a/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart b/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart index 22e3522..beabcd2 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart @@ -230,7 +230,13 @@ class _TemplateLegendItem extends StatelessWidget { height: 20, ), const SizedBox(width: 8), - Text(name, style: theme.textTheme.bodyLarge), + Expanded( + child: Text( + name, + style: theme.textTheme.bodyLarge, + overflow: TextOverflow.ellipsis, + ), + ), ], ); }