add price policy
This commit is contained in:
@@ -83,26 +83,70 @@ class QuickActionSection extends StatelessWidget {
|
||||
}
|
||||
|
||||
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,
|
||||
// Determine grid columns based on item count
|
||||
// If 2 items: 2 columns (no scroll, rectangular aspect ratio)
|
||||
// If 3 items: 3 columns (no scroll)
|
||||
// If more than 3: 3 columns (scrollable horizontally)
|
||||
final int crossAxisCount = actions.length == 2 ? 2 : 3;
|
||||
final bool isScrollable = actions.length > 3;
|
||||
|
||||
// Use rectangular aspect ratio for 2 items to reduce height
|
||||
// 1.5 means width is 1.5x the height (more rectangular/wider)
|
||||
final double aspectRatio = actions.length == 2 ? 1.5 : 0.85;
|
||||
|
||||
if (!isScrollable) {
|
||||
// Non-scrollable grid for 2 or 3 items
|
||||
return GridView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: crossAxisCount,
|
||||
childAspectRatio: aspectRatio,
|
||||
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,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Scrollable horizontal grid for more than 3 items
|
||||
// Calculate grid height based on number of rows needed
|
||||
final int rows = (actions.length / crossAxisCount).ceil();
|
||||
const double itemHeight = 100; // Approximate height of each item
|
||||
final double gridHeight = (rows * itemHeight) + ((rows - 1) * 8);
|
||||
|
||||
return SizedBox(
|
||||
height: gridHeight,
|
||||
child: GridView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
scrollDirection: Axis.horizontal,
|
||||
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,
|
||||
);
|
||||
},
|
||||
),
|
||||
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