import 'package:fcs/domain/entities/fcs_shipment.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart';
import 'fcs_shipment_info.dart';

class FcsShipmentListRow extends StatelessWidget {
  final FcsShipment shipment;
  final dateFormatter = new DateFormat('dd MMM yyyy');
  FcsShipmentListRow({Key key, this.shipment}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Navigator.of(context).push(CupertinoPageRoute(
            builder: (context) => FcsShipmentInfo(fcsShipment: shipment)));
      },
      child: Container(
        padding: EdgeInsets.only(left: 15, right: 15),
        child: Row(
          children: <Widget>[
            Expanded(
              child: new Padding(
                padding: const EdgeInsets.symmetric(vertical: 10.0),
                child: new Row(
                  children: <Widget>[
                    Container(
                      padding: EdgeInsets.only(left: 5, right: 10),
                      child: Icon(
                        Ionicons.ios_airplane,
                        color: primaryColor,
                        size: 30,
                      ),
                    ),
                    new Expanded(
                      child: new Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Padding(
                            padding: const EdgeInsets.only(left: 8.0),
                            child: new Text(
                              shipment.shipmentNumber == null
                                  ? ''
                                  : shipment.shipmentNumber,
                              style: new TextStyle(
                                  fontSize: 15.0, color: Colors.black),
                            ),
                          ),
                          Padding(
                            padding: const EdgeInsets.only(left: 10.0, top: 10),
                            child: new Text(
                              dateFormatter.format(shipment.cutoffDate),
                              style: new TextStyle(
                                  fontSize: 15.0, color: Colors.grey),
                            ),
                          )
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(0),
              child: getStatus(shipment.status),
            ),
          ],
        ),
      ),
    );
  }
}
