cargo66/lib/presentation/widgets/order_card.dart

226 lines
7.4 KiB
Dart
Raw Normal View History

2024-08-19 11:31:03 +00:00
import 'package:easy_localization/easy_localization.dart';
2024-07-23 11:36:50 +00:00
import 'package:flutter/material.dart';
import '../../configs/configs.dart';
import '../../core/core.dart';
2024-08-08 18:34:30 +00:00
import '../../domain/domain.dart';
2024-07-29 06:40:26 +00:00
import 'vertical_line.dart';
2024-07-23 11:36:50 +00:00
2024-08-29 08:48:59 +00:00
final infoStyle = AppText.b2b!.copyWith(
color: const Color(0xFF57575C),
fontSize: 16,
);
2024-07-23 11:36:50 +00:00
class OrderCard extends StatelessWidget {
2024-08-08 18:34:30 +00:00
final OrderEntity order;
const OrderCard({required this.order, super.key});
2024-07-23 11:36:50 +00:00
@override
Widget build(BuildContext context) {
return Card(
color: Colors.white,
margin: Space.all(.8, 0.5),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/// Track number
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
2024-08-08 18:34:30 +00:00
'${order.no}',
2024-07-23 11:36:50 +00:00
style: AppText.b1b,
),
2024-07-24 12:14:17 +00:00
GestureDetector(
onTap: () {
2024-08-15 05:49:01 +00:00
Navigator.of(context).pushNamed(
AppRouter.orderDetails,
arguments: order,
);
2024-07-24 12:14:17 +00:00
},
child: Text(
2024-08-19 11:31:03 +00:00
'${'order_details'.tr()} >',
2024-07-24 12:14:17 +00:00
style: AppText.b1b?.copyWith(
color: AppColors.primary,
),
2024-07-23 11:36:50 +00:00
),
),
],
),
/// gap
Space.yf(0.5),
/// status bar
Row(
children: [
2024-07-29 06:40:26 +00:00
const Icon(Icons.circle, color: AppColors.green, size: 12),
2024-07-23 11:36:50 +00:00
const SizedBox(width: 4),
Text(
2024-08-08 18:34:30 +00:00
order.state,
2024-07-23 11:36:50 +00:00
style: AppText.b2b!.copyWith(
2024-07-29 12:30:30 +00:00
color: AppColors.grey,
2024-07-23 11:36:50 +00:00
),
),
const Spacer(),
2024-08-29 08:48:59 +00:00
/* Text(
2024-08-19 11:31:03 +00:00
'${'order_sent'.tr()}: ${order.departedAt}',
2024-07-23 11:36:50 +00:00
style: AppText.b2b!.copyWith(
2024-07-29 12:30:30 +00:00
color: AppColors.grey,
2024-07-23 11:36:50 +00:00
),
2024-08-29 08:48:59 +00:00
), */
RichText(
text: TextSpan(
text: '${'order_sent'.tr()}: ',
style: AppText.b2b!.copyWith(
color: AppColors.grey,
),
children: [
TextSpan(
text: order.departedAt,
style: AppText.b2b!.copyWith(
color: const Color(0xFF57575C),
fontWeight: FontWeight.bold,
fontSize: 15,
),
),
],
),
2024-07-23 11:36:50 +00:00
),
],
),
/// gap
2024-07-24 06:59:16 +00:00
Space.y!,
const Divider(),
Space.y!,
2024-07-23 11:36:50 +00:00
/// info bar
Row(
children: [
Expanded(
2024-08-19 11:31:03 +00:00
flex: 2,
2024-07-24 06:59:16 +00:00
child: Row(
2024-07-23 11:36:50 +00:00
children: [
2024-07-29 07:35:53 +00:00
/// vertical status line
Container(
2024-07-24 06:59:16 +00:00
width: AppDimensions.normalize(15),
2024-07-29 07:35:53 +00:00
alignment: Alignment.topLeft,
2024-07-29 06:40:26 +00:00
child: VerticalLine(
2024-07-29 07:35:53 +00:00
width: AppDimensions.normalize(1),
height: AppDimensions.normalize(2.5),
2024-07-29 06:40:26 +00:00
topColor: AppColors.green,
2024-08-27 04:53:55 +00:00
bottomColor: order.state == GoodsState.Delivered.name ? AppColors.green : AppColors.grey,
2024-07-23 11:36:50 +00:00
),
),
2024-07-29 07:35:53 +00:00
/// info
2024-08-08 18:34:30 +00:00
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
2024-08-19 11:31:03 +00:00
'${'order_from_card'.tr()}:',
2024-08-08 18:34:30 +00:00
style: AppText.b2b!.copyWith(
color: AppColors.grey,
),
2024-07-24 06:59:16 +00:00
),
2024-08-08 18:34:30 +00:00
Text(
order.from,
2024-08-29 08:48:59 +00:00
style: infoStyle,
2024-08-08 18:34:30 +00:00
maxLines: 2,
overflow: TextOverflow.ellipsis,
2024-07-24 06:59:16 +00:00
),
2024-08-08 18:34:30 +00:00
const SizedBox(height: 8),
Text(
2024-08-19 11:31:03 +00:00
'${'order_to_card'.tr()}:',
2024-08-08 18:34:30 +00:00
style: AppText.b2b!.copyWith(
color: AppColors.grey,
),
2024-07-24 06:59:16 +00:00
),
2024-08-08 18:34:30 +00:00
Text(
order.to,
2024-08-29 08:48:59 +00:00
style: infoStyle,
2024-08-08 18:34:30 +00:00
maxLines: 2,
overflow: TextOverflow.ellipsis,
2024-07-24 06:59:16 +00:00
),
2024-08-08 18:34:30 +00:00
],
),
2024-07-23 11:36:50 +00:00
),
2024-07-24 06:59:16 +00:00
],
),
),
// const Spacer(flex: 1),
Expanded(
2024-08-08 18:34:30 +00:00
flex: 1,
2024-07-24 06:59:16 +00:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2024-07-23 11:36:50 +00:00
Text(
2024-08-19 11:31:03 +00:00
'${'order_placement_count'.tr()}:',
2024-07-23 11:36:50 +00:00
style: AppText.b2b!.copyWith(
2024-07-29 12:30:30 +00:00
color: AppColors.grey,
2024-07-23 11:36:50 +00:00
),
),
Text(
2024-08-08 18:34:30 +00:00
order.placesCount.toString(),
2024-08-29 08:48:59 +00:00
style: infoStyle,
2024-07-23 11:36:50 +00:00
),
2024-07-24 06:59:16 +00:00
const SizedBox(height: 8),
2024-07-23 11:36:50 +00:00
Text(
2024-08-19 11:31:03 +00:00
'${'order_dimensions'.tr()}:',
2024-07-23 11:36:50 +00:00
style: AppText.b2b!.copyWith(
2024-07-29 12:30:30 +00:00
color: AppColors.grey,
2024-07-23 11:36:50 +00:00
),
),
Text(
2024-08-08 18:34:30 +00:00
order.volume.toString(),
2024-08-29 08:48:59 +00:00
style: infoStyle,
2024-07-23 11:36:50 +00:00
),
],
),
),
2024-07-24 06:59:16 +00:00
// const Spacer(flex: 1),
2024-07-23 11:36:50 +00:00
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
2024-08-19 11:31:03 +00:00
'${'order_carrier'.tr()}:',
2024-07-23 11:36:50 +00:00
style: AppText.b2b!.copyWith(
2024-07-29 12:30:30 +00:00
color: AppColors.grey,
2024-07-23 11:36:50 +00:00
),
),
Text(
2024-08-08 18:34:30 +00:00
order.carrier,
2024-07-23 11:36:50 +00:00
style: AppText.b2b!.copyWith(
color: const Color(0xFF57575C),
),
),
const SizedBox(height: 8),
Text(
2024-08-19 11:31:03 +00:00
'${'order_shop'.tr()}:',
2024-07-23 11:36:50 +00:00
style: AppText.b2b!.copyWith(
2024-07-29 12:30:30 +00:00
color: AppColors.grey,
2024-07-23 11:36:50 +00:00
),
),
Text(
2024-08-08 18:34:30 +00:00
order.shopNo,
2024-08-29 08:48:59 +00:00
style: infoStyle,
2024-07-23 11:36:50 +00:00
),
],
),
),
],
),
],
),
),
);
}
}