import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/blood_donation/blood_donation_view_model.dart';
import 'package:hmg_patient_app_new/presentation/blood_donation/widgets/city_list_item.dart';

class SelectCityWidget extends StatelessWidget {
  SelectCityWidget({super.key, required this.bloodDonationViewModel});

  BloodDonationViewModel bloodDonationViewModel;

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        SizedBox(height: 8.h),
        SizedBox(
          height: MediaQuery.sizeOf(context).height * .4,
          child: ListView.separated(
              itemBuilder: (_, index) {
                return CityListItem(
                  cityModel: bloodDonationViewModel.citiesList[index],
                ).onPress(() {
                  bloodDonationViewModel.setSelectedCity(bloodDonationViewModel.citiesList[index]);
                  Navigator.of(context).pop();
                });
              },
              separatorBuilder: (_, __) => SizedBox(height: 8.h),
              itemCount: bloodDonationViewModel.citiesList.length),
        )
      ],
    );
  }
}
