109 lines
2.9 KiB
Dart
109 lines
2.9 KiB
Dart
/// Widget: Quick Action Section
|
|
///
|
|
/// Section container with title and grid of action items.
|
|
/// Groups related actions together (e.g., Products & Cart, Loyalty, etc.)
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:worker/features/home/presentation/widgets/quick_action_item.dart';
|
|
|
|
/// Quick Action Section Data Model
|
|
class QuickAction {
|
|
final IconData icon;
|
|
final String label;
|
|
final String? badge;
|
|
final VoidCallback? onTap;
|
|
|
|
const QuickAction({
|
|
required this.icon,
|
|
required this.label,
|
|
this.badge,
|
|
this.onTap,
|
|
});
|
|
}
|
|
|
|
/// Quick Action Section Widget
|
|
///
|
|
/// Displays a titled card containing a grid of action buttons.
|
|
/// Each section groups related functionality.
|
|
class QuickActionSection extends StatelessWidget {
|
|
/// Section title
|
|
final String title;
|
|
|
|
/// List of actions in this section
|
|
final List<QuickAction> actions;
|
|
|
|
const QuickActionSection({
|
|
super.key,
|
|
required this.title,
|
|
required this.actions,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
margin: const EdgeInsets.only(bottom: 16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.07),
|
|
blurRadius: 15,
|
|
offset: const Offset(0, 4),
|
|
),
|
|
],
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
spacing: 16,
|
|
children: [
|
|
// Section Title
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w700,
|
|
color: Color(0xFF212121), // --text-dark
|
|
height: 1.0, // Reduce line height to minimize spacing
|
|
),
|
|
),
|
|
// Action Grid (always 3 columns to match HTML)
|
|
// Using Transform to remove spacing between title and grid
|
|
Transform.translate(
|
|
offset: const Offset(0, -4),
|
|
child: _buildActionGrid(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildActionGrid() {
|
|
return GridView.builder(
|
|
padding: EdgeInsets.zero, // Remove default GridView padding
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 3, // Always 3 columns to match HTML
|
|
childAspectRatio: 1.0,
|
|
crossAxisSpacing: 8,
|
|
mainAxisSpacing: 8,
|
|
),
|
|
itemCount: actions.length,
|
|
itemBuilder: (context, index) {
|
|
final action = actions[index];
|
|
return QuickActionItem(
|
|
icon: action.icon,
|
|
label: action.label,
|
|
badge: action.badge,
|
|
onTap: action.onTap,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|