forked from eatvio/eatvio_app
feat(insights): first isights impemetation
This commit is contained in:
76
lib/features/insights/presentation/widgets/series_chips.dart
Normal file
76
lib/features/insights/presentation/widgets/series_chips.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
import 'package:eatvio_app/features/insights/presentation/widgets/insights_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SeriesChipData {
|
||||
const SeriesChipData({
|
||||
required this.label,
|
||||
required this.color,
|
||||
required this.isVisible,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final Color color;
|
||||
final bool isVisible;
|
||||
}
|
||||
|
||||
/// Чипы-переключатели серий под графиком.
|
||||
class SeriesChips extends StatelessWidget {
|
||||
const SeriesChips({super.key, required this.chips, required this.onToggle});
|
||||
|
||||
final List<SeriesChipData> chips;
|
||||
final ValueChanged<int> onToggle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
for (var i = 0; i < chips.length; i++)
|
||||
Opacity(
|
||||
opacity: chips[i].isVisible ? 1 : 0.45,
|
||||
child: InkWell(
|
||||
key: Key('insights_series_$i'),
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
onTap: () => onToggle(i),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
vertical: 7,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
border: Border.all(color: InsightsColors.border, width: 1.5),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: chips[i].color,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
chips[i].label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: InsightsColors.title,
|
||||
decoration: chips[i].isVisible
|
||||
? TextDecoration.none
|
||||
: TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user