import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import '../theme/tokens.dart'; /// Shows a themed, transient confirmation toast plus a light haptic tick. /// /// Rendered as a fixed [SnackBar], so it settles just above the app's bottom /// chrome (mini-player + tab bar) rather than over it. Styled to match the /// dense, near-black terminal aesthetic — [TimbreColors.surface] fill, warm /// [TimbreColors.foreground] text, with the live accent used for the leading /// [icon]. Any in-flight toast is cleared first so rapid taps don't stack. void showToast(BuildContext context, String message, {IconData? icon}) { final accent = Theme.of(context).colorScheme.primary; HapticFeedback.selectionClick(); ScaffoldMessenger.of(context) ..clearSnackBars() ..showSnackBar( SnackBar( backgroundColor: TimbreColors.surface, duration: const Duration(seconds: 2), content: Row( children: [ if (icon != null) ...[ Icon(icon, size: 16, color: accent), const SizedBox(width: TimbreSpacing.md), ], Expanded( child: Text( message, style: const TextStyle(color: TimbreColors.foreground), ), ), ], ), ), ); }