122 lines
3.8 KiB
Dart
122 lines
3.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../domain/entities/warehouse_entity.dart';
|
|
|
|
/// Reusable warehouse card widget
|
|
/// Displays warehouse information in a card format
|
|
class WarehouseCard extends StatelessWidget {
|
|
final WarehouseEntity warehouse;
|
|
final VoidCallback onTap;
|
|
|
|
const WarehouseCard({
|
|
super.key,
|
|
required this.warehouse,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final colorScheme = theme.colorScheme;
|
|
|
|
return Card(
|
|
elevation: 2,
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(12),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Warehouse name
|
|
Text(
|
|
warehouse.name,
|
|
style: theme.textTheme.titleMedium?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
color: colorScheme.onSurface,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
|
|
// Warehouse code
|
|
Row(
|
|
children: [
|
|
Icon(
|
|
Icons.qr_code,
|
|
size: 16,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
'Code: ${warehouse.code}',
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 4),
|
|
|
|
// Items count
|
|
Row(
|
|
children: [
|
|
Icon(
|
|
Icons.inventory_2_outlined,
|
|
size: 16,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
'Items: ${warehouse.totalCount}',
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
// Description (if available)
|
|
if (warehouse.description != null &&
|
|
warehouse.description!.isNotEmpty) ...[
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
warehouse.description!,
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: colorScheme.onSurfaceVariant,
|
|
fontStyle: FontStyle.italic,
|
|
),
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
|
|
// NG Warehouse badge (if applicable)
|
|
if (warehouse.isNGWareHouse) ...[
|
|
const SizedBox(height: 8),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 8,
|
|
vertical: 4,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.errorContainer,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Text(
|
|
'NG Warehouse',
|
|
style: theme.textTheme.labelSmall?.copyWith(
|
|
color: colorScheme.onErrorContainer,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|