Commit 6a9e373
Changed files (5)
lib
l10n
model
storage
screens
lib/l10n/app_en.arb
@@ -488,5 +488,9 @@
"errAccuracyLoss": "There is precision loss expected when exporting with custom time formatters.",
"@errAccuracyLoss": {},
"bottomAppBars": "Bottom dialoge bars",
- "@bottomAppBars": {}
+ "@bottomAppBars": {},
+ "medications": "Medications",
+ "@medications": {},
+ "addMedication": "Add medication",
+ "@addMedication": {}
}
lib/model/storage/settings_store.dart
@@ -307,8 +307,9 @@ class Settings extends ChangeNotifier {
_medications.add(medication);
notifyListeners();
}
- void removeMedication(Medicine medication) {
- _medications.remove(medication);
+ void removeMedicationAt(int index) {
+ assert(index >= 0 && index < _medications.length);
+ _medications.removeAt(index);
notifyListeners();
}
lib/screens/subsettings/graph_markings_screen.dart
@@ -15,8 +15,7 @@ class GraphMarkingsScreen extends StatelessWidget {
// IMPORTANT: When adding more option, like vertical lines, add navigation bar
return Scaffold(
appBar: AppBar(
- title: Text(AppLocalizations.of(context)!.customGraphMarkings),
- backgroundColor: Theme.of(context).primaryColor,
+ forceMaterialTransparency: true,
),
body: Center(child: Consumer<Settings>(
builder: (context, settings, child) {
lib/screens/subsettings/medicine_manager_screen.dart
@@ -0,0 +1,65 @@
+import 'package:blood_pressure_app/model/storage/settings_store.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+import 'package:provider/provider.dart';
+
+class MedicineManagerScreen extends StatelessWidget {
+ const MedicineManagerScreen({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final localizations = AppLocalizations.of(context)!;
+ return Scaffold(
+ appBar: AppBar(
+ forceMaterialTransparency: true,
+ ),
+ body: Center(child: Consumer<Settings>(
+ builder: (context, settings, child) {
+ final medications = settings.medications;
+ return ListView.builder(
+ itemCount: medications.length + 2,
+ itemBuilder: (context, i) {
+ if(i == 0) { // first row
+ return Container(
+ padding: const EdgeInsets.all(10),
+ child: DefaultTextStyle.merge(
+ child: Text(localizations.medications),
+ style: Theme.of(context).textTheme.headlineLarge
+ ),
+ );
+ }
+ if (i > medications.length) { // last row
+ return ListTile(
+ leading: const Icon(Icons.add),
+ title: Text(localizations.addMedication),
+ onTap: () async {
+ // TODO
+ },
+ );
+ }
+ return ListTile(
+ leading: Container(
+ width: 40.0,
+ height: 40.0,
+ decoration: BoxDecoration(
+ color: medications[i-1].color,
+ shape: BoxShape.circle,
+ ),
+ ),
+ title: Text(medications[i-1].designation),
+ subtitle: Text(medications[i-1].defaultDosis.toString()),
+ trailing: IconButton(
+ icon: const Icon(Icons.delete),
+ onPressed: () {
+ settings.removeMedicationAt(i - 1);
+ },
+ ),
+ );
+ }
+ );
+ }),
+ ),
+ );
+ }
+
+}
\ No newline at end of file
lib/screens/settings_screen.dart
@@ -11,6 +11,7 @@ import 'package:blood_pressure_app/platform_integration/platform_client.dart';
import 'package:blood_pressure_app/screens/subsettings/delete_data_screen.dart';
import 'package:blood_pressure_app/screens/subsettings/export_import/export_import_screen.dart';
import 'package:blood_pressure_app/screens/subsettings/graph_markings_screen.dart';
+import 'package:blood_pressure_app/screens/subsettings/medicine_manager_screen.dart';
import 'package:blood_pressure_app/screens/subsettings/version_screen.dart';
import 'package:blood_pressure_app/screens/subsettings/warn_about_screen.dart';
import 'package:file_picker/file_picker.dart';
@@ -266,6 +267,17 @@ class SettingsPage extends StatelessWidget {
settings.bottomAppBars = value;
}
),
+ ListTile(
+ onTap: () {
+ Navigator.push(
+ context,
+ MaterialPageRoute(builder: (context) => const MedicineManagerScreen()),
+ );
+ },
+ leading: const Icon(Icons.medication),
+ title: Text(localizations.medications), // TODO
+ trailing: const Icon(Icons.arrow_forward_ios)
+ )
]),
TitledColumn(
title: Text(localizations.data),