import 'package:chat/configs/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';

class CustomEasyRefresh {
  static Header get header => ClassicalHeader(
        refreshText: '下拉刷新',
        refreshReadyText: '松开刷新',
        refreshingText: '刷新中...',
        refreshedText: '刷新完成',
        infoText: '上次更新 %T',
        infoColor: AppColors.primary,
        textColor: AppColors.primary,
      );

  static Footer get ballFooter => BallPulseFooter(
        color: AppColors.primary,
      );

  static Footer get footer => ClassicalFooter(
        loadText: '上拉加载',
        loadReadyText: '松开加载',
        loadingText: '加载中...',
        loadedText: '加载完成',
        infoText: '上次更新 %T',
        noMoreText: '没有更多了',
        infoColor: AppColors.primary,
        textColor: AppColors.primary,
      );

  /// 数据为空的时候显示
  static Widget empty({
    String text = '暂无数据',
    double size = 156.0,
  }) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Image.asset(
          'assets/images/empty/im_emptyIcon_2.png',
          width: size,
        ),
        const SizedBox(
          height: 16,
        ),
        Text(
          text,
          style: const TextStyle(
            fontSize: 12,
            color: AppColors.unactive,
          ),
        ),
      ],
    );
  }

  static Widget get first => Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Container(
            decoration: BoxDecoration(
              color: AppColors.white,
              borderRadius: BorderRadius.circular(8),
              boxShadow: const [
                BoxShadow(
                  blurStyle: BlurStyle.outer,
                  color: AppColors.shadow,
                  blurRadius: 4,
                ),
              ],
            ),
            width: 120,
            height: 120,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: const <Widget>[
                SpinKitFadingCircle(
                  color: AppColors.primary,
                  size: 50.0,
                ),
                SizedBox(height: 16),
                Text('加载中...'),
              ],
            ),
          ),
        ],
      );
}
