/*
 * @Author: XianKaiQun
 * @Date: 2020-09-29 11:21:53
 * @LastEditors  : WuWei
 * @LastEditTime : 2022-01-19 10:46:44
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:wisdom_cli/src/assets.gen.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

///一个空提示
class WEmptyWidget extends StatelessWidget {
  const WEmptyWidget({
    Key? key,
    this.text,
    this.imageWidth,
    this.margin,
    this.space,
    this.image,
  }) : super(key: key);
  final ImageProvider? image;
  final Widget? text;

  ///图标的大小 默认`200.pt`
  final double? imageWidth;

  ///默认`EdgeInsets.all(20.pt)`
  final EdgeInsetsGeometry? margin;

  ///较为朴素的空提示（图片没有背景）
  WEmptyWidget.plain({
    Key? key,
    this.text,
    double? imageWidth,
    this.margin,
    this.space,
  })  : image = AssetList.$emptyPlain_png_image,
        this.imageWidth = imageWidth ?? 83.pt;

  ///图片和文字的间隔
  final double? space;
  @override
  Widget build(BuildContext context) {
    return Wisdom.column(
      padding: margin ?? EdgeInsets.all(20.pt),
      alignment: Alignment.center,
      children: [
        WImage(
          image: image ?? AssetList.$empty_png_image,
          width: imageWidth ?? 200.pt,
        ),
        if (text != null) SizedBox(height: space ?? 18.pt),
        if (text != null)
          DefaultTextStyle(
            style: DefaultTextStyle.of(context).style.copyWith(
                  fontSize: 14.pt,
                  color: WTheme.of(context).colorScheme.minor,
                ),
            child: text!,
          )
      ],
    );
  }
}
