upgrade flutter
This commit is contained in:
@@ -4,73 +4,106 @@ import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:timeline_list/timeline.dart';
|
||||
import 'package:timeline_list/timeline_model.dart';
|
||||
import 'package:timeline_list/timeline_list.dart';
|
||||
|
||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
var dateFormatter = DateFormat('dd MMM yyyy');
|
||||
|
||||
class StatusTree extends StatelessWidget {
|
||||
final List<ShipmentStatus>? shipmentHistory;
|
||||
final String? currentStatus;
|
||||
|
||||
const StatusTree({Key? key, this.shipmentHistory, this.currentStatus})
|
||||
: super(key: key);
|
||||
const StatusTree({super.key, this.shipmentHistory, this.currentStatus});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ExpansionTile(
|
||||
initiallyExpanded: true,
|
||||
shape:
|
||||
Border.symmetric(horizontal: BorderSide(color: Colors.grey.shade300)),
|
||||
title: Text(
|
||||
'Status',
|
||||
style: TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
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,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Status',
|
||||
style: TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20),
|
||||
height: 400,
|
||||
child: Timeline(children: _models(), position: TimelinePosition.Left),
|
||||
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
|
||||
? Text(dateFormatter.format(e.date))
|
||||
: Container(),
|
||||
e.staffName == null
|
||||
? Container()
|
||||
: Text(e.staffName!)
|
||||
],
|
||||
),
|
||||
),
|
||||
icon: e == null
|
||||
? null
|
||||
: e.status == "shipped"
|
||||
? shippedIcon
|
||||
: e.status == "delivered"
|
||||
? deliveredIcon
|
||||
: e.status == "packed"
|
||||
? packedIcon
|
||||
: e.status == "processed"
|
||||
? processedIcon
|
||||
: receivedIcon,
|
||||
position: MarkerPosition.left,
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<TimelineModel> _models() {
|
||||
if (shipmentHistory == null || currentStatus == null) return [];
|
||||
bool isPacked = currentStatus != package_received_status &&
|
||||
currentStatus != package_processed_status;
|
||||
return shipmentHistory!
|
||||
.map((e) => TimelineModel(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(18.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(e.status,
|
||||
style: TextStyle(
|
||||
color: e.done! ? primaryColor : Colors.grey,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold)),
|
||||
e.done! || isPacked
|
||||
? Text(dateFormatter.format(e.date))
|
||||
: Container(),
|
||||
e.staffName == null ? Container() : Text(e.staffName!)
|
||||
],
|
||||
),
|
||||
),
|
||||
iconBackground: e.done! ? primaryColor : Colors.grey,
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user