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';
|
|
|
|
|
import 'package:timeline_list/timeline.dart';
|
|
|
|
|
import 'package:timeline_list/timeline_model.dart';
|
|
|
|
|
|
|
|
|
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2021-09-10 15:22:11 +06:30
|
|
|
const StatusTree({Key? key, this.shipmentHistory, this.currentStatus})
|
2020-10-11 02:17:23 +06:30
|
|
|
: super(key: key);
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-10-12 03:34:05 +06:30
|
|
|
return ExpansionTile(
|
|
|
|
|
initiallyExpanded: true,
|
2024-09-22 16:49:59 +06:30
|
|
|
shape:
|
|
|
|
|
Border.symmetric(horizontal: BorderSide(color: Colors.grey.shade300)),
|
2020-10-12 03:34:05 +06:30
|
|
|
title: Text(
|
|
|
|
|
'Status',
|
|
|
|
|
style: TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 20),
|
|
|
|
|
height: 400,
|
|
|
|
|
child: Timeline(children: _models(), position: TimelinePosition.Left),
|
|
|
|
|
)
|
|
|
|
|
],
|
2020-10-11 02:17:23 +06:30
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<TimelineModel> _models() {
|
|
|
|
|
if (shipmentHistory == null || currentStatus == null) return [];
|
|
|
|
|
bool isPacked = currentStatus != package_received_status &&
|
|
|
|
|
currentStatus != package_processed_status;
|
2021-09-10 15:22:11 +06:30
|
|
|
return shipmentHistory!
|
2020-10-11 02:17:23 +06:30
|
|
|
.map((e) => TimelineModel(
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(18.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Text(e.status,
|
|
|
|
|
style: TextStyle(
|
2021-09-10 15:22:11 +06:30
|
|
|
color: e.done! ? primaryColor : Colors.grey,
|
2020-10-11 02:17:23 +06:30
|
|
|
fontSize: 16,
|
|
|
|
|
fontWeight: FontWeight.bold)),
|
2021-09-10 15:22:11 +06:30
|
|
|
e.done! || isPacked
|
2020-10-11 02:17:23 +06:30
|
|
|
? Text(dateFormatter.format(e.date))
|
|
|
|
|
: Container(),
|
2021-09-10 15:22:11 +06:30
|
|
|
e.staffName == null ? Container() : Text(e.staffName!)
|
2020-10-11 02:17:23 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
2021-09-10 15:22:11 +06:30
|
|
|
iconBackground: e.done! ? primaryColor : Colors.grey,
|
2020-10-11 02:17:23 +06:30
|
|
|
icon: Icon(
|
|
|
|
|
e.status == "shipped"
|
|
|
|
|
? Ionicons.ios_airplane
|
|
|
|
|
: e.status == "delivered"
|
|
|
|
|
? MaterialCommunityIcons.truck_fast
|
|
|
|
|
: e.status == "packed"
|
|
|
|
|
? MaterialCommunityIcons.package
|
|
|
|
|
: e.status == "processed"
|
|
|
|
|
? FontAwesome.dropbox
|
|
|
|
|
: MaterialCommunityIcons.inbox_arrow_down,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
)))
|
|
|
|
|
.toList();
|
|
|
|
|
}
|
|
|
|
|
}
|