forked from eatvio/eatvio_app
81 lines
2.4 KiB
Dart
81 lines
2.4 KiB
Dart
import 'package:eatvio_app/features/insights/presentation/cubit/insights_panel.dart';
|
|
import 'package:eatvio_app/features/insights/presentation/widgets/insights_colors.dart';
|
|
import 'package:eatvio_app/generated/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
extension InsightsPanelLabel on InsightsPanel {
|
|
String label(S s) {
|
|
switch (this) {
|
|
case InsightsPanel.weight:
|
|
return s.insights_tab_weight;
|
|
case InsightsPanel.bmi:
|
|
return s.insights_tab_bmi;
|
|
case InsightsPanel.measures:
|
|
return s.insights_tab_measures;
|
|
case InsightsPanel.daily:
|
|
return s.insights_tab_daily;
|
|
case InsightsPanel.intra:
|
|
return s.insights_tab_intra;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Горизонтально прокручиваемые вкладки (`l-tab`).
|
|
class InsightsTabs extends StatelessWidget {
|
|
const InsightsTabs({
|
|
super.key,
|
|
required this.panels,
|
|
required this.selected,
|
|
required this.onSelected,
|
|
});
|
|
|
|
final List<InsightsPanel> panels;
|
|
final InsightsPanel selected;
|
|
final ValueChanged<InsightsPanel> onSelected;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final s = S.of(context);
|
|
return SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
children: [
|
|
for (final panel in panels)
|
|
InkWell(
|
|
key: Key('insights_tab_${panel.name}'),
|
|
onTap: () => onSelected(panel),
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 12,
|
|
vertical: 10,
|
|
),
|
|
decoration: BoxDecoration(
|
|
border: Border(
|
|
bottom: BorderSide(
|
|
color: panel == selected
|
|
? InsightsColors.blue
|
|
: Colors.transparent,
|
|
width: 2,
|
|
),
|
|
),
|
|
),
|
|
child: Text(
|
|
panel.label(s),
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: panel == selected
|
|
? FontWeight.w700
|
|
: FontWeight.w600,
|
|
color: panel == selected
|
|
? InsightsColors.blue
|
|
: InsightsColors.subtitle,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|