map: fixed unstable layout for addresses with funky scripts
This commit is contained in:
parent
5939668fd5
commit
214650ebe4
2 changed files with 55 additions and 37 deletions
|
@ -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,23 +106,30 @@ 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: ValueListenableBuilder<String?>(
|
child: Container(
|
||||||
valueListenable: _addressLineNotifier,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
builder: (context, addressLine, child) {
|
// addresses can include non-latin scripts with inconsistent line height,
|
||||||
final location = addressLine ??
|
// which is especially an issue for relayout/painting of heavy Google maps,
|
||||||
(entry == null
|
// so we give extra height to give breathing room to the text and stabilize layout
|
||||||
? Constants.overlayUnknown
|
height: Theme.of(context).textTheme.bodyText2!.fontSize! * context.select<MediaQueryData, double>((mq) => mq.textScaleFactor) * 2,
|
||||||
: entry.hasAddress
|
child: ValueListenableBuilder<String?>(
|
||||||
? entry.shortAddress
|
valueListenable: _addressLineNotifier,
|
||||||
: settings.coordinateFormat.format(entry.latLng!));
|
builder: (context, addressLine, child) {
|
||||||
return Text(
|
final location = addressLine ??
|
||||||
location,
|
(entry == null
|
||||||
strutStyle: Constants.overflowStrutStyle,
|
? Constants.overlayUnknown
|
||||||
softWrap: false,
|
: entry.hasAddress
|
||||||
overflow: TextOverflow.fade,
|
? entry.shortAddress
|
||||||
maxLines: 1,
|
: 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;
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue