// ignore_for_file: must_be_immutable

import 'package:cs_resources/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:cs_resources/constants/color_constants.dart';

import '../my_text_view.dart';

/// 相机相册的选择
class AlbumDefaultSelectDialog extends StatelessWidget {
  bool isTypeVideo = false;
  VoidCallback? cancelAction;
  VoidCallback cameraAction;
  VoidCallback albumAction;

  AlbumDefaultSelectDialog({
    Key? key,
    required this.cameraAction,
    required this.albumAction,
    this.cancelAction,
    this.isTypeVideo = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final bgColor = const Color(0xFAFFFFFF);
    const roundRadios = 10.0;

    return Container(
      margin: const EdgeInsets.only(left: 30, right: 30, bottom: 30),
      child: Column(
        //顶部标题
        mainAxisSize: MainAxisSize.min,
        children: [
          // 顶部的文本
          Container(
            width: double.infinity,
            alignment: Alignment.center,
            decoration: BoxDecoration(
                color: bgColor,
                borderRadius: const BorderRadius.only(
                  topLeft: Radius.circular(roundRadios),
                  topRight: Radius.circular(roundRadios),
                )),
            child: MyTextView(
              isTypeVideo ? S.current.choose_video : S.current.choose_image,
              paddingTop: 10,
              paddingBottom: 10,
              textColor: const Color(0xff323843),
              fontSize: 12,
              isFontRegular: true,
            ),
          ),

          // 分割线
          Container(
            color: ColorConstants.dividerItem,
            height: 0.5,
          ),

          InkWell(
            onTap: () {
              onCancel();
              cameraAction.call();
            },
            child: Container(
              width: double.infinity,
              alignment: Alignment.center,
              color: bgColor,
              child: MyTextView(
                S.current.camera,
                textColor: ColorConstants.blue1578fe,
                paddingTop: 15,
                paddingBottom: 15,
                fontSize: 16,
                isFontMedium: true,
              ),
            ),
          ),

          // 分割线
          Container(
            color: ColorConstants.dividerItem,
            height: 0.5,
          ),

          InkWell(
            onTap: () {
              onCancel();
              albumAction.call();
            },
            child: Container(
              width: double.infinity,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                  color: bgColor,
                  borderRadius: const BorderRadius.only(
                    bottomRight: Radius.circular(roundRadios),
                    bottomLeft: Radius.circular(roundRadios),
                  )),
              child: MyTextView(
                S.current.album,
                textColor: ColorConstants.blue1578fe,
                fontSize: 16,
                paddingTop: 15,
                paddingBottom: 15,
                isFontMedium: true,
              ),
            ),
          ),

          // 分割线
          Container(
            color: ColorConstants.dividerA6,
            height: 0.5,
          ),

          // 取消按钮
          InkWell(
            onTap: () {
              onCancel();
              cancelAction?.call();
            },
            child: Container(
              margin: const EdgeInsets.only(top: 10),
              width: double.infinity,
              alignment: Alignment.center,
              decoration: BoxDecoration(color: bgColor, borderRadius: const BorderRadius.all(Radius.circular(roundRadios))),
              child: MyTextView(
                S.current.cancel,
                textColor: ColorConstants.blue1578fe,
                fontSize: 16,
                paddingTop: 15,
                paddingBottom: 15,
                isFontMedium: true,
              ),
            ),
          ),
        ],
      ),
    );
  }

  //取消弹框
  void onCancel() async {
    SmartDialog.dismiss();
  }
}
