import 'package:diplomaticquarterapp/models/LiveCare/ClinicsServiceTimingsResponse.dart';
import 'package:flutter/material.dart';

class ClinicTimingsDialog extends StatefulWidget {
  final clinicName;
  final List<PatientERGetClinicsServiceTimingsList>
      patientERGetClinicsServiceTimingsList;

  ClinicTimingsDialog(
      {@required this.clinicName,
      @required this.patientERGetClinicsServiceTimingsList});

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

class _ClinicTimingsDialogState extends State<ClinicTimingsDialog> {
  @override
  void initState() {
    print(widget.patientERGetClinicsServiceTimingsList);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    var size = MediaQuery.of(context).size;
    final double itemHeight = ((size.height - kToolbarHeight - 24) * 0.42) / 2;
    final double itemWidth = size.width / 2;
    return Container(
      child: Dialog(
        shape:
            RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
        child: Container(
          height: MediaQuery.of(context).size.height * 0.68,
          margin: EdgeInsets.all(20.0),
          width: 450.0,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
              Container(
                alignment: Alignment.center,
                margin: EdgeInsets.only(bottom: 10.0),
                child: Text("Clinic Schedule",
                    textAlign: TextAlign.center,
                    style:
                        TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
              ),
              Divider(
                thickness: 1.0,
                color: Colors.grey[400],
              ),
              Container(
                margin: EdgeInsets.only(bottom: 20.0, top: 10.0),
                child: Text(widget.clinicName,
                    style:
                        TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
              ),
              CustomScrollView(
                primary: false,
                physics: NeverScrollableScrollPhysics(),
                shrinkWrap: true,
                slivers: <Widget>[
                  SliverPadding(
                    padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
                    sliver: SliverGrid.count(
                        crossAxisCount: 2,
                        childAspectRatio: (itemWidth / itemHeight),
                        children: widget.patientERGetClinicsServiceTimingsList
                            .map((e) => Container(
                                  height: 10.0,
                                  child: Column(
                                    children: <Widget>[
                                      Text(e.dayOfWeekStr),
                                      Text(e.shiftTimings[0].startTime +
                                          " - " +
                                          e.shiftTimings[0].endTime),
                                    ],
                                  ),
                                ))
                            .toList()),
                  ),
                ],
              ),
              Divider(
                thickness: 1.0,
                color: Colors.grey[400],
              ),
              Container(
                alignment: Alignment.center,
                height: 30.0,
                child: Flex(
                  direction: Axis.horizontal,
                  children: <Widget>[
                    Expanded(
                      child: InkWell(
                        onTap: () {
                          Navigator.pop(context);
                        },
                        child: Container(
                          child: Text("OK",
                              textAlign: TextAlign.center,
                              style: TextStyle(
                                fontSize: 18.0,
                              )),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
