import 'package:electronic_assistant/resource/assets.gen.dart';
import 'package:electronic_assistant/resource/colors.gen.dart';
import 'package:electronic_assistant/utils/mmkv_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

void showModelExplainTipsDialog() {
  const key = 'isShowModelExplainTipsDialog';
  if (KVUtil.getBool(key, true)) {
    final isCheck = false.obs;

    const tag = 'showModelExplainTipsDialog';

    SmartDialog.show(
        tag: tag,
        builder: (_) {
          return Container(
            padding: EdgeInsets.only(
                left: 16.w, right: 16.w, top: 37.h, bottom: 20.h),
            width: 280.w,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(12.w),
                color: ColorName.white),
            child: IntrinsicHeight(
              child: Column(
                children: [
                  Text(
                    textAlign: TextAlign.center,
                    '本应用提供人工智能服务，禁止利用人工智能从事违法犯罪相关活动',
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 15.sp,
                        color: ColorName.primaryTextColor),
                  ),
                  SizedBox(height: 8.h),
                  GestureDetector(
                    onTap: () {
                      isCheck.value = !isCheck.value;
                    },
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Obx(() {
                          return isCheck.value
                              ? Assets.images.iconSelectTrue
                                  .image(width: 20.w, height: 20.w)
                              : Assets.images.iconSelectFalse
                                  .image(width: 20.w, height: 20.w);
                        }),
                        SizedBox(width: 5.w),
                        Text('以后不再提示',
                            style: TextStyle(
                                fontSize: 15.sp,
                                color: ColorName.tertiaryTextColor))
                      ],
                    ),
                  ),
                  SizedBox(height: 24.5.h),
                  GestureDetector(
                    onTap: () {
                      if (isCheck.value) {
                        KVUtil.putBool(key, false);
                      }
                      SmartDialog.dismiss(tag: tag);
                    },
                    child: Container(
                      height: 36.h,
                      decoration: BoxDecoration(
                          color: ColorName.colorPrimary,
                          borderRadius: BorderRadius.circular(8.w)),
                      child: Center(
                        child: Text(
                          '知道了',
                          style: TextStyle(
                              fontSize: 14.sp,
                              fontWeight: FontWeight.bold,
                              color: ColorName.white),
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),
          );
        });
  }
}
