import 'package:flutter/material.dart';

import '../../../../common/theme/theme.dart';
import '../../../../domain/analytic/analytic.dart';
import '../../../components/spacer/spacer.dart';
import 'title.dart';
import 'top_product_tile.dart';

class HomeTopProduct extends StatelessWidget {
  final List<DashboardTopProduct> products;
  const HomeTopProduct({super.key, required this.products});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(
        vertical: 24,
        horizontal: AppValue.padding,
      ).copyWith(bottom: 0),
      child: Column(
        children: [
          HomeTitle(title: 'Product Terlaris Hari Ini'),
          SpaceHeight(20),
          ListView.builder(
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            itemCount: products.length,
            itemBuilder: (context, index) {
              return HomeTopProductTile(
                product: products[index],
                ranking: index + 1,
              );
            },
          ),
        ],
      ),
    );
  }
}
