format review
This commit is contained in:
parent
ff16651ce1
commit
f10abcd670
41 changed files with 108 additions and 117 deletions
|
@ -23,6 +23,9 @@ import 'package:latlong2/latlong.dart';
|
|||
import 'package:xml/xml.dart';
|
||||
|
||||
extension ExtraAvesEntryMetadataEdition on AvesEntry {
|
||||
static final _iso6709LatitudeFormatter = NumberFormat('00.0000', asciiLocale);
|
||||
static final _iso6709LongitudeFormatter = NumberFormat('000.0000', asciiLocale);
|
||||
|
||||
Future<Set<EntryDataType>> editDate(DateModifier userModifier) async {
|
||||
final dataTypes = <EntryDataType>{};
|
||||
|
||||
|
@ -122,9 +125,8 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
|
|||
if (latLng != null && latLng != removalLocation) {
|
||||
final latitude = latLng.latitude;
|
||||
final longitude = latLng.longitude;
|
||||
const locale = asciiLocale;
|
||||
final isoLat = '${latitude >= 0 ? '+' : '-'}${NumberFormat('00.0000', locale).format(latitude.abs())}';
|
||||
final isoLon = '${longitude >= 0 ? '+' : '-'}${NumberFormat('000.0000', locale).format(longitude.abs())}';
|
||||
final isoLat = '${latitude >= 0 ? '+' : '-'}${_iso6709LatitudeFormatter.format(latitude.abs())}';
|
||||
final isoLon = '${longitude >= 0 ? '+' : '-'}${_iso6709LongitudeFormatter.format(longitude.abs())}';
|
||||
iso6709String = '$isoLat$isoLon/';
|
||||
}
|
||||
mp4Fields[MetadataField.mp4GpsCoordinates] = iso6709String;
|
||||
|
|
|
@ -53,9 +53,9 @@ extension ExtraAvesEntryProps on AvesEntry {
|
|||
// text
|
||||
|
||||
String getResolutionText(String locale) {
|
||||
final numberFormat = NumberFormat('0', locale);
|
||||
final ws = numberFormat.format(width);
|
||||
final hs = numberFormat.format(height);
|
||||
final dimensionFormatter = NumberFormat('0', locale);
|
||||
final ws = dimensionFormatter.format(width);
|
||||
final hs = dimensionFormatter.format(height);
|
||||
return isRotated ? '$hs${AText.resolutionSeparator}$ws' : '$ws${AText.resolutionSeparator}$hs';
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,7 @@ class DateFilter extends CollectionFilter {
|
|||
|
||||
@override
|
||||
String getLabel(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final locale = l10n.localeName;
|
||||
final locale = context.locale;
|
||||
switch (level) {
|
||||
case DateLevel.y:
|
||||
return DateFormat.y(locale).format(_effectiveDate);
|
||||
|
@ -113,7 +112,7 @@ class DateFilter extends CollectionFilter {
|
|||
if (date != null) {
|
||||
return DateFormat.MMMd(locale).format(_effectiveDate);
|
||||
} else {
|
||||
return l10n.filterOnThisDayLabel;
|
||||
return context.l10n.filterOnThisDayLabel;
|
||||
}
|
||||
case DateLevel.m:
|
||||
return DateFormat.MMMM(locale).format(_effectiveDate);
|
||||
|
|
|
@ -55,11 +55,10 @@ extension ExtraCoordinateFormat on CoordinateFormat {
|
|||
}
|
||||
|
||||
static List<String> _toDecimal(AppLocalizations l10n, LatLng latLng) {
|
||||
final locale = l10n.localeName;
|
||||
final formatter = NumberFormat('0.000000°', locale);
|
||||
final coordinateFormatter = NumberFormat('0.000000°', l10n.localeName);
|
||||
return [
|
||||
formatter.format(latLng.latitude),
|
||||
formatter.format(latLng.longitude),
|
||||
coordinateFormatter.format(latLng.latitude),
|
||||
coordinateFormatter.format(latLng.longitude),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ const tera = giga * kilo;
|
|||
String formatFileSize(String locale, int size, {int round = 2}) {
|
||||
if (size < kilo) return '$size B';
|
||||
|
||||
final formatter = NumberFormat('0${round > 0 ? '.${'0' * round}' : ''}', locale);
|
||||
if (size < mega) return '${formatter.format(size / kilo)} KB';
|
||||
if (size < giga) return '${formatter.format(size / mega)} MB';
|
||||
if (size < tera) return '${formatter.format(size / giga)} GB';
|
||||
return '${formatter.format(size / tera)} TB';
|
||||
final compactFormatter = NumberFormat('0${round > 0 ? '.${'0' * round}' : ''}', locale);
|
||||
if (size < mega) return '${compactFormatter.format(size / kilo)} KB';
|
||||
if (size < giga) return '${compactFormatter.format(size / mega)} MB';
|
||||
if (size < tera) return '${compactFormatter.format(size / giga)} GB';
|
||||
return '${compactFormatter.format(size / tera)} TB';
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class AppReference extends StatelessWidget {
|
|||
}
|
||||
|
||||
Widget _buildAvesLine(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final locale = context.locale;
|
||||
final textScaler = MediaQuery.textScalerOf(context);
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
|
@ -122,9 +122,6 @@ class _BugReportState extends State<BugReport> with FeedbackMixin {
|
|||
}
|
||||
|
||||
Widget _buildStep(int step, String text, String buttonText, VoidCallback onPressed) {
|
||||
final locale = context.l10n.localeName;
|
||||
final numberFormat = NumberFormat.decimalPattern(locale);
|
||||
|
||||
final isMonochrome = settings.themeColorMode == AvesThemeColorMode.monochrome;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
|
@ -139,7 +136,7 @@ class _BugReportState extends State<BugReport> with FeedbackMixin {
|
|||
)),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Text(numberFormat.format(step)),
|
||||
child: Text(NumberFormat('0', context.locale).format(step)),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(text)),
|
||||
|
|
|
@ -137,7 +137,7 @@ class DataUsageDonut extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final locale = l10n.localeName;
|
||||
final locale = context.locale;
|
||||
|
||||
return AvesDonut(
|
||||
title: Text(title),
|
||||
|
|
|
@ -673,7 +673,7 @@ class _CollectionScrollViewState extends State<_CollectionScrollView> with Widge
|
|||
final newest = firstKey.date;
|
||||
final oldest = lastKey.date;
|
||||
if (newest != null && oldest != null) {
|
||||
final locale = context.l10n.localeName;
|
||||
final locale = context.locale;
|
||||
final dateFormat = (newest.difference(oldest).inHumanDays).abs() > 365 ? DateFormat.y(locale) : DateFormat.MMM(locale);
|
||||
String? lastLabel;
|
||||
sectionLayouts.forEach((section) {
|
||||
|
|
|
@ -55,7 +55,7 @@ class CollectionDraggableThumbLabel extends StatelessWidget {
|
|||
];
|
||||
case EntrySortFactor.size:
|
||||
return [
|
||||
if (entry.sizeBytes != null) formatFileSize(context.l10n.localeName, entry.sizeBytes!, round: 0),
|
||||
if (entry.sizeBytes != null) formatFileSize(context.locale, entry.sizeBytes!, round: 0),
|
||||
];
|
||||
}
|
||||
},
|
||||
|
|
|
@ -40,7 +40,8 @@ class DaySectionHeader<T> extends StatelessWidget {
|
|||
if (date == null) return l10n.sectionUnknown;
|
||||
if (date.isToday) return l10n.dateToday;
|
||||
if (date.isYesterday) return l10n.dateYesterday;
|
||||
final locale = l10n.localeName;
|
||||
|
||||
final locale = context.locale;
|
||||
if (date.isThisYear) return '${DateFormat.MMMMd(locale).format(date)} (${DateFormat.E(locale).format(date)})';
|
||||
return '${DateFormat.yMMMMd(locale).format(date)} (${DateFormat.E(locale).format(date)})';
|
||||
}
|
||||
|
@ -69,7 +70,8 @@ class MonthSectionHeader<T> extends StatelessWidget {
|
|||
final l10n = context.l10n;
|
||||
if (date == null) return l10n.sectionUnknown;
|
||||
if (date.isThisMonth) return l10n.dateThisMonth;
|
||||
final locale = l10n.localeName;
|
||||
|
||||
final locale = context.locale;
|
||||
final localized = date.isThisYear ? DateFormat.MMMM(locale).format(date) : DateFormat.yMMMM(locale).format(date);
|
||||
return '${localized.substring(0, 1).toUpperCase()}${localized.substring(1)}';
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class EntryListDetails extends StatelessWidget {
|
|||
}
|
||||
|
||||
Widget _buildDateRow(BuildContext context, TextStyle style) {
|
||||
final locale = context.l10n.localeName;
|
||||
final locale = context.locale;
|
||||
final use24hour = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
final date = entry.bestDate;
|
||||
final dateText = date != null ? formatDateTime(date, locale, use24hour) : AText.valueNotAvailable;
|
||||
|
|
|
@ -24,8 +24,6 @@ class EntryListDetailsTheme extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return ProxyProvider<MediaQueryData, EntryListDetailsThemeData>(
|
||||
update: (context, mq, previous) {
|
||||
final locale = context.l10n.localeName;
|
||||
|
||||
final use24hour = mq.alwaysUse24HourFormat;
|
||||
final textScaler = mq.textScaler;
|
||||
|
||||
|
@ -50,7 +48,7 @@ class EntryListDetailsTheme extends StatelessWidget {
|
|||
|
||||
final captionLineHeightParagraph = RenderParagraph(
|
||||
TextSpan(
|
||||
text: formatDateTime(DateTime.now(), locale, use24hour),
|
||||
text: formatDateTime(DateTime.now(), context.locale, use24hour),
|
||||
style: captionStyle,
|
||||
),
|
||||
textDirection: TextDirection.ltr,
|
||||
|
|
|
@ -218,8 +218,7 @@ class _ReportOverlayState<T> extends State<ReportOverlay<T>> with SingleTickerPr
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final percentFormat = NumberFormat.percentPattern(locale);
|
||||
final percentFormatter = NumberFormat.percentPattern(context.locale);
|
||||
|
||||
final theme = Theme.of(context);
|
||||
final colorScheme = theme.colorScheme;
|
||||
|
@ -265,7 +264,7 @@ class _ReportOverlayState<T> extends State<ReportOverlay<T>> with SingleTickerPr
|
|||
animation: animate,
|
||||
center: total != null
|
||||
? Text(
|
||||
percentFormat.format(percent),
|
||||
percentFormatter.format(percent),
|
||||
style: const TextStyle(fontSize: fontSize),
|
||||
)
|
||||
: null,
|
||||
|
@ -353,8 +352,7 @@ class _FeedbackMessageState extends State<_FeedbackMessage> with SingleTickerPro
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final numberFormat = NumberFormat('0', locale);
|
||||
final durationFormatter = NumberFormat('0', context.locale);
|
||||
|
||||
final textScaler = MediaQuery.textScalerOf(context);
|
||||
final theme = Theme.of(context);
|
||||
|
@ -393,7 +391,7 @@ class _FeedbackMessageState extends State<_FeedbackMessage> with SingleTickerPro
|
|||
// because we cannot use the app context theme here
|
||||
foreground: widget.progressColor,
|
||||
center: ChangeHighlightText(
|
||||
numberFormat.format((remainingDurationMillis / 1000).ceil()),
|
||||
durationFormatter.format((remainingDurationMillis / 1000).ceil()),
|
||||
style: contentTextStyle.copyWith(
|
||||
shadows: [
|
||||
Shadow(
|
||||
|
|
|
@ -77,13 +77,12 @@ mixin SizeAwareMixin {
|
|||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
final l10n = context.l10n;
|
||||
final locale = l10n.localeName;
|
||||
final locale = context.locale;
|
||||
final neededSize = formatFileSize(locale, needed);
|
||||
final freeSize = formatFileSize(locale, free);
|
||||
final volume = destinationVolume.getDescription(context);
|
||||
return AvesDialog(
|
||||
content: Text(l10n.notEnoughSpaceDialogMessage(neededSize, freeSize, volume)),
|
||||
content: Text(context.l10n.notEnoughSpaceDialogMessage(neededSize, freeSize, volume)),
|
||||
actions: const [OkButton()],
|
||||
);
|
||||
},
|
||||
|
|
|
@ -8,6 +8,7 @@ class WheelSelector<T> extends StatefulWidget {
|
|||
final List<T> values;
|
||||
final TextStyle textStyle;
|
||||
final TextAlign textAlign;
|
||||
final String Function(T v) format;
|
||||
|
||||
const WheelSelector({
|
||||
super.key,
|
||||
|
@ -15,6 +16,7 @@ class WheelSelector<T> extends StatefulWidget {
|
|||
required this.values,
|
||||
required this.textStyle,
|
||||
required this.textAlign,
|
||||
required this.format,
|
||||
});
|
||||
|
||||
@override
|
||||
|
@ -117,7 +119,7 @@ class _WheelSelectorState<T> extends State<WheelSelector<T>> {
|
|||
.map((i) => SizedBox.fromSize(
|
||||
size: itemSize,
|
||||
child: Text(
|
||||
'$i',
|
||||
widget.format(i),
|
||||
textAlign: widget.textAlign,
|
||||
style: widget.textStyle,
|
||||
),
|
||||
|
|
|
@ -7,7 +7,9 @@ extension ExtraContext on BuildContext {
|
|||
|
||||
AppLocalizations get l10n => AppLocalizations.of(this)!;
|
||||
|
||||
bool get isArabic => l10n.localeName.startsWith('ar');
|
||||
String get locale => l10n.localeName;
|
||||
|
||||
bool get isArabic => locale.startsWith('ar');
|
||||
|
||||
bool get isRtl => Directionality.of(this) == TextDirection.rtl;
|
||||
|
||||
|
|
|
@ -62,15 +62,13 @@ class DraggableThumbLabel<T> extends StatelessWidget {
|
|||
}
|
||||
|
||||
static String formatMonthThumbLabel(BuildContext context, DateTime? date) {
|
||||
final l10n = context.l10n;
|
||||
if (date == null) return l10n.sectionUnknown;
|
||||
return DateFormat.yMMM(l10n.localeName).format(date);
|
||||
if (date == null) return context.l10n.sectionUnknown;
|
||||
return DateFormat.yMMM(context.locale).format(date);
|
||||
}
|
||||
|
||||
static String formatDayThumbLabel(BuildContext context, DateTime? date) {
|
||||
final l10n = context.l10n;
|
||||
if (date == null) return l10n.sectionUnknown;
|
||||
return formatDay(date, l10n.localeName);
|
||||
if (date == null) return context.l10n.sectionUnknown;
|
||||
return formatDay(date, context.locale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class HighlightTitle extends StatelessWidget {
|
|||
final style = TextStyle(
|
||||
shadows: shadows(context),
|
||||
fontSize: fontSize,
|
||||
letterSpacing: canHaveLetterSpacing(context.l10n.localeName) ? 1 : 0,
|
||||
letterSpacing: canHaveLetterSpacing(context.locale) ? 1 : 0,
|
||||
fontFeatures: const [FontFeature.enable('smcp')],
|
||||
);
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ class _GeoMapState extends State<GeoMap> {
|
|||
selector: (context, s) => s.mapStyle,
|
||||
builder: (context, mapStyle, child) {
|
||||
final isHeavy = ExtraEntryMapStyle.isHeavy(mapStyle);
|
||||
final locale = context.l10n.localeName;
|
||||
final locale = context.locale;
|
||||
Widget _buildMarkerWidget(MarkerKey<AvesEntry> key) => ImageMarker(
|
||||
key: key,
|
||||
count: key.count,
|
||||
|
@ -484,7 +484,7 @@ class _GeoMapState extends State<GeoMap> {
|
|||
} else {
|
||||
markerEntry = geoEntry.entry!;
|
||||
}
|
||||
final locale = context.l10n.localeName;
|
||||
final locale = context.locale;
|
||||
final markerLocation = LatLng(geoEntry.latitude!, geoEntry.longitude!);
|
||||
Widget markerBuilder(BuildContext context) => ImageMarker(
|
||||
count: geoEntry.pointsSize,
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:aves/widgets/common/extensions/build_context.dart';
|
|||
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
||||
import 'package:aves/widgets/dialogs/aves_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class DurationDialog extends StatefulWidget {
|
||||
final int initialSeconds;
|
||||
|
@ -41,7 +42,10 @@ class _DurationDialogState extends State<DurationDialog> {
|
|||
return MediaQueryDataProvider(
|
||||
child: Builder(builder: (context) {
|
||||
final l10n = context.l10n;
|
||||
final timeComponentFormatter = NumberFormat('0', context.locale);
|
||||
|
||||
const textStyle = TextStyle(fontSize: 34);
|
||||
const digitsAlign = TextAlign.right;
|
||||
|
||||
return AvesDialog(
|
||||
scrollableContent: [
|
||||
|
@ -53,9 +57,9 @@ class _DurationDialogState extends State<DurationDialog> {
|
|||
children: [
|
||||
TableRow(
|
||||
children: [
|
||||
Center(child: Text(context.l10n.durationDialogMinutes)),
|
||||
Center(child: Text(l10n.durationDialogMinutes)),
|
||||
const SizedBox(width: 16),
|
||||
Center(child: Text(context.l10n.durationDialogSeconds)),
|
||||
Center(child: Text(l10n.durationDialogSeconds)),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
|
@ -66,7 +70,8 @@ class _DurationDialogState extends State<DurationDialog> {
|
|||
valueNotifier: _minutes,
|
||||
values: List.generate(minutesInHour, (i) => i),
|
||||
textStyle: textStyle,
|
||||
textAlign: TextAlign.end,
|
||||
textAlign: digitsAlign,
|
||||
format: timeComponentFormatter.format,
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
|
@ -82,7 +87,8 @@ class _DurationDialogState extends State<DurationDialog> {
|
|||
valueNotifier: _seconds,
|
||||
values: List.generate(secondsInMinute, (i) => i),
|
||||
textStyle: textStyle,
|
||||
textAlign: TextAlign.end,
|
||||
textAlign: digitsAlign,
|
||||
format: timeComponentFormatter.format,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -18,6 +18,7 @@ import 'package:aves/widgets/dialogs/item_picker.dart';
|
|||
import 'package:aves/widgets/dialogs/pick_dialogs/item_pick_page.dart';
|
||||
import 'package:aves_model/aves_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class EditEntryDateDialog extends StatefulWidget {
|
||||
|
@ -147,19 +148,17 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
|||
}
|
||||
|
||||
Widget _buildSetCustomContent(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final locale = l10n.localeName;
|
||||
final use24hour = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 16, end: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(formatDateTime(_customDateTime, locale, use24hour))),
|
||||
Expanded(child: Text(formatDateTime(_customDateTime, context.locale, use24hour))),
|
||||
IconButton(
|
||||
icon: const Icon(AIcons.edit),
|
||||
onPressed: _editDate,
|
||||
tooltip: l10n.changeTooltip,
|
||||
tooltip: context.l10n.changeTooltip,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -181,15 +180,13 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
|||
}
|
||||
|
||||
Widget _buildCopyItemContent(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final locale = l10n.localeName;
|
||||
final use24hour = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 16, end: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(formatDateTime(copyItemDate, locale, use24hour))),
|
||||
Expanded(child: Text(formatDateTime(copyItemDate, context.locale, use24hour))),
|
||||
const SizedBox(width: 8),
|
||||
ItemPicker(
|
||||
extent: 48,
|
||||
|
@ -202,7 +199,12 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
|||
}
|
||||
|
||||
Widget _buildShiftContent(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final timeComponentFormatter = NumberFormat('0', context.locale);
|
||||
|
||||
const textStyle = TextStyle(fontSize: 34);
|
||||
const digitsAlign = TextAlign.right;
|
||||
|
||||
return Center(
|
||||
child: Table(
|
||||
textDirection: timeComponentsDirection,
|
||||
|
@ -210,9 +212,9 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
|||
TableRow(
|
||||
children: [
|
||||
const SizedBox(),
|
||||
Center(child: Text(context.l10n.durationDialogHours)),
|
||||
Center(child: Text(l10n.durationDialogHours)),
|
||||
const SizedBox(width: 16),
|
||||
Center(child: Text(context.l10n.durationDialogMinutes)),
|
||||
Center(child: Text(l10n.durationDialogMinutes)),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
|
@ -222,6 +224,7 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
|||
values: const ['+', '-'],
|
||||
textStyle: textStyle,
|
||||
textAlign: TextAlign.center,
|
||||
format: (v) => v,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
|
@ -229,7 +232,8 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
|||
valueNotifier: _shiftHour,
|
||||
values: List.generate(hoursInDay, (i) => i),
|
||||
textStyle: textStyle,
|
||||
textAlign: TextAlign.end,
|
||||
textAlign: digitsAlign,
|
||||
format: timeComponentFormatter.format,
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
|
@ -245,7 +249,8 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
|||
valueNotifier: _shiftMinute,
|
||||
values: List.generate(minutesInHour, (i) => i),
|
||||
textStyle: textStyle,
|
||||
textAlign: TextAlign.end,
|
||||
textAlign: digitsAlign,
|
||||
format: timeComponentFormatter.format,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -48,7 +48,7 @@ class _EditEntryLocationDialogState extends State<EditEntryLocationDialog> {
|
|||
final TextEditingController _latitudeController = TextEditingController(), _longitudeController = TextEditingController();
|
||||
final ValueNotifier<bool> _isValidNotifier = ValueNotifier(false);
|
||||
|
||||
NumberFormat get coordinateFormatter => NumberFormat('0.000000', context.l10n.localeName);
|
||||
NumberFormat get coordinateFormatter => NumberFormat('0.000000', context.locale);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -54,7 +54,7 @@ class _RenameEntrySetPageState extends State<RenameEntrySetPage> {
|
|||
_patternTextController.addListener(_onUserPatternChanged);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
locale = context.l10n.localeName;
|
||||
locale = context.locale;
|
||||
_onUserPatternChanged();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ class RotationControlPanel extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = context.watch<TransformController>();
|
||||
final angleFormatter = NumberFormat('0.0°', context.locale);
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
|
@ -172,7 +173,7 @@ class RotationControlPanel extends StatelessWidget {
|
|||
divisions: 18,
|
||||
onChangeStart: (v) => controller.activity = TransformActivity.straighten,
|
||||
onChangeEnd: (v) => controller.activity = TransformActivity.none,
|
||||
label: NumberFormat('0.0°', context.l10n.localeName).format(transformation.straightenDegrees),
|
||||
label: angleFormatter.format(transformation.straightenDegrees),
|
||||
onChanged: (v) => controller.straightenDegrees = v,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -171,8 +171,7 @@ class CoveredFilterChip<T extends CollectionFilter> extends StatelessWidget {
|
|||
Color _detailColor(BuildContext context) => Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
Widget _buildDetails(BuildContext context, CollectionSource source, T filter) {
|
||||
final locale = context.l10n.localeName;
|
||||
final numberFormat = NumberFormat.decimalPattern(locale);
|
||||
final countFormatter = NumberFormat.decimalPattern(context.locale);
|
||||
|
||||
final padding = min<double>(8.0, extent / 16);
|
||||
final iconSize = detailIconSize(extent);
|
||||
|
@ -211,7 +210,7 @@ class CoveredFilterChip<T extends CollectionFilter> extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
Text(
|
||||
locked ? AText.valueNotAvailable : numberFormat.format(source.count(filter)),
|
||||
locked ? AText.valueNotAvailable : countFormatter.format(source.count(filter)),
|
||||
style: TextStyle(
|
||||
color: _detailColor(context),
|
||||
fontSize: fontSize,
|
||||
|
|
|
@ -36,9 +36,8 @@ class FilterDraggableThumbLabel<T extends CollectionFilter> extends StatelessWid
|
|||
context.l10n.itemCount(context.read<CollectionSource>().count(filterGridItem.filter)),
|
||||
];
|
||||
case ChipSortFactor.size:
|
||||
final locale = context.l10n.localeName;
|
||||
return [
|
||||
formatFileSize(locale, context.read<CollectionSource>().size(filterGridItem.filter)),
|
||||
formatFileSize(context.locale, context.read<CollectionSource>().size(filterGridItem.filter)),
|
||||
];
|
||||
}
|
||||
},
|
||||
|
|
|
@ -84,10 +84,9 @@ class FilterListDetails<T extends CollectionFilter> extends StatelessWidget {
|
|||
}
|
||||
|
||||
Widget _buildDateRow(BuildContext context, FilterListDetailsThemeData detailsTheme, bool hasTitleLeading) {
|
||||
final locale = context.l10n.localeName;
|
||||
final use24hour = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
final date = entry?.bestDate;
|
||||
final dateText = date != null ? formatDateTime(date, locale, use24hour) : AText.valueNotAvailable;
|
||||
final dateText = date != null ? formatDateTime(date, context.locale, use24hour) : AText.valueNotAvailable;
|
||||
|
||||
Widget leading = const Icon(AIcons.date);
|
||||
if (hasTitleLeading) {
|
||||
|
@ -143,8 +142,6 @@ class FilterListDetails<T extends CollectionFilter> extends StatelessWidget {
|
|||
child: Center(child: leading ?? const SizedBox()),
|
||||
);
|
||||
|
||||
final l10n = context.l10n;
|
||||
final locale = l10n.localeName;
|
||||
final source = context.read<CollectionSource>();
|
||||
|
||||
return IconTheme.merge(
|
||||
|
@ -154,7 +151,7 @@ class FilterListDetails<T extends CollectionFilter> extends StatelessWidget {
|
|||
leading,
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${l10n.itemCount(source.count(filter))} • ${formatFileSize(locale, source.size(filter))}',
|
||||
'${context.l10n.itemCount(source.count(filter))} • ${formatFileSize(context.locale, source.size(filter))}',
|
||||
style: detailsTheme.captionStyle,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.fade,
|
||||
|
|
|
@ -28,8 +28,6 @@ class FilterListDetailsTheme extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return ProxyProvider<MediaQueryData, FilterListDetailsThemeData>(
|
||||
update: (context, mq, previous) {
|
||||
final locale = context.l10n.localeName;
|
||||
|
||||
final use24hour = mq.alwaysUse24HourFormat;
|
||||
final textScaler = mq.textScaler;
|
||||
|
||||
|
@ -54,7 +52,7 @@ class FilterListDetailsTheme extends StatelessWidget {
|
|||
titleLineHeightParagraph.dispose();
|
||||
|
||||
final captionLineHeightParagraph = RenderParagraph(
|
||||
TextSpan(text: formatDateTime(DateTime.now(), locale, use24hour), style: captionStyle),
|
||||
TextSpan(text: formatDateTime(DateTime.now(), context.locale, use24hour), style: captionStyle),
|
||||
textDirection: TextDirection.ltr,
|
||||
textScaler: textScaler,
|
||||
)..layout(const BoxConstraints(), parentUsesSize: true);
|
||||
|
|
|
@ -16,11 +16,10 @@ class MapDateRow extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final use24hour = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
|
||||
final date = entry?.bestDate;
|
||||
final dateText = date != null ? formatDateTime(date, locale, use24hour) : AText.valueNotAvailable;
|
||||
final dateText = date != null ? formatDateTime(date, context.locale, use24hour) : AText.valueNotAvailable;
|
||||
return Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
|
|
|
@ -112,7 +112,6 @@ class _AppDrawerState extends State<AppDrawer> {
|
|||
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final locale = l10n.localeName;
|
||||
|
||||
Future<void> goTo(String routeName, WidgetBuilder pageBuilder) async {
|
||||
Navigator.maybeOf(context)?.pop();
|
||||
|
@ -153,7 +152,7 @@ class _AppDrawerState extends State<AppDrawer> {
|
|||
color: Colors.white,
|
||||
fontSize: 38,
|
||||
fontWeight: FontWeight.w300,
|
||||
letterSpacing: canHaveLetterSpacing(locale) ? 1 : 0,
|
||||
letterSpacing: canHaveLetterSpacing(context.locale) ? 1 : 0,
|
||||
fontFeatures: const [FontFeature.enable('smcp')],
|
||||
),
|
||||
),
|
||||
|
@ -295,7 +294,7 @@ class _AppDrawerState extends State<AppDrawer> {
|
|||
return CollectionNavTile(
|
||||
leading: const DrawerFilterIcon(filter: filter),
|
||||
title: const DrawerFilterTitle(filter: filter),
|
||||
trailing: Text(formatFileSize(context.l10n.localeName, trashSize, round: 0)),
|
||||
trailing: Text(formatFileSize(context.locale, trashSize, round: 0)),
|
||||
filter: filter,
|
||||
isSelected: () => currentCollection?.filters.contains(filter) ?? false,
|
||||
);
|
||||
|
|
|
@ -91,9 +91,6 @@ class _TvRailState extends State<TvRail> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final locale = l10n.localeName;
|
||||
|
||||
final navEntries = _getNavEntries(context);
|
||||
return DirectionalSafeArea(
|
||||
end: false,
|
||||
|
@ -107,12 +104,12 @@ class _TvRailState extends State<TvRail> {
|
|||
logo,
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
l10n.appName,
|
||||
context.l10n.appName,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w300,
|
||||
letterSpacing: canHaveLetterSpacing(locale) ? 1 : 0,
|
||||
letterSpacing: canHaveLetterSpacing(context.locale) ? 1 : 0,
|
||||
fontFeatures: const [FontFeature.enable('smcp')],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -223,7 +223,7 @@ class _HistogramState extends State<Histogram> with AutomaticKeepAliveClientMixi
|
|||
)..setAttribute(charts.rendererIdKey, 'customPoint'),
|
||||
];
|
||||
|
||||
final locale = context.l10n.localeName;
|
||||
final locale = context.locale;
|
||||
final timeAxisSpec = _firstDate != null && _lastDate != null
|
||||
? TimeAxisSpec.forLevel(
|
||||
locale: locale,
|
||||
|
@ -232,7 +232,7 @@ class _HistogramState extends State<Histogram> with AutomaticKeepAliveClientMixi
|
|||
last: _lastDate!,
|
||||
)
|
||||
: null;
|
||||
final measureFormat = NumberFormat.decimalPattern(locale);
|
||||
final tickFormatter = NumberFormat.decimalPattern(locale);
|
||||
|
||||
final domainAxis = charts.DateTimeAxisSpec(
|
||||
renderSpec: charts.SmallTickRendererSpec(
|
||||
|
@ -254,7 +254,7 @@ class _HistogramState extends State<Histogram> with AutomaticKeepAliveClientMixi
|
|||
),
|
||||
tickFormatterSpec: charts.BasicNumericTickFormatterSpec((v) {
|
||||
// localize and hide 0
|
||||
return (v == null || v == 0) ? '' : measureFormat.format(v);
|
||||
return (v == null || v == 0) ? '' : tickFormatter.format(v);
|
||||
}),
|
||||
),
|
||||
defaultRenderer: charts.LineRendererConfig(
|
||||
|
@ -304,8 +304,7 @@ class _HistogramState extends State<Histogram> with AutomaticKeepAliveClientMixi
|
|||
}
|
||||
|
||||
Widget _buildSelectionRow() {
|
||||
final locale = context.l10n.localeName;
|
||||
final numberFormat = NumberFormat.decimalPattern(locale);
|
||||
final countFormatter = NumberFormat.decimalPattern(context.locale);
|
||||
|
||||
return ValueListenableBuilder<_EntryByDate?>(
|
||||
valueListenable: _selection,
|
||||
|
@ -326,7 +325,7 @@ class _HistogramState extends State<Histogram> with AutomaticKeepAliveClientMixi
|
|||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
numberFormat.format(count),
|
||||
countFormatter.format(count),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
|
|
|
@ -35,8 +35,7 @@ class FilterTable<T extends Comparable> extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final numberFormat = NumberFormat.decimalPattern(locale);
|
||||
final countFormatter = NumberFormat.decimalPattern(context.locale);
|
||||
final animate = context.select<Settings, bool>((v) => v.accessibilityAnimations.animate);
|
||||
|
||||
final sortedEntries = entryCountMap.entries.toList();
|
||||
|
@ -104,7 +103,7 @@ class FilterTable<T extends Comparable> extends StatelessWidget {
|
|||
},
|
||||
),
|
||||
Text(
|
||||
numberFormat.format(count),
|
||||
countFormatter.format(count),
|
||||
style: TextStyle(
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
|
|
|
@ -24,8 +24,7 @@ class MimeDonut extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final numberFormat = NumberFormat.decimalPattern(locale);
|
||||
final countFormatter = NumberFormat.decimalPattern(context.locale);
|
||||
|
||||
String formatKey(d) => MimeUtils.displayType(d.key);
|
||||
return AvesDonut(
|
||||
|
@ -33,7 +32,7 @@ class MimeDonut extends StatelessWidget {
|
|||
byTypes: byMimeTypes,
|
||||
animationDuration: animationDuration,
|
||||
formatKey: formatKey,
|
||||
formatValue: numberFormat.format,
|
||||
formatValue: countFormatter.format,
|
||||
colorize: (context, d) {
|
||||
final colors = context.read<AvesColorsData>();
|
||||
return colors.fromString(formatKey(d));
|
||||
|
|
|
@ -16,13 +16,12 @@ class LinearPercentIndicatorText extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final percentFormat = NumberFormat.percentPattern(locale);
|
||||
final percentFormatter = NumberFormat.percentPattern(context.locale);
|
||||
|
||||
return OutlinedText(
|
||||
textSpans: [
|
||||
TextSpan(
|
||||
text: percentFormat.format(percent),
|
||||
text: percentFormatter.format(percent),
|
||||
style: TextStyle(
|
||||
shadows: Theme.of(context).isDark ? AStyles.embossShadows : null,
|
||||
),
|
||||
|
|
|
@ -168,7 +168,7 @@ class _StatsPageState extends State<StatsPage> with FeedbackMixin, VaultAwareMix
|
|||
const Icon(AIcons.size),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Text(formatFileSize(l10n.localeName, _totalSizeBytes)),
|
||||
child: Text(formatFileSize(context.locale, _totalSizeBytes)),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -299,7 +299,7 @@ class _BasicInfoState extends State<_BasicInfo> {
|
|||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final infoUnknown = l10n.viewerInfoUnknown;
|
||||
final locale = l10n.localeName;
|
||||
final locale = context.locale;
|
||||
final use24hour = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
|
||||
// TODO TLAD line break on all characters for the following fields when this is fixed: https://github.com/flutter/flutter/issues/61081
|
||||
|
@ -383,10 +383,9 @@ class _BasicInfoState extends State<_BasicInfo> {
|
|||
// guess whether this is a photo, according to file type
|
||||
final isPhoto = [MimeTypes.heic, MimeTypes.heif, MimeTypes.jpeg, MimeTypes.tiff].contains(entry.mimeType) || entry.isRaw;
|
||||
if (isPhoto) {
|
||||
final numberFormat = NumberFormat('0', locale);
|
||||
final megaPixels = (entry.width * entry.height / 1000000).round();
|
||||
if (megaPixels > 0) {
|
||||
s += ' • ${numberFormat.format(megaPixels)} MP';
|
||||
s += ' • ${NumberFormat('0', locale).format(megaPixels)} MP';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class OverlayDateRow extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final locale = context.locale;
|
||||
final use24hour = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
|
||||
final date = entry.bestDate;
|
||||
|
|
|
@ -17,7 +17,7 @@ class OverlayShootingRow extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = context.l10n.localeName;
|
||||
final locale = context.locale;
|
||||
|
||||
final aperture = details.aperture;
|
||||
final apertureText = aperture != null ? 'ƒ/${NumberFormat('0.0', locale).format(aperture)}' : AText.valueNotAvailable;
|
||||
|
|
|
@ -9,7 +9,7 @@ import 'package:latlong2/latlong.dart';
|
|||
|
||||
class ImageMarker extends StatelessWidget {
|
||||
final int? count;
|
||||
final intl.NumberFormat numberFormat;
|
||||
final intl.NumberFormat countFormatter;
|
||||
final bool drawArrow;
|
||||
final Widget Function(double extent) buildThumbnailImage;
|
||||
|
||||
|
@ -28,7 +28,7 @@ class ImageMarker extends StatelessWidget {
|
|||
required String locale,
|
||||
this.drawArrow = true,
|
||||
required this.buildThumbnailImage,
|
||||
}) : numberFormat = intl.NumberFormat.decimalPattern(locale);
|
||||
}) : countFormatter = intl.NumberFormat.decimalPattern(locale);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -110,7 +110,7 @@ class ImageMarker extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
child: Text(
|
||||
numberFormat.format(count),
|
||||
countFormatter.format(count),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.onPrimary,
|
||||
|
|
Loading…
Reference in a new issue