import 'package:flutter/material.dart';
import 'package:proxibuy/data/models/offer_model.dart';
import 'package:proxibuy/presentation/offer/bloc/widgets/offer_card.dart';
import 'package:proxibuy/presentation/pages/product_detail_page.dart';

class CategoryOffersRow extends StatelessWidget {
  final String categoryTitle;
  final List<OfferModel> offers;

  const CategoryOffersRow({
    super.key,
    required this.categoryTitle,
    required this.offers,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
          child: Text(
            categoryTitle,
            style: Theme.of(
              context,
            ).textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.bold),
          ),
        ),
        SizedBox(
          height: 300,
          child: ListView.builder(
            scrollDirection: Axis.horizontal,
            padding: const EdgeInsets.symmetric(horizontal: 16.0),
            itemCount: offers.length,
            itemBuilder: (context, index) {
              final offer = offers[index];
              return Padding(
                padding: const EdgeInsets.only(left: 12.0),
                child: OfferCard(
                  offer: offer,
                  width: 320,
                  onTap: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (_) {
                          return ProductDetailPage(offer: offer,);
                        },
                      ),
                    );
                  },
                ),
              );
            },
          ),
        ),
        // const SizedBox(height: 16),
      ],
    );
  }
}
