Commit 37e4014

derdilla <derdilla06@gmail.com>
2023-07-27 16:01:56
use material you
1 parent 9760ae2
Changed files (2)
lib/screens/add_measurement.dart
@@ -157,42 +157,44 @@ class _AddMeasurementPageState extends State<AddMeasurementPage> {
                       ),
                       Row(
                         children: [
-                          ElevatedButton(
-                              key: const Key('btnCancel'),
-                              onPressed: () {
-                                if (widget.addInitialValuesOnCancel) {
-                                  assert(widget.initTime != null);
-                                  Provider.of<BloodPressureModel>(context, listen: false).add(BloodPressureRecord(
-                                      widget.initTime ?? DateTime.now(),
-                                      widget.initSys,
-                                      widget.initDia,
-                                      widget.initPul,
-                                      widget.initNote));
-                                }
-                                Navigator.of(context).pop();
-                              },
-                              style: ElevatedButton.styleFrom(backgroundColor: Theme.of(context).unselectedWidgetColor),
-                              child: Text(AppLocalizations.of(context)!.btnCancel)),
+                          TextButton(
+                            key: const Key('btnCancel'),
+                            onPressed: () {
+                              if (widget.addInitialValuesOnCancel) {
+                                assert(widget.initTime != null);
+                                Provider.of<BloodPressureModel>(context, listen: false).add(BloodPressureRecord(
+                                    widget.initTime ?? DateTime.now(),
+                                    widget.initSys,
+                                    widget.initDia,
+                                    widget.initPul,
+                                    widget.initNote));
+                              }
+                              Navigator.of(context).pop();
+                            },
+
+                            child: Text(AppLocalizations.of(context)!.btnCancel)
+                          ),
                           const Spacer(),
-                          ElevatedButton(
-                              key: const Key('btnSave'),
-                              onPressed: () async {
-                                if ((_formKey.currentState?.validate() ?? false) ||
-                                    (_systolic == null && _diastolic == null && _pulse == null && _note != null)){
-                                  final settings = Provider.of<Settings>(context, listen: false);
-                                  final model = Provider.of<BloodPressureModel>(context, listen: false);
-                                  final navigator = Navigator.of(context);
+                          FilledButton.icon(
+                            key: const Key('btnSave'),
+                            onPressed: () async {
+                              if ((_formKey.currentState?.validate() ?? false) ||
+                                  (_systolic == null && _diastolic == null && _pulse == null && _note != null)){
+                                final settings = Provider.of<Settings>(context, listen: false);
+                                final model = Provider.of<BloodPressureModel>(context, listen: false);
+                                final navigator = Navigator.of(context);
 
-                                  await model.add(BloodPressureRecord(_time, _systolic, _diastolic, _pulse, _note));
-                                  if (settings.exportAfterEveryEntry && context.mounted) {
-                                    final exporter = Exporter(context);
-                                    exporter.export();
-                                  }
-                                  navigator.pop();
+                                await model.add(BloodPressureRecord(_time, _systolic, _diastolic, _pulse, _note));
+                                if (settings.exportAfterEveryEntry && context.mounted) {
+                                  final exporter = Exporter(context);
+                                  exporter.export();
                                 }
-                              },
-                              style: ElevatedButton.styleFrom(backgroundColor: Theme.of(context).primaryColor),
-                              child: Text(AppLocalizations.of(context)!.btnSave))
+                                navigator.pop();
+                              }
+                            },
+                            icon: Icon(Icons.save),
+                            label: Text(AppLocalizations.of(context)!.btnSave),
+                          )
                         ],
                       )
                     ]);
lib/main.dart
@@ -39,12 +39,19 @@ class AppRoot extends StatelessWidget {
         // TODO: Use Material 3 everywhere. Some components like the add button on the start page and the settings
         // switches already use it, so they need to get this theme override removed
         theme: ThemeData(
-            primaryColor: settings.accentColor,
+            colorScheme: ColorScheme.fromSeed(
+                seedColor: settings.accentColor,
+                brightness: Brightness.light,
+            ),
+            useMaterial3: true
         ),
         darkTheme: ThemeData(
-          brightness: Brightness.dark,
-          canvasColor: Colors.black,
-          primaryColor: settings.accentColor.shade400,
+          colorScheme: ColorScheme.fromSeed(
+            seedColor: settings.accentColor,
+            brightness: Brightness.dark,
+            background: Colors.black
+          ),
+          useMaterial3: true
         ),
         themeMode: mode,
         localizationsDelegates: const [