Files
worker/lib/features/home/presentation/widgets/quick_action_item.dart
Phuoc Nguyen f95fa9d0a6 prodycrts
2025-10-20 15:56:34 +07:00

110 lines
3.1 KiB
Dart

/// Widget: Quick Action Item
///
/// Individual action button with icon and label.
/// Used in quick action grids on the home screen.
library;
import 'package:flutter/material.dart';
import 'package:worker/core/theme/colors.dart';
/// Quick Action Item Widget
///
/// Displays an icon button with a label below.
/// Supports optional badge for notifications or counts.
class QuickActionItem extends StatelessWidget {
/// Icon to display
final IconData icon;
/// Label text
final String label;
/// Optional badge text (e.g., "3" for cart items)
final String? badge;
/// Tap callback
final VoidCallback? onTap;
const QuickActionItem({
super.key,
required this.icon,
required this.label,
this.badge,
this.onTap,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Container(
padding: const EdgeInsets.all(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Icon with optional badge
Stack(
clipBehavior: Clip.none,
children: [
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppColors.primaryBlue.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
),
child: Icon(
icon,
size: 20,
color: AppColors.primaryBlue,
),
),
// Badge
if (badge != null && badge!.isNotEmpty)
Positioned(
top: -4,
right: -4,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 6,
vertical: 2,
),
decoration: BoxDecoration(
color: AppColors.danger,
borderRadius: BorderRadius.circular(10),
),
constraints: const BoxConstraints(
minWidth: 20,
minHeight: 20,
),
child: Text(
badge!,
style: const TextStyle(
color: Colors.white,
fontSize: 11,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
),
],
),
const SizedBox(height: 8),
// Label
Text(
label,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
],
),
),
);
}
}