import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
import 'package:sizer/sizer.dart';

class PosShimmer extends StatelessWidget {
  const PosShimmer({super.key});

  @override
  Widget build(BuildContext context) {
    final bool isTablet = 100.w >= 600;
    final int crossAxisCount = isTablet ? 4 : 2;
    final double childAspectRatio = isTablet ? 0.75 : 0.65;
    final baseColor = Colors.grey[300]!;
    final highlightColor = Colors.grey[100]!;

    return Shimmer.fromColors(
      baseColor: baseColor,
      highlightColor: highlightColor,
      child: GridView.builder(
        padding: EdgeInsets.all(4.w),
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: crossAxisCount,
          childAspectRatio: childAspectRatio,
          crossAxisSpacing: 4.w,
          mainAxisSpacing: 4.w,
        ),
        itemCount: 6,
        itemBuilder: (context, index) {
          return Container(
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(2.5.w),
              border: Border.all(color: Colors.white),
            ),
            padding: EdgeInsets.all(3.w),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Expanded(
                  flex: 3,
                  child: Container(
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(2.w),
                    ),
                  ),
                ),

                SizedBox(height: 1.5.h),

                Container(
                  width: double.infinity,
                  height: 1.5.h,
                  color: Colors.white,
                ),
                SizedBox(height: 0.8.h),

                Container(width: 15.w, height: 1.2.h, color: Colors.white),
                SizedBox(height: 0.8.h),

                Container(width: 20.w, height: 1.5.h, color: Colors.white),

                SizedBox(height: 1.5.h),

                Container(
                  width: double.infinity,
                  height: 4.h,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(2.w),
                    border: Border.all(color: Colors.white, width: 1.5),
                  ),
                ),
              ],
            ),
          );
        },
      ),
    );
  }
}
