import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';

class AdWidget extends StatelessWidget {
  final int count;

  const AdWidget({Key? key, required this.count}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: count,
        shrinkWrap: true,
        physics: const NeverScrollableScrollPhysics(),
        itemBuilder: (BuildContext context, int index) {
          return Padding(
            padding: const EdgeInsets.only(bottom: 15),
            child: buildAdContainer(),
          );
        });
  }

  Widget buildAdContainer() {
    return Row(
      children: [
        Image.asset(
          MyAssets.bnCar,
          width: 80,
          height: 80,
          fit: BoxFit.cover,
        ),
        12.width,
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        "Toyota Crolla".toText(fontSize: 16, isBold: true),
                        Row(
                          children: [
                            "Model:".toText(
                              color: MyColors.lightTextColor,
                            ),
                            2.width,
                            "2019".toText(),
                          ],
                        ),
                        Row(
                          children: [
                            "Mileage:".toText(
                              color: MyColors.lightTextColor,
                            ),
                            2.width,
                            "73,000 km".toText(),
                          ],
                        ),
                      ],
                    ),
                  ),
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      "Riyadh".toText(
                        color: MyColors.lightTextColor,
                      ),
                      "9 Hours Ago".toText(
                        color: MyColors.lightTextColor,
                      ),
                    ],
                  ),
                ],
              ),
              8.height,
              Row(
                children: [
                  Expanded(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        "30,000".toText(fontSize: 16, isBold: true),
                        2.width,
                        "SAR:".toText(
                          color: MyColors.lightTextColor,
                        ),
                      ],
                    ),
                  ),
                  const Icon(Icons.arrow_forward)
                ],
              ),
            ],
          ),
        ),
      ],
    ).toWhiteContainer(width: double.infinity, allPading: 12);
  }
}
