import 'package:flutter/material.dart'; import '../theme/app_theme.dart'; class PillTabBar extends StatelessWidget { final List tabs; final int selectedIndex; final ValueChanged onSelect; final EdgeInsetsGeometry padding; const PillTabBar({ super.key, required this.tabs, required this.selectedIndex, required this.onSelect, this.padding = EdgeInsets.zero, }); @override Widget build(BuildContext context) { final theme = Theme.of(context); final tokens = context.appTokens; final isDark = theme.brightness == Brightness.dark; final activeBg = theme.colorScheme.primary.withValues(alpha: 0.12); final activeFg = theme.colorScheme.primary; final idleBg = isDark ? Colors.white.withValues(alpha: 0.04) : Colors.black.withValues(alpha: 0.03); return Padding( padding: padding, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: List.generate(tabs.length, (i) { final selected = i == selectedIndex; return Padding( padding: const EdgeInsets.only(right: 8), child: GestureDetector( onTap: () => onSelect(i), child: AnimatedContainer( duration: const Duration(milliseconds: 150), padding: const EdgeInsets.symmetric( horizontal: 16, vertical: 8, ), decoration: BoxDecoration( color: selected ? activeBg : idleBg, borderRadius: BorderRadius.circular(20), ), child: Text( tabs[i], style: TextStyle( fontSize: 13, fontWeight: selected ? FontWeight.w600 : FontWeight.w500, color: selected ? activeFg : tokens.mutedForeground, ), ), ), ), ); }), ), ), ); } }