map: fixed unstable layout for addresses with funky scripts

This commit is contained in:
Thibault Deckers 2021-09-26 12:29:45 +09:00
parent 5939668fd5
commit 214650ebe4
2 changed files with 55 additions and 37 deletions

View file

@ -40,13 +40,13 @@ class MapInfoRow extends StatelessWidget {
children: [ children: [
_AddressRow(entry: entry), _AddressRow(entry: entry),
const SizedBox(height: _interRowPadding), const SizedBox(height: _interRowPadding),
_buildDate(context, entry), _DateRow(entry: entry),
], ],
), ),
), ),
] ]
: [ : [
_buildDate(context, entry), _DateRow(entry: entry),
Expanded( Expanded(
child: _AddressRow(entry: entry), 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 { class _AddressRow extends StatefulWidget {
@ -123,6 +106,12 @@ class _AddressRowState extends State<_AddressRow> {
const DecoratedIcon(AIcons.location, shadows: Constants.embossShadows, size: MapInfoRow.iconSize), const DecoratedIcon(AIcons.location, shadows: Constants.embossShadows, size: MapInfoRow.iconSize),
const SizedBox(width: MapInfoRow.iconPadding), const SizedBox(width: MapInfoRow.iconPadding),
Expanded( Expanded(
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<MediaQueryData, double>((mq) => mq.textScaleFactor) * 2,
child: ValueListenableBuilder<String?>( child: ValueListenableBuilder<String?>(
valueListenable: _addressLineNotifier, valueListenable: _addressLineNotifier,
builder: (context, addressLine, child) { builder: (context, addressLine, child) {
@ -142,6 +131,7 @@ class _AddressRowState extends State<_AddressRow> {
}, },
), ),
), ),
),
], ],
); );
} }
@ -157,3 +147,30 @@ class _AddressRowState extends State<_AddressRow> {
return null; 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,
),
],
);
}
}

View file

@ -193,7 +193,8 @@ class _MapPageContentState extends State<MapPageContent> with SingleTickerProvid
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
const Divider(), const SizedBox(height: 8),
const Divider(height: 0),
_buildScroller(), _buildScroller(),
], ],
), ),