import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:worker_client/models/entities/Machinery.dart';

import '../../../widgets/Jianbian/index.dart';

class MachineryCard extends StatelessWidget {
  final Machinery machinery;
  final GestureTapCallback goDetail;
  final GestureTapCallback goMap;

  const MachineryCard(
      {Key? key,
      required this.machinery,
      required this.goDetail,
      required this.goMap})
      : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left:15.w,right: 15.w,bottom: 15.w),
      clipBehavior: Clip.hardEdge,
      decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(20.w)),
          boxShadow: [
            BoxShadow(
                color: const Color(0x14000000),
                offset: const Offset(0, 0),
                blurRadius: 22.w)
          ]),
      child: Stack(
        children: [
          Column(
            children: [
              GestureDetector(
                onTap: goDetail,
                child: Image.network(
                  machinery.thumb.toString(),
                  width: 345.w,
                  height: 227.7.w,
                  fit: BoxFit.fill,
                ),
              ),
              Container(
                padding: EdgeInsets.fromLTRB(14.w, 19.5.h, 14.w, 30.h),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    SizedBox(
                      width: 250.w,
                      child: GestureDetector(
                        onTap: goDetail,
                        child: Text(
                          machinery.name.toString(),
                          softWrap: true,
                          textAlign: TextAlign.left,
                          overflow: TextOverflow.ellipsis,
                          maxLines: 1,
                          style: TextStyle(
                            fontWeight: FontWeight.w700,
                            fontSize: 18.sp,
                            color: const Color(0xFF222222),
                          ),
                        ),
                      ),
                    ),
                    GestureDetector(
                      onTap: goMap,
                      child: const Text(
                        '进入地图>>',
                        style: TextStyle(fontWeight: FontWeight.w700),
                      ),
                    )
                  ],
                ),
              ),
            ],
          ),
          Jianbian(
            status: machinery.status,
            type: 'machinery',
            value: machinery.jobStatus,
          ),
        ],
      ),
    );
  }
}
