import 'dart:async';

import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';

class BaseEasyRefresh extends StatelessWidget {
  final EasyRefreshController? controller;
  final bool refreshOnStart;
  final bool resetAfterRefresh;
  final Header? header;
  final Footer? footer;
  final FutureOr Function()? onRefresh;
  final FutureOr Function()? onLoad;
  final ScrollController? scrollController;
  final Widget Function(BuildContext context, ScrollPhysics physics) childBuilder;

  const BaseEasyRefresh({
    super.key,
    this.controller,
    this.refreshOnStart = false,
    this.resetAfterRefresh = true,
    this.header,
    this.footer,
    this.onRefresh,
    this.onLoad,
    this.scrollController,
    required this.childBuilder,
  });

  @override
  Widget build(BuildContext context) {
    return EasyRefresh.builder(
      refreshOnStart: refreshOnStart,
      resetAfterRefresh: resetAfterRefresh,
      controller: controller,
      header: header ?? const ClassicHeader(),
      footer: footer ?? const ClassicFooter(),
      onRefresh: onRefresh,
      onLoad: onLoad,
      scrollController: scrollController,
      triggerAxis: Axis.vertical,
      childBuilder: childBuilder,
    );
  }
}
