Files
worker/lib/features/home/presentation/widgets/quick_action_item.dart
Phuoc Nguyen fbeaa3c9e8 fix
2025-10-24 14:07:22 +07:00

121 lines
3.6 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 Material(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
padding: const EdgeInsets.all(16),
child: Stack(
alignment: Alignment.center, // Center the column within the stack
clipBehavior: Clip.none,
children: [
Column(
mainAxisSize: MainAxisSize.max, // Take all available space
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Icon
Icon(
icon,
size: 32,
color: AppColors.primaryBlue,
),
const SizedBox(height: 8),
// Label
Text(
label,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Color(0xFF212121), // --text-dark
),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
// Badge (positioned absolute like HTML)
if (badge != null && badge!.isNotEmpty)
Positioned(
top: -4,
right: -4,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: AppColors.danger,
borderRadius: BorderRadius.circular(12),
),
constraints: const BoxConstraints(
minWidth: 20,
),
child: Text(
badge!,
style: const TextStyle(
color: Colors.white,
fontSize: 11,
fontWeight: FontWeight.w700,
),
textAlign: TextAlign.center,
),
),
),
],
),
),
),
);
}
}