//import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/model/blooddonation/get_all_cities.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

// todo 'sikander' remove this file when usage known
class SelectCiteisDialog extends StatefulWidget {
  final List<CitiesModel> hospitals;
  final Function(CitiesModel) onValueSelected;
  CitiesModel selectedHospital;

  SelectCiteisDialog(
      {Key key, this.hospitals, this.onValueSelected, this.selectedHospital});

  @override
  _SelectCiteisDialogState createState() => _SelectCiteisDialogState();
}

class _SelectCiteisDialogState extends State<SelectCiteisDialog> {
  @override
  void initState() {
    super.initState();

    widget.selectedHospital = widget.selectedHospital ?? widget.hospitals[0];
  }

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectProvider = Provider.of(context);

    return SimpleDialog(
      children: [
        Column(
          children: [
            Divider(),
            ...List.generate(
              widget.hospitals.length,
              (index) => Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  SizedBox(
                    height: 2,
                  ),
                  Row(
                    children: <Widget>[
                      Expanded(
                        flex: 1,
                        child: InkWell(
                          onTap: () {
                            setState(() {
                              widget.selectedHospital = widget.hospitals[index];
                            });
                          },
                          child: ListTile(
                            // title: Text(widget.hospitals[index].description +
                            //     ' ${widget.hospitals[index].distanceInKilometers} KM'),
                            title: Text(projectProvider.isArabic
                                ? widget.hospitals[index].descriptionN
                                : widget.hospitals[index].description),
                            leading: Radio(
                              value: widget.hospitals[index],
                              groupValue: widget.selectedHospital,
                              activeColor: Colors.red[800],
                              onChanged: (value) {
                                setState(() {
                                  widget.selectedHospital = value;
                                });
                              },
                            ),
                          ),
                        ),
                      )
                    ],
                  ),
                  SizedBox(
                    height: 5.0,
                  ),
                ],
              ),
            ),
            SizedBox(
              height: 5.0,
            ),
            Row(
              // mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Expanded(
                  flex: 1,
                  child: InkWell(
                    onTap: () {
                      Navigator.pop(context);
                    },
                    child: Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Container(
                        child: Center(
                          child: Texts(
                            TranslationBase.of(context).cancel.toUpperCase(),
                            color: Colors.red,
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
                Container(
                  width: 1,
                  height: 30,
                  color: Colors.grey[500],
                ),
                Expanded(
                  flex: 1,
                  child: InkWell(
                    onTap: () {
                      widget.onValueSelected(widget.selectedHospital);
                      Navigator.pop(context);
                    },
                    child: Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Center(
                          child: Texts(
                        TranslationBase.of(context).ok,
                        fontWeight: FontWeight.w400,
                      )),
                    ),
                  ),
                ),
              ],
            )
          ],
        )
      ],
    );
  }
}
