From 030addcf29058e1b6084675dd28907c7b3d7e494 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:21:48 +0100 Subject: [PATCH] fixed `ReadingValueContainer` text color --- .../lightmeter_pro/widget_lightmeter_pro.dart | 1 + .../widget_container_reading_value.dart | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/screens/metering/components/shared/readings_container/components/lightmeter_pro/widget_lightmeter_pro.dart b/lib/screens/metering/components/shared/readings_container/components/lightmeter_pro/widget_lightmeter_pro.dart index 4a4b8d0..9d5218a 100644 --- a/lib/screens/metering/components/shared/readings_container/components/lightmeter_pro/widget_lightmeter_pro.dart +++ b/lib/screens/metering/components/shared/readings_container/components/lightmeter_pro/widget_lightmeter_pro.dart @@ -12,6 +12,7 @@ class LightmeterProAnimatedDialog extends StatelessWidget { return AnimatedDialog( closedChild: ReadingValueContainer( color: Theme.of(context).colorScheme.errorContainer, + textColor: Theme.of(context).colorScheme.onErrorContainer, values: [ ReadingValue( label: S.of(context).proFeatures, diff --git a/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart b/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart index 10e051e..6968db6 100644 --- a/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart +++ b/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart @@ -15,10 +15,12 @@ class ReadingValue { class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClosedChild { late final List _items; final Color? color; + final Color? textColor; ReadingValueContainer({ required List values, this.color, + this.textColor, super.key, }) { _items = []; @@ -26,15 +28,16 @@ class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClo if (i > 0) { _items.add(const SizedBox(height: Dimens.grid8)); } - _items.add(_ReadingValueBuilder(values[i])); + _items.add(_ReadingValueBuilder(values[i], textColor: textColor)); } } ReadingValueContainer.singleValue({ required ReadingValue value, this.color, + this.textColor, super.key, - }) : _items = [_ReadingValueBuilder(value)]; + }) : _items = [_ReadingValueBuilder(value, textColor: textColor)]; @override Color backgroundColor(BuildContext context) => color ?? Theme.of(context).colorScheme.primaryContainer; @@ -60,20 +63,21 @@ class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClo class _ReadingValueBuilder extends StatelessWidget { final ReadingValue reading; + final Color? textColor; - const _ReadingValueBuilder(this.reading); + const _ReadingValueBuilder(this.reading, {this.textColor}); @override Widget build(BuildContext context) { final textTheme = Theme.of(context).textTheme; - final textColor = Theme.of(context).colorScheme.onPrimaryContainer; + final color = textColor ?? Theme.of(context).colorScheme.onPrimaryContainer; return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( reading.label, - style: textTheme.labelMedium?.copyWith(color: textColor), + style: textTheme.labelMedium?.copyWith(color: color), maxLines: 1, overflow: TextOverflow.visible, softWrap: false, @@ -83,7 +87,7 @@ class _ReadingValueBuilder extends StatelessWidget { duration: Dimens.switchDuration, child: Text( reading.value, - style: textTheme.titleMedium?.copyWith(color: textColor), + style: textTheme.titleMedium?.copyWith(color: color), maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: false,