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

void showIosShortcutGuideDialog(
    {void Function()? onConfirm, void Function()? onCancel}) {
  const tag = 'showIosShortcutGuideDialog';

  SmartDialog.show(
      tag: tag,
      backType: SmartBackType.block,
      clickMaskDismiss: false,
      alignment: const Alignment(0.0, 0.9),
      builder: (_) {
        return Container(
          margin: EdgeInsets.symmetric(horizontal: 12.w),
          child: IntrinsicHeight(
            child: Container(
              decoration: BoxDecoration(
                  color: ColorName.white,
                  borderRadius: BorderRadius.circular(12.w)),
              child: Column(
                children: [
                  Container(
                    decoration: BoxDecoration(
                        gradient: LinearGradient(
                          begin: Alignment.topCenter,
                          end: Alignment.bottomCenter,
                          colors: ['#6177F2'.color, '#7EBAFF'.color],
                        ),
                        borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(12.w),
                            topRight: Radius.circular(12.w))),
                    child: Stack(
                      children: [
                        AspectRatio(
                            aspectRatio: 336 / 201,
                            child: Assets.images.dialogIosAddShortcutGuide
                                .image(width: double.infinity)),
                        Align(
                          alignment: Alignment.topRight,
                          child: Padding(
                            padding: EdgeInsets.all(16.w),
                            child: GestureDetector(
                              onTap: () {
                                SmartDialog.dismiss(tag: tag);
                                onCancel?.call();
                              },
                              child: Assets.images.iconDesktopShortcutClose
                                  .image(width: 26.w, height: 26.w),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                  SizedBox(height: 20.w),
                  Text('轻敲背面，快捷录音',
                      style: TextStyle(
                          color: ColorName.primaryTextColor, fontSize: 18.sp)),
                  SizedBox(height: 6.w),
                  Text(
                    textAlign: TextAlign.center,
                    '想更快打开录音吗？\n设置快捷方式，让小听更快听见~',
                    style: TextStyle(
                        fontSize: 14.sp, color: ColorName.secondaryTextColor),
                  ),
                  SizedBox(height: 24.w),
                  GestureDetector(
                    onTap: () {
                      SmartDialog.dismiss(tag: tag);
                      onConfirm?.call();
                    },
                    child: Container(
                      decoration: getCommonDecoration(8.w),
                      width: 304.w,
                      height: 48.w,
                      child: Center(
                        child: Text('立即设置',
                            style: TextStyle(
                                fontSize: 16.sp,
                                color: ColorName.white,
                                fontWeight: FontWeight.bold)),
                      ),
                    ),
                  ),
                  SizedBox(height: 20.w),
                ],
              ),
            ),
          ),
        );
      });
}
