From 214650ebe43b224af757670e4186c4743ada9b2a Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Sun, 26 Sep 2021 12:29:45 +0900 Subject: [PATCH] map: fixed unstable layout for addresses with funky scripts --- lib/widgets/map/map_info_row.dart | 89 ++++++++++++++++++------------- lib/widgets/map/map_page.dart | 3 +- 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/lib/widgets/map/map_info_row.dart b/lib/widgets/map/map_info_row.dart index 1cf9b4681..df3db6a36 100644 --- a/lib/widgets/map/map_info_row.dart +++ b/lib/widgets/map/map_info_row.dart @@ -40,13 +40,13 @@ class MapInfoRow extends StatelessWidget { children: [ _AddressRow(entry: entry), const SizedBox(height: _interRowPadding), - _buildDate(context, entry), + _DateRow(entry: entry), ], ), ), ] : [ - _buildDate(context, entry), + _DateRow(entry: entry), Expanded( child: _AddressRow(entry: entry), ), @@ -66,23 +66,6 @@ class MapInfoRow extends StatelessWidget { }, ); } - - Widget _buildDate(BuildContext context, AvesEntry? entry) { - final locale = context.l10n.localeName; - final date = entry?.bestDate; - final dateText = date != null ? formatDateTime(date, locale) : Constants.overlayUnknown; - return Row( - children: [ - const SizedBox(width: iconPadding), - const DecoratedIcon(AIcons.date, shadows: Constants.embossShadows, size: iconSize), - const SizedBox(width: iconPadding), - Text( - dateText, - strutStyle: Constants.overflowStrutStyle, - ), - ], - ); - } } class _AddressRow extends StatefulWidget { @@ -123,23 +106,30 @@ class _AddressRowState extends State<_AddressRow> { const DecoratedIcon(AIcons.location, shadows: Constants.embossShadows, size: MapInfoRow.iconSize), const SizedBox(width: MapInfoRow.iconPadding), Expanded( - child: ValueListenableBuilder( - valueListenable: _addressLineNotifier, - builder: (context, addressLine, child) { - final location = addressLine ?? - (entry == null - ? Constants.overlayUnknown - : entry.hasAddress - ? entry.shortAddress - : settings.coordinateFormat.format(entry.latLng!)); - return Text( - location, - strutStyle: Constants.overflowStrutStyle, - softWrap: false, - overflow: TextOverflow.fade, - maxLines: 1, - ); - }, + child: Container( + alignment: AlignmentDirectional.centerStart, + // addresses can include non-latin scripts with inconsistent line height, + // which is especially an issue for relayout/painting of heavy Google maps, + // so we give extra height to give breathing room to the text and stabilize layout + height: Theme.of(context).textTheme.bodyText2!.fontSize! * context.select((mq) => mq.textScaleFactor) * 2, + child: ValueListenableBuilder( + valueListenable: _addressLineNotifier, + builder: (context, addressLine, child) { + final location = addressLine ?? + (entry == null + ? Constants.overlayUnknown + : entry.hasAddress + ? entry.shortAddress + : settings.coordinateFormat.format(entry.latLng!)); + return Text( + location, + strutStyle: Constants.overflowStrutStyle, + softWrap: false, + overflow: TextOverflow.fade, + maxLines: 1, + ); + }, + ), ), ), ], @@ -157,3 +147,30 @@ class _AddressRowState extends State<_AddressRow> { return null; } } + +class _DateRow extends StatelessWidget { + final AvesEntry? entry; + + const _DateRow({ + Key? key, + required this.entry, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final locale = context.l10n.localeName; + final date = entry?.bestDate; + final dateText = date != null ? formatDateTime(date, locale) : Constants.overlayUnknown; + return Row( + children: [ + const SizedBox(width: MapInfoRow.iconPadding), + const DecoratedIcon(AIcons.date, shadows: Constants.embossShadows, size: MapInfoRow.iconSize), + const SizedBox(width: MapInfoRow.iconPadding), + Text( + dateText, + strutStyle: Constants.overflowStrutStyle, + ), + ], + ); + } +} diff --git a/lib/widgets/map/map_page.dart b/lib/widgets/map/map_page.dart index 845a4f5d6..d3522a026 100644 --- a/lib/widgets/map/map_page.dart +++ b/lib/widgets/map/map_page.dart @@ -193,7 +193,8 @@ class _MapPageContentState extends State with SingleTickerProvid child: Column( mainAxisSize: MainAxisSize.min, children: [ - const Divider(), + const SizedBox(height: 8), + const Divider(height: 0), _buildScroller(), ], ),