fixed ReadingValueContainer text color

This commit is contained in:
Vadim 2024-01-12 13:21:48 +01:00
parent 1d149425ab
commit 030addcf29
2 changed files with 11 additions and 6 deletions

View file

@ -12,6 +12,7 @@ class LightmeterProAnimatedDialog extends StatelessWidget {
return AnimatedDialog( return AnimatedDialog(
closedChild: ReadingValueContainer( closedChild: ReadingValueContainer(
color: Theme.of(context).colorScheme.errorContainer, color: Theme.of(context).colorScheme.errorContainer,
textColor: Theme.of(context).colorScheme.onErrorContainer,
values: [ values: [
ReadingValue( ReadingValue(
label: S.of(context).proFeatures, label: S.of(context).proFeatures,

View file

@ -15,10 +15,12 @@ class ReadingValue {
class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClosedChild { class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClosedChild {
late final List<Widget> _items; late final List<Widget> _items;
final Color? color; final Color? color;
final Color? textColor;
ReadingValueContainer({ ReadingValueContainer({
required List<ReadingValue> values, required List<ReadingValue> values,
this.color, this.color,
this.textColor,
super.key, super.key,
}) { }) {
_items = []; _items = [];
@ -26,15 +28,16 @@ class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClo
if (i > 0) { if (i > 0) {
_items.add(const SizedBox(height: Dimens.grid8)); _items.add(const SizedBox(height: Dimens.grid8));
} }
_items.add(_ReadingValueBuilder(values[i])); _items.add(_ReadingValueBuilder(values[i], textColor: textColor));
} }
} }
ReadingValueContainer.singleValue({ ReadingValueContainer.singleValue({
required ReadingValue value, required ReadingValue value,
this.color, this.color,
this.textColor,
super.key, super.key,
}) : _items = [_ReadingValueBuilder(value)]; }) : _items = [_ReadingValueBuilder(value, textColor: textColor)];
@override @override
Color backgroundColor(BuildContext context) => color ?? Theme.of(context).colorScheme.primaryContainer; Color backgroundColor(BuildContext context) => color ?? Theme.of(context).colorScheme.primaryContainer;
@ -60,20 +63,21 @@ class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClo
class _ReadingValueBuilder extends StatelessWidget { class _ReadingValueBuilder extends StatelessWidget {
final ReadingValue reading; final ReadingValue reading;
final Color? textColor;
const _ReadingValueBuilder(this.reading); const _ReadingValueBuilder(this.reading, {this.textColor});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final textTheme = Theme.of(context).textTheme; final textTheme = Theme.of(context).textTheme;
final textColor = Theme.of(context).colorScheme.onPrimaryContainer; final color = textColor ?? Theme.of(context).colorScheme.onPrimaryContainer;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
reading.label, reading.label,
style: textTheme.labelMedium?.copyWith(color: textColor), style: textTheme.labelMedium?.copyWith(color: color),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.visible, overflow: TextOverflow.visible,
softWrap: false, softWrap: false,
@ -83,7 +87,7 @@ class _ReadingValueBuilder extends StatelessWidget {
duration: Dimens.switchDuration, duration: Dimens.switchDuration,
child: Text( child: Text(
reading.value, reading.value,
style: textTheme.titleMedium?.copyWith(color: textColor), style: textTheme.titleMedium?.copyWith(color: color),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
softWrap: false, softWrap: false,