import 'package:flutter/material.dart'; import '../../l10n/app_localizations.dart'; import '../../utils/money.dart'; import '../../utils/tab_orders.dart'; /// The line above the drinks of one order: "—— 12:32 today ——". With /// [totalInCents] it adds what the order costs; with [onTap] it opens and /// closes the order, a chevron showing whether it is [expanded]. class OrderDivider extends StatelessWidget { final DateTime startedAt; final int? totalInCents; final bool expanded; final VoidCallback? onTap; const OrderDivider({ super.key, required this.startedAt, this.totalInCents, this.expanded = true, this.onTap, }); @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context); final locale = Localizations.localeOf(context).toLanguageTag(); final scheme = Theme.of(context).colorScheme; final line = Expanded( child: Divider(color: scheme.onSurface.withValues(alpha: 0.18)), ); final label = [ orderTimeLabel(l10n, locale, startedAt), if (totalInCents != null) totalInCents!.asEuro, ].join(' – '); final style = Theme.of(context).textTheme.bodySmall?.copyWith( fontWeight: FontWeight.w700, color: scheme.onSurface.withValues(alpha: 0.6), ); final row = Padding( padding: const EdgeInsets.only(top: 6, bottom: 2), child: Row( children: [ line, Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisSize: MainAxisSize.min, children: [ Text(label, style: style), if (onTap != null) ...[ const SizedBox(width: 2), Icon( expanded ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded, size: 18, color: style?.color, ), ], ], ), ), line, ], ), ); if (onTap == null) return row; return InkWell( onTap: onTap, borderRadius: BorderRadius.circular(8), child: row, ); } }