import 'package:electronic_assistant/data/bean/agenda.dart';
import 'package:electronic_assistant/utils/expand.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../resource/assets.gen.dart';
import '../../resource/colors.gen.dart';
import '../../resource/string.gen.dart';
import '../../utils/common_style.dart';

Widget taskItemView(Agenda item,
    {VoidCallback? onCheckClick, VoidCallback? onThinkingClick}) {
  return Container(
    padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 17).w,
    margin: const EdgeInsets.only(left: 12, right: 12, bottom: 8).w,
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.circular(8),
    ),
    child: Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        GestureDetector(
          onTap: onCheckClick,
          child: SizedBox(
              width: 20.w,
              height: 20.w,
              child: item.isDone.isTrue
                  ? Assets.images.iconAgentChecked.image()
                  : Assets.images.iconAgentUnderway.image()),
        ),
        SizedBox(width: 3.w),
        Visibility(
          visible: item.isExample.isTrue,
          child: Container(
            decoration: BoxDecoration(
              color: ColorName.colorPrimary.withOpacity(0.2),
              borderRadius: BorderRadius.circular(4),
            ),
            padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3).w,
            child: Text(
              StringName.homeTalkExample.tr,
              style: TextStyle(
                  fontSize: 12.sp, color: ColorName.colorPrimary, height: 1),
            ),
          ),
        ),
        SizedBox(width: 5.w),
        Expanded(
          child: Padding(
            padding: const EdgeInsets.only(right: 12).w,
            child: Text(item.content ?? '',
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    fontSize: 15.sp,
                    fontWeight: FontWeight.bold,
                    color: ColorName.primaryTextColor)),
          ),
        ),
        GestureDetector(
          onTap: onThinkingClick,
          child: Container(
            decoration: getPrimaryBtnDecoration(6),
            padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 5).w,
            child: Text(
              StringName.homeTalkThinking.tr,
              style: TextStyle(fontSize: 13.sp, color: ColorName.white),
            ),
          ),
        )
      ],
    ),
  );
}
