110 lines
3.1 KiB
Dart
110 lines
3.1 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import '../../../../common/theme/theme.dart';
|
||
|
|
import '../../../components/spacer/spacer.dart';
|
||
|
|
import '../inventory_page.dart';
|
||
|
|
|
||
|
|
class InventoryIngredientTile extends StatelessWidget {
|
||
|
|
final IngredientItem item;
|
||
|
|
const InventoryIngredientTile({super.key, required this.item});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Container(
|
||
|
|
margin: const EdgeInsets.only(bottom: 12),
|
||
|
|
padding: const EdgeInsets.all(16),
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
color: AppColor.surface,
|
||
|
|
borderRadius: BorderRadius.circular(16),
|
||
|
|
boxShadow: [
|
||
|
|
BoxShadow(
|
||
|
|
color: AppColor.primaryWithOpacity(0.1),
|
||
|
|
blurRadius: 8,
|
||
|
|
offset: const Offset(0, 2),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
child: Row(
|
||
|
|
children: [
|
||
|
|
Container(
|
||
|
|
width: 60,
|
||
|
|
height: 60,
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
gradient: LinearGradient(colors: AppColor.backgroundGradient),
|
||
|
|
borderRadius: BorderRadius.circular(12),
|
||
|
|
),
|
||
|
|
child: Center(
|
||
|
|
child: Text(item.image, style: const TextStyle(fontSize: 24)),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
const SpaceWidth(16),
|
||
|
|
Expanded(
|
||
|
|
child: Column(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
|
children: [
|
||
|
|
Text(
|
||
|
|
item.name,
|
||
|
|
style: AppStyle.lg.copyWith(
|
||
|
|
fontWeight: FontWeight.bold,
|
||
|
|
color: AppColor.textPrimary,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
SpaceHeight(4),
|
||
|
|
Text(
|
||
|
|
'Stok: ${item.quantity} ${item.unit}',
|
||
|
|
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||
|
|
),
|
||
|
|
SpaceHeight(4),
|
||
|
|
Text(
|
||
|
|
'Min: ${item.minQuantity} ${item.unit}',
|
||
|
|
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
Container(
|
||
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
color: getStatusColor(item.status),
|
||
|
|
borderRadius: BorderRadius.circular(20),
|
||
|
|
),
|
||
|
|
child: Text(
|
||
|
|
getStatusText(item.status),
|
||
|
|
style: AppStyle.sm.copyWith(
|
||
|
|
fontWeight: FontWeight.bold,
|
||
|
|
color: AppColor.textWhite,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Color getStatusColor(String status) {
|
||
|
|
switch (status) {
|
||
|
|
case 'available':
|
||
|
|
return AppColor.success;
|
||
|
|
case 'low_stock':
|
||
|
|
return AppColor.warning;
|
||
|
|
case 'out_of_stock':
|
||
|
|
return AppColor.error;
|
||
|
|
default:
|
||
|
|
return AppColor.textSecondary;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
String getStatusText(String status) {
|
||
|
|
switch (status) {
|
||
|
|
case 'available':
|
||
|
|
return 'Tersedia';
|
||
|
|
case 'low_stock':
|
||
|
|
return 'Stok Rendah';
|
||
|
|
case 'out_of_stock':
|
||
|
|
return 'Habis';
|
||
|
|
default:
|
||
|
|
return 'Unknown';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|