import 'dart:ui';

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

void showCommonPopup(
    Offset offset, Alignment alignment, List<Widget> childWidget,
    {String? tag, BuildContext? context}) {
  SmartDialog.showAttach(
    targetContext: null,
    targetBuilder: (_, __) => offset,
    animationType: SmartAnimationType.fade,
    clickMaskDismiss: true,
    alignment: alignment,
    bindWidget: context,
    tag: tag,
    maskColor: Colors.transparent,
    builder: (_) {
      return IntrinsicWidth(
        child: Container(
          constraints: BoxConstraints(
            minWidth: 128.w,
          ),
          decoration: BoxDecoration(
            color: Colors.white,
            border: Border.all(color: '#D8D8D8'.toColor(), width: 1), // 边框
            borderRadius: BorderRadius.circular(8), // 圆角
            boxShadow: [
              BoxShadow(
                color: Colors.black.withOpacity(0.1), // 阴影颜色
                spreadRadius: 2, // 阴影扩散半径
                blurRadius: 6, // 阴影模糊半径
                offset: const Offset(0, 3), // 阴影偏移量
              ),
            ],
          ),
          child: Column(
            children: childWidget,
          ),
        ),
      );
    },
  );
}
