import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:farmer_client/widgets/LinearGradientText.dart';

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

Widget summary({required CardInfo item,required String km}) {

  return Column(
    children: [
      _title(item: item),
      SizedBox(height: 20.w,),
      _desc(item: item,km: km),
      SizedBox(height: 20.w,),
      _detail(item: item),
      SizedBox(height: 20.w,),
    ],
  );
}

Widget _title({required CardInfo item}) {

  return Row(
    children: [
      Expanded(
          child: Text(item.name.toString(),
              style: TextStyle(
                color: const Color(0xFF222222),
                fontSize: 18.sp,
                fontWeight: FontWeight.bold,
              )),
          flex: 1),
      Container(
        width: 100.w,
        alignment: Alignment.centerRight,
        child: LinearGradientText(
          colors: const <Color>[
            Color(0xFFFA7878),
            Color(0xFFB61515),
          ],
          child: RichText(
            text: TextSpan(
                children: <InlineSpan>[
                  TextSpan(
                      text: ((item.price??0)/100).toString(),
                      style: TextStyle(
                        fontSize: 22.sp,
                        fontWeight: FontWeight.bold,
                      )),
                  TextSpan(
                      text: "元/",
                      style: TextStyle(
                        fontSize: 22.sp,
                        fontWeight: FontWeight.bold,
                      )),
                  TextSpan(
                      text: "公顷",
                      style: TextStyle(
                        fontSize: 12.sp,
                        fontWeight: FontWeight.bold,
                      )),
                ]
            ),
          ),
        ),
      )
    ],
  );
}

Widget _desc({required CardInfo item,required String km}) {
  return Row(
    children: [
      Icon(Icons.location_on_outlined, size: 16.sp,),
      Expanded(
        flex: 1,
        child: Text("距离当前位置$km >>", style: TextStyle(color: const Color(0xFF222222), fontSize: 15.sp),),
      ),
    ],
  );
}

Widget _detail({required CardInfo item}) {
  return Container(
    alignment: Alignment.centerLeft,
    child: Text(item.orgName.toString(), style: TextStyle(color: const Color(0xFF222222), fontSize: 15.sp),),
  );
}
