Commit c467e17
Changed files (8)
lib
components
l10n
screens
lib/components/measurement_list.dart
@@ -10,8 +10,8 @@ import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class MeasurementList extends StatelessWidget {
- late final _tableElementsSizes;
- late final _sideFlex;
+ late final List<int> _tableElementsSizes;
+ late final int _sideFlex;
MeasurementList(BuildContext context, {super.key}) {
if (MediaQuery.of(context).size.width < 1000) {
@@ -37,7 +37,7 @@ class MeasurementList extends StatelessWidget {
),
Expanded(
flex: _tableElementsSizes[0],
- child: Text(AppLocalizations.of(context)!.time, style: TextStyle(fontWeight: FontWeight.bold))),
+ child: Text(AppLocalizations.of(context)!.time, style: const TextStyle(fontWeight: FontWeight.bold))),
Expanded(
flex: _tableElementsSizes[1],
child: Text(AppLocalizations.of(context)!.sysShort, style: TextStyle(fontWeight: FontWeight.bold, color: settings.sysColor))),
@@ -49,7 +49,7 @@ class MeasurementList extends StatelessWidget {
child: Text(AppLocalizations.of(context)!.pulShort, style: TextStyle(fontWeight: FontWeight.bold, color: settings.pulColor))),
Expanded(
flex: _tableElementsSizes[4],
- child: Text(AppLocalizations.of(context)!.notes, style: TextStyle(fontWeight: FontWeight.bold))),
+ child: Text(AppLocalizations.of(context)!.notes, style: const TextStyle(fontWeight: FontWeight.bold))),
Expanded(
flex: _sideFlex,
child: const SizedBox(),
lib/l10n/app_en.arb
@@ -337,5 +337,6 @@
"@last30Days": {},
"allowMissingValues": "Allow missing values",
"@allowMissingValues": {},
- "errTimeAfterNow": "The selected time of day is after this moment. We have automatically reset it to the current time. You can disable this validation in the settings!"
+ "errTimeAfterNow": "The selected time of day is after this moment. We have automatically reset it to the current time. You can disable this validation in the settings!",
+ "language": "Language"
}
lib/model/ram_only_implementations.dart
@@ -70,6 +70,7 @@ class RamSettings extends ChangeNotifier implements Settings {
String _defaultExportDir = '';
bool _exportAfterEveryEntry = false;
bool _allowMissingValues = false;
+ Locale? _language;
RamSettings() {
_accentColor = createMaterialColor(0xFF009688);
@@ -363,6 +364,15 @@ class RamSettings extends ChangeNotifier implements Settings {
notifyListeners();
}
+ @override
+ Locale? get language => _language;
+
+ @override
+ set language(Locale? value) {
+ _language = value;
+ notifyListeners();
+ }
+
@override
void changeStepSize(TimeStep value) {
graphStepSize = value;
lib/model/settings_store.dart
@@ -474,6 +474,17 @@ class Settings extends ChangeNotifier {
_prefs.setBool('exportAfterEveryEntry', value);
notifyListeners();
}
+
+ Locale? get language {
+ final value = _prefs.getString('language');
+ if (value?.isEmpty ?? true) return null;
+ return Locale(value ?? 'en');
+ }
+
+ set language (Locale? value) {
+ _prefs.setString('language', value?.languageCode ?? '');
+ notifyListeners();
+ }
}
enum TimeStep {
lib/screens/settings.dart
@@ -9,6 +9,7 @@ import 'package:blood_pressure_app/screens/subsettings/warn_about.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+import 'package:locale_names/locale_names.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -79,6 +80,20 @@ class SettingsPage extends StatelessWidget {
}
},
),
+ DropDownSettingsTile<Locale?>(
+ key: const Key('language'),
+ leading: const Icon(Icons.language),
+ title: Text(AppLocalizations.of(context)!.language),
+ value: settings.language,
+ items: [
+ DropdownMenuItem(value: null, child: Text(AppLocalizations.of(context)!.system)),
+ for (final l in AppLocalizations.supportedLocales)
+ DropdownMenuItem(value: l, child: Text(l.nativeDisplayLanguage ?? l.languageCode)),
+ ],
+ onChanged: (Locale? value) {
+ settings.language = value;
+ },
+ ),
SliderSettingsTile(
key: const Key('iconSize'),
title: Text(AppLocalizations.of(context)!.iconSize),
lib/main.dart
@@ -50,6 +50,7 @@ class AppRoot extends StatelessWidget {
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
+ locale: settings.language,
home: const AppHome(),
);
});
pubspec.lock
@@ -381,6 +381,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.0"
+ locale_names:
+ dependency: "direct main"
+ description:
+ name: locale_names
+ sha256: b536de2e2e46b34a69687e637ca95cdb60fe931a27bb3ad66344c527ebe8b432
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.0"
logging:
dependency: transitive
description:
pubspec.yaml
@@ -49,6 +49,7 @@ dependencies:
pdf: ^3.10.4
jsaver: ^1.2.0
package_info_plus: ^4.0.2
+ locale_names: ^1.0.0
dev_dependencies:
flutter_test: