import 'package:flutter/material.dart';
import 'package:widgets/utils/dark_theme_util.dart';
import 'package:cs_resources/constants/color_constants.dart';


/// 自定义Loading的UI展示
class CustomLoadingWidget extends StatelessWidget {
  const CustomLoadingWidget({
    Key? key,
    required this.msg,
  }) : super(key: key);

  final String msg;

  @override
  Widget build(BuildContext context) {
    return _buildBg(context,children: [
      const SizedBox(
        width: 30,
        height: 30,
        child: CircularProgressIndicator(
          strokeWidth: 2,
          valueColor: AlwaysStoppedAnimation(Colors.white),
        ),
      ),
      Container(
        margin: const EdgeInsets.only(top: 12),
        child: Text(
          msg,
          style: const TextStyle(color: Colors.white, fontSize: 13),
          textAlign: TextAlign.center,
        ),
      ),
    ]);
  }

  Widget _buildBg(BuildContext context,{required List<Widget> children}) {
    return Container(
      width: 85,
      height: 85,
      alignment: Alignment.center,
      decoration: BoxDecoration(
        color: DarkThemeUtil.multiColors(context,const Color(0xcc000000),darkColor: ColorConstants.darkBlackItem),
        borderRadius: BorderRadius.circular(10),
      ),
      child: Column(mainAxisSize: MainAxisSize.min, children: children),
    );
  }
}
