From a1f4844f6c3e4b46da566b4ccf30bad734acfa2d Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Tue, 4 Aug 2026 11:45:54 +0200 Subject: [PATCH] Replace more hard coded colors with theme generated ones --- lib/core/widgets/error.dart | 6 +++++- .../add_exercise_multiselect_button.dart | 21 +++++++++---------- .../add_exercise/image_details_form.dart | 8 +++---- .../add_exercise/steps/step_5_images.dart | 18 +++++++++------- .../routines/widgets/plate_calculator.dart | 6 ++++-- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/lib/core/widgets/error.dart b/lib/core/widgets/error.dart index 7009551de..21695c022 100644 --- a/lib/core/widgets/error.dart +++ b/lib/core/widgets/error.dart @@ -154,7 +154,11 @@ class _PlainErrorBody extends StatelessWidget { const SizedBox(height: 8), SelectableText( stacktrace.toString(), - style: const TextStyle(fontFamily: 'monospace', fontSize: 11, color: Colors.grey), + style: TextStyle( + fontFamily: 'monospace', + fontSize: 11, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), ), ], ], diff --git a/lib/features/exercises/widgets/add_exercise/add_exercise_multiselect_button.dart b/lib/features/exercises/widgets/add_exercise/add_exercise_multiselect_button.dart index ae854471f..91fbabe48 100644 --- a/lib/features/exercises/widgets/add_exercise/add_exercise_multiselect_button.dart +++ b/lib/features/exercises/widgets/add_exercise/add_exercise_multiselect_button.dart @@ -28,6 +28,11 @@ class _AddExerciseMultiselectButtonState extends State extends State { widget.onAdd(widget.submissionImage); }, style: ElevatedButton.styleFrom( - backgroundColor: Theme.of(context).primaryColor, - foregroundColor: Colors.white, + backgroundColor: Theme.of(context).colorScheme.primary, + foregroundColor: Theme.of(context).colorScheme.onPrimary, padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 12), ), child: Text( AppLocalizations.of(context).add, - style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white), + style: const TextStyle(fontWeight: FontWeight.bold), ), ), ], @@ -181,7 +181,7 @@ class ImagePreview extends StatelessWidget { constraints: const BoxConstraints(maxWidth: 300, maxHeight: 200), decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey.shade300), + border: Border.all(color: Theme.of(context).colorScheme.outlineVariant), ), child: ClipRRect( borderRadius: BorderRadius.circular(8), diff --git a/lib/features/exercises/widgets/add_exercise/steps/step_5_images.dart b/lib/features/exercises/widgets/add_exercise/steps/step_5_images.dart index c5c5f4c7c..8ac1f2cb0 100644 --- a/lib/features/exercises/widgets/add_exercise/steps/step_5_images.dart +++ b/lib/features/exercises/widgets/add_exercise/steps/step_5_images.dart @@ -203,13 +203,17 @@ class _Step5ImagesState extends ConsumerState with ExerciseImagePic return Column( children: [ const SizedBox(height: 20), - Icon(Icons.add_photo_alternate, size: 80, color: Colors.grey.shade400), + Icon( + Icons.add_photo_alternate, + size: 80, + color: Theme.of(context).colorScheme.outline, + ), const SizedBox(height: 16), Text( 'No images selected', - style: Theme.of( - context, - ).textTheme.titleMedium?.copyWith(color: Colors.grey.shade600), + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), ), const SizedBox(height: 24), // Camera and Gallery buttons @@ -240,9 +244,9 @@ class _Step5ImagesState extends ConsumerState with ExerciseImagePic padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Text( 'Only JPEG, PNG and WEBP files below 20 MB are supported', - style: Theme.of( - context, - ).textTheme.bodySmall?.copyWith(color: Colors.grey.shade600), + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), textAlign: TextAlign.center, ), ), diff --git a/lib/features/routines/widgets/plate_calculator.dart b/lib/features/routines/widgets/plate_calculator.dart index c6a9cc4f9..d3baa1418 100644 --- a/lib/features/routines/widgets/plate_calculator.dart +++ b/lib/features/routines/widgets/plate_calculator.dart @@ -34,7 +34,9 @@ class PlateWeight extends StatelessWidget { alignment: Alignment.center, margin: EdgeInsets.all(margin), decoration: BoxDecoration( - color: isSelected ? color : Colors.black12, + // Selected shows the real plate color, so its rim and label stay + // black whatever the theme. Unselected sits on the surface instead. + color: isSelected ? color : Theme.of(context).colorScheme.surfaceContainerHighest, shape: BoxShape.circle, border: Border.all(color: Colors.black, width: isSelected ? 2 : 0), ), @@ -44,7 +46,7 @@ class PlateWeight extends StatelessWidget { value.toString(), textAlign: TextAlign.center, style: TextStyle( - color: isSelected ? Colors.black : Colors.black87, + color: isSelected ? Colors.black : Theme.of(context).colorScheme.onSurfaceVariant, fontWeight: isSelected ? FontWeight.bold : FontWeight.normal, ), ),