
import 'package:farmer_client/pages/machinery/widgets/DefLayout.dart';
import 'package:farmer_client/pages/machinery/widgets/RoundButton.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart';
import 'package:farmer_client/widgets/amap/amap.dart';

import '../../../../models/entities/CardInfo.dart';
import '../../widgets/summary.dart';

Widget page({required CardInfo item,required String km, required BuildContext context, VoidCallback? handleClick}) {
  final _offset = 20.w;
  final width = MediaQuery.of(context).size.width;
  final mapHeight = 226.5.w;
  final cardHeight = 250.w;


  final LatLng position = LatLng(32.690712, 112.091892);

  return DefLayout(
      head: AMap(position: position),
      children: [
        DefLayout.card(
            top: DefLayout.headHeight - DefLayout.offset,
            height: DefLayout.headHeight,
            child: Image.network(item.thumb.toString(), fit: BoxFit.cover,
            errorBuilder:  (ctx, exception, stackTrace) {
              return Container(); //THE WIDGET YOU WANT TO SHOW IF URL NOT RETURN IMAGE
            },
            ),
        ),
        DefLayout.card(
            top: (DefLayout.headHeight - DefLayout.offset) * 2,
            padding: EdgeInsets.only(top: 45.w, left: 15.w, right: 15.w, bottom: 20.w),
            child: _content(context, handleClick,item,km)
        ),
      ]
  );
}

Widget _content(BuildContext context, VoidCallback? handleClick,CardInfo item,String km) {
  return
    Column(
    children: [
      summary(item: item,km:km),
      RoundButton(text: "预约", onPressed: handleClick,),
    ],
  );
}