import 'dart:ui';

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';

Widget createPopupDivider(
    {Color color = const Color(0xFFF6F6F6), double height = 1}) {
  return Divider(color: color, height: height);
}

Widget createNormalPopupItem(String title, {VoidCallback? onItemClick}) {
  return GestureDetector(
    onTap: onItemClick,
    child: Container(
      color: Colors.transparent,
      padding: EdgeInsets.symmetric(horizontal: _itemPadding),
      height: _itemHeight,
      child: Align(
        alignment: Alignment.centerLeft,
        child: Text(
          title,
          style: TextStyle(
            fontSize: 14.sp,
            color: ColorName.primaryTextColor,
          ),
        ),
      ),
    ),
  );
}

Widget createDeletePopupItem(VoidCallback? onDelete) {
  return GestureDetector(
    onTap: () {
      onDelete?.call();
    },
    child: Container(
      color: Colors.transparent,
      padding: EdgeInsets.symmetric(horizontal: _itemPadding),
      height: _itemHeight,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(
            StringName.talkDelete.tr,
            style: TextStyle(color: '#F5574E'.toColor(), fontSize: 14.sp),
          ),
          const Spacer(),
          SizedBox(
              width: 20.w,
              height: 20.w,
              child: Assets.images.iconTalkDelete.image())
        ],
      ),
    ),
  );
}

Widget createSelectItem(String title, bool isSelect,
    {VoidCallback? onItemClick}) {
  return GestureDetector(
    onTap: onItemClick,
    child: ConstrainedBox(
      constraints: BoxConstraints(minWidth: 128.w, minHeight: 48.w),
      child: Container(
        color: ColorName.transparent,
        child: Row(
          children: [
            SizedBox(width: 14.w),
            Text(title,
                style: TextStyle(
                    fontSize: 14.sp, color: ColorName.primaryTextColor)),
            const Spacer(),
            Visibility(
                visible: isSelect,
                child: Assets.images.iconPopupSelected
                    .image(width: 20.w, height: 20.w)),
            SizedBox(width: 16.w),
          ],
        ),
      ),
    ),
  );
}

final _itemHeight = 52.h;
final _itemPadding = 14.w;
