Files
fcs/lib/pages/widgets/status_tree.dart

112 lines
4.3 KiB
Dart
Raw Normal View History

2024-09-22 16:49:59 +06:30
import 'package:fcs/constants.dart';
2020-10-11 02:17:23 +06:30
import 'package:fcs/domain/vo/shipment_status.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/material.dart';
2021-09-10 15:22:11 +06:30
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
2020-10-11 02:17:23 +06:30
import 'package:intl/intl.dart';
2025-02-11 22:11:45 +06:30
import 'package:timeline_list/timeline_list.dart';
2020-10-11 02:17:23 +06:30
2025-02-11 22:11:45 +06:30
var dateFormatter = DateFormat('dd MMM yyyy');
2020-10-11 02:17:23 +06:30
class StatusTree extends StatelessWidget {
2021-09-10 15:22:11 +06:30
final List<ShipmentStatus>? shipmentHistory;
final String? currentStatus;
2020-10-11 02:17:23 +06:30
2025-02-11 22:11:45 +06:30
const StatusTree({super.key, this.shipmentHistory, this.currentStatus});
2020-10-11 02:17:23 +06:30
@override
Widget build(BuildContext context) {
2025-02-11 22:11:45 +06:30
bool isPacked = currentStatus != package_received_status &&
currentStatus != package_processed_status;
var receivedIcon = Container(
width: 25,
height: 25,
decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.green),
child: Icon(MaterialCommunityIcons.inbox_arrow_down,
color: Colors.white, size: 18));
var processedIcon = Container(
width: 25,
height: 25,
decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.green),
child: Icon(FontAwesome.dropbox, color: Colors.white, size: 18));
var packedIcon = Container(
width: 25,
height: 25,
decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.green),
child: Icon(MaterialCommunityIcons.package,
color: Colors.white, size: 18));
var shippedIcon = Container(
width: 25,
height: 25,
decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.green),
child: Icon(Ionicons.ios_airplane, color: Colors.white, size: 18));
var deliveredIcon = Container(
width: 25,
height: 25,
decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.green),
child: Icon(MaterialCommunityIcons.truck_fast,
color: Colors.white, size: 18));
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
2020-10-12 03:34:05 +06:30
children: <Widget>[
2025-02-11 22:11:45 +06:30
Text(
'Status',
style: TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
),
2020-10-12 03:34:05 +06:30
Container(
2025-02-11 22:11:45 +06:30
child: Timeline.builder(
shrinkWrap: true,
context: context,
markerCount: shipmentHistory?.length ?? 0,
physics: NeverScrollableScrollPhysics(),
properties: TimelineProperties(
iconAlignment: MarkerIconAlignment.center,
iconSize: 25,
timelinePosition: TimelinePosition.start),
markerBuilder: (context, index) {
ShipmentStatus? e = shipmentHistory?[index];
return Marker(
child: SizedBox(
width: 250,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: e == null
? []
: <Widget>[
Text(e.status,
style: TextStyle(
color: e.done! ? primaryColor : Colors.grey,
fontSize: 16,
fontWeight: FontWeight.bold)),
e.done! || isPacked
2025-02-17 20:13:30 +06:30
? e.date != null
? Text(dateFormatter.format(e.date!))
: const SizedBox()
2025-02-11 22:11:45 +06:30
: Container(),
e.staffName == null
? Container()
: Text(e.staffName!)
],
),
),
icon: e == null
? null
2025-02-17 20:13:30 +06:30
: e.status == package_shipped_status
2025-02-11 22:11:45 +06:30
? shippedIcon
2025-02-17 20:13:30 +06:30
: e.status == package_delivered_status
2025-02-11 22:11:45 +06:30
? deliveredIcon
2025-02-17 20:13:30 +06:30
: e.status == package_packed_status
2025-02-11 22:11:45 +06:30
? packedIcon
2025-02-17 20:13:30 +06:30
: e.status == package_processed_status
2025-02-11 22:11:45 +06:30
? processedIcon
: receivedIcon,
position: MarkerPosition.left,
);
},
),
2020-10-12 03:34:05 +06:30
)
],
2020-10-11 02:17:23 +06:30
);
}
}