import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/DoctorView.dart';
import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';

class SearchResults extends StatefulWidget {
  List<DoctorList> doctorsList = [];
  List<PatientDoctorAppointmentList> patientDoctorAppointmentListHospital;

  SearchResults(
      {@required this.doctorsList, this.patientDoctorAppointmentListHospital});

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

class _SearchResultsState extends State<SearchResults> {
  var event = RobotProvider();
  List<DoctorList> tempList = [];

  @override
  void initState() {
    event.controller.stream.listen((p) {});
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      appBarTitle: TranslationBase.of(context).bookAppo,
      isShowAppBar: true,
      body: Container(
        margin: EdgeInsets.all(10.0),
        child: SingleChildScrollView(
          physics: BouncingScrollPhysics(),
          child: Column(
            children: <Widget>[
              ...List.generate(
                widget.patientDoctorAppointmentListHospital.length,
                (index) => AppExpandableNotifier(
                    title: widget
                        .patientDoctorAppointmentListHospital[index].filterName + " - "  +widget
                        .patientDoctorAppointmentListHospital[index].distanceInKMs + " " + TranslationBase.of(context).km,
                    bodyWidget: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: widget
                          .patientDoctorAppointmentListHospital[index]
                          .patientDoctorAppointmentList
                          .map((doctor) {
                        return DoctorView(
                          doctor: doctor,
                        );
                      }).toList(),
                    )),
              )
            ],
          ),
        ),
      ),
    );
  }
}
