import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hoshan/ui/theme/colors.dart';
import 'package:hoshan/ui/theme/cubit/theme_mode_cubit.dart';
import 'package:shimmer/shimmer.dart';

class ListviewPlaceholder extends StatelessWidget {
  final int count;
  final double? itemWidth;
  final double? itemHeight;
  final Widget child;
  final Axis scrollDirection;
  const ListviewPlaceholder(
      {super.key,
      this.count = 10,
      this.itemWidth,
      this.itemHeight,
      required this.child,
      this.scrollDirection = Axis.vertical});

  @override
  Widget build(BuildContext context) {
    final isDark = context.read<ThemeModeCubit>().state == ThemeMode.dark;

    return ListView.builder(
      physics: const NeverScrollableScrollPhysics(),
      shrinkWrap: true,
      itemCount: count,
      padding: const EdgeInsets.symmetric(vertical: 8),
      scrollDirection: scrollDirection,
      itemBuilder: (context, index) {
        return SizedBox(
          width: itemWidth,
          height: itemHeight,
          child: Shimmer.fromColors(
              baseColor: AppColors.gray[isDark ? 800 : 400],
              highlightColor: AppColors.gray[isDark ? 900 : 600],
              child: child),
        );
      },
    );
  }
}
