import 'package:flutter/material.dart';
import 'package:taafee_mobile/common/widgets/gridview.dart';
import 'package:taafee_mobile/common/widgets/listview.dart';
import 'package:taafee_mobile/common/const/const.dart';

class ResponsiveView extends StatelessWidget {
  const ResponsiveView({
    super.key,
    required this.itemCount,
    required this.childBuilder,
    this.scrollController,
    this.mainAxisExtent,
    this.count,
  });
  final int itemCount;
  final int? count;
  final double? mainAxisExtent;
  final ScrollController? scrollController;
  final Widget Function(int) childBuilder;
  @override
  Widget build(BuildContext context) {
    bool isTabletResult = Responsive.isTablet();
    if (isTabletResult) {
      return GridViewWidget(
          scrollController: scrollController,
          child: childBuilder,
          count: count ?? 2,
          mainAxisExtent: mainAxisExtent,
          itemCount: itemCount);
    } else {
      return ListViewWidget(
        itemExtent: mainAxisExtent,
        itemCount: itemCount,
        childBuilder: childBuilder,
        scrollController: scrollController,
      );
    }
  }
}
