import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:widgets/ext/ex_widget.dart';
import '../my_text_view.dart';
import 'package:cs_resources/constants/color_constants.dart';

/// 打印调试信息，点击可以复制弹窗的文本
class PrintInfoDialog extends StatelessWidget {
  String? message;

  PrintInfoDialog(this.message);

  @override
  Widget build(BuildContext context) {
    GlobalKey _textKey = GlobalKey();

    return Container(
      decoration: const BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(5)),
      ),
      child: SingleChildScrollView(
        child: RepaintBoundary(
          key: _textKey,
          child: MyTextView(
            message ?? '',
            fontSize: 14,
            textColor: const Color(0xff333333),
            isFontRegular: true,
            textAlign: TextAlign.center,
            paddingLeft: 30,
            paddingRight: 30,
            paddingBottom: 35,
            marginTop: 35,
            onClick: () {
              Clipboard.setData(ClipboardData(text: message ?? ''));
              SmartDialog.showToast('复制成功');
            },
          ),
        ),
      ),
    ).constrained(width: 300, maxHeight: 500);
  }

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