forked from eatvio/eatvio_app
71 lines
2.0 KiB
Dart
71 lines
2.0 KiB
Dart
import 'package:eatvio_app/features/insights/presentation/widgets/insights_colors.dart';
|
||
import 'package:flutter/material.dart';
|
||
|
||
/// Крупное число + единица + строка с дельтой.
|
||
class InsightsHead extends StatelessWidget {
|
||
const InsightsHead({
|
||
super.key,
|
||
required this.headline,
|
||
required this.unit,
|
||
required this.deltaText,
|
||
this.isDeltaHighlighted = true,
|
||
});
|
||
|
||
final String headline;
|
||
final String unit;
|
||
final String deltaText;
|
||
|
||
/// Зелёная дельта при наличии изменения, иначе нейтральный серый.
|
||
final bool isDeltaHighlighted;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Row(
|
||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||
textBaseline: TextBaseline.alphabetic,
|
||
children: [
|
||
Text(
|
||
headline,
|
||
key: const Key('insights_headline'),
|
||
style: const TextStyle(
|
||
fontSize: 34,
|
||
fontWeight: FontWeight.w800,
|
||
color: InsightsColors.title,
|
||
height: 1.1,
|
||
),
|
||
),
|
||
if (unit.isNotEmpty) ...[
|
||
const SizedBox(width: 6),
|
||
Text(
|
||
unit,
|
||
style: const TextStyle(
|
||
fontSize: 16,
|
||
fontWeight: FontWeight.w600,
|
||
color: InsightsColors.subtitle,
|
||
),
|
||
),
|
||
],
|
||
],
|
||
),
|
||
if (deltaText.isNotEmpty) ...[
|
||
const SizedBox(height: 4),
|
||
Text(
|
||
deltaText,
|
||
key: const Key('insights_delta'),
|
||
style: TextStyle(
|
||
fontSize: 13.5,
|
||
fontWeight: FontWeight.w700,
|
||
color: isDeltaHighlighted
|
||
? InsightsColors.positive
|
||
: InsightsColors.subtitle,
|
||
),
|
||
),
|
||
],
|
||
],
|
||
);
|
||
}
|
||
}
|