import 'package:driverapp/uitl/utils.dart';
import 'package:driverapp/widgets/delivery/distance_in_kilometers.dart';
import 'package:driverapp/widgets/others/rounded_container.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';

class OrderInfoCard extends StatelessWidget {
  const OrderInfoCard({Key key, this.order, this.onTap}) : super(key: key);

  final dynamic order;
  final Function onTap;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
        child: RoundedContainer(
          showShadow: true,
          raduis: 25.0,
          height: MediaQuery.of(context).orientation == Orientation.portrait
              ? MediaQuery.of(context).size.height * 0.120
              : MediaQuery.of(context).size.height * 0.209,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Expanded(
                flex: 1,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Padding(
                      padding: EdgeInsets.only(left: 15.0, top: 14.0),
                      child: Image.asset(
                        'assets/images/location.png',
                        height: MediaQuery.of(context).orientation ==
                                Orientation.portrait
                            ? MediaQuery.of(context).size.height * 0.06
                            : MediaQuery.of(context).size.height * 0.11,
                        width: MediaQuery.of(context).orientation ==
                                Orientation.portrait
                            ? MediaQuery.of(context).size.width * 0.05
                            : MediaQuery.of(context).size.width * 0.09,
                      ),
                    )
                  ],
                ),
              ),
              Expanded(
                flex: 5,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Padding(
                      padding: EdgeInsets.only(top: 20.0),
                      child: Text(
                        Utils.formatName(
                            order.firstName + ' ' + order.lastName),
                        style: TextStyle(
                            fontSize: 18.0,
                            color: Hexcolor("#343333"),
                            fontWeight: FontWeight.bold),
                      ),
                    ),
                    Text(
                      order.mobileNumber,
                      style: TextStyle(
                        color: Color(0xff30B7B9),
                        fontWeight: FontWeight.w600,
                        fontSize: 15.0,
                      ),
                    ),
                    Expanded(
                      child: Text(
                        order.orderID.toString(),
                        style: TextStyle(
                            fontSize: 15.0,
                            fontWeight: FontWeight.w400,
                            letterSpacing: 8.0),
                      ),
                    ),
                  ],
                ),
              ),
              Padding(
                padding: EdgeInsets.all(8.0),
                child: DistanceInKilometers(
                  distanceInKilometers: order.distanceInKilometers,
                ),
              ),
            ],
          ),
        ),
      ),
      onTap: () {
        onTap();
      },
    );
  }
}
