import 'package:electronic_assistant/utils/expand.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

import '../resource/colors.gen.dart';
import '../resource/string.gen.dart';

typedef TalkDeleteBuilder = void Function();

void talkDeleteDialog(String? talkId, String? talkTitle,
    {TalkDeleteBuilder? returnBuilder}) {
  SmartDialog.show(
      builder: (_) {
        return Container(
          padding: EdgeInsets.all(16.w),
          width: 280.w,
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(12),
          ),
          child: IntrinsicHeight(
            child: Column(
              children: [
                SizedBox(height: 24.h),
                Text(
                  StringName.talkRenameDeletePrompt.tr
                      .replacePlaceholders([talkTitle]),
                  style: TextStyle(
                      fontSize: 15.sp,
                      color: ColorName.primaryTextColor,
                      fontWeight: FontWeight.bold),
                ),
                SizedBox(height: 35.h),
                Row(
                  children: [
                    Expanded(
                        child: GestureDetector(
                      onTap: () {
                        SmartDialog.dismiss();
                      },
                      child: Container(
                        padding: EdgeInsets.symmetric(vertical: 8.h),
                        decoration: BoxDecoration(
                          color: '#F0F0F0'.toColor(),
                          borderRadius: BorderRadius.circular(8),
                        ),
                        child: Center(
                          child: Text(
                            StringName.cancel.tr,
                            style: TextStyle(
                                fontSize: 16.sp,
                                color: ColorName.secondaryTextColor),
                          ),
                        ),
                      ),
                    )),
                    SizedBox(width: 12.w),
                    Expanded(
                        child: GestureDetector(
                      onTap: () {
                        SmartDialog.dismiss();
                        if (returnBuilder != null) {
                          returnBuilder.call();
                        }
                      },
                      child: Container(
                        padding: EdgeInsets.symmetric(vertical: 8.h),
                        decoration: BoxDecoration(
                          color: ColorName.colorPrimary,
                          borderRadius: BorderRadius.circular(8),
                        ),
                        child: Center(
                          child: Text(
                            StringName.sure.tr,
                            style: TextStyle(
                                fontSize: 16.sp, color: ColorName.white),
                          ),
                        ),
                      ),
                    )),
                  ],
                ),
                SizedBox(height: 4.h),
              ],
            ),
          ),
        );
      },
      clickMaskDismiss: false);
}
