update
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/// 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 Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Section Title
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// Action Grid
|
||||
_buildActionGrid(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionGrid() {
|
||||
// Determine grid layout based on number of items
|
||||
final int crossAxisCount = actions.length <= 2 ? 2 : 3;
|
||||
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: crossAxisCount,
|
||||
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,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user