Spaces:
Configuration error
Configuration error
File size: 1,978 Bytes
78013c4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import 'package:flutter/material.dart';
import 'package:smart_attendance_app/app/theme.dart';
/// Unified chip widget replacing duplicated _StatusChip, _FilterChip variants
/// across home, history, and profile screens.
///
/// [variant] controls visual style:
/// - [StatusChipVariant.filled] — colored background with matching border
/// - [StatusChipVariant.outlined] — transparent background, colored border only
enum StatusChipVariant { filled, outlined }
class StatusChip extends StatelessWidget {
final String label;
final Color color;
final bool isSelected;
final VoidCallback? onTap;
final StatusChipVariant variant;
const StatusChip({
super.key,
required this.label,
required this.color,
this.isSelected = true,
this.onTap,
this.variant = StatusChipVariant.filled,
});
@override
Widget build(BuildContext context) {
final isActive = isSelected;
final bgColor = isActive
? color.withValues(alpha: variant == StatusChipVariant.filled ? 0.1 : 0.15)
: SasColors.glassBg;
final borderColor = isActive
? color.withValues(alpha: variant == StatusChipVariant.filled ? 0.3 : 0.5)
: SasColors.glassBorder;
final textColor = isActive ? color : SasColors.textMuted;
final child = AnimatedContainer(
duration: SasDurations.fast,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: bgColor,
borderRadius: SasRadius.xlAll,
border: Border.all(
color: borderColor,
width: isActive && variant == StatusChipVariant.outlined ? 2 : 1,
),
),
child: Text(
label,
style: TextStyle(
color: textColor,
fontSize: 11,
fontWeight: isActive ? FontWeight.w700 : FontWeight.w600,
),
),
);
if (onTap != null) {
return GestureDetector(onTap: onTap, child: child);
}
return child;
}
}
|