import 'package:diplomaticquarterapp/core/model/contactus/get_hmg_locations.dart';
import 'package:diplomaticquarterapp/core/viewModels/contactus/findus_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:giffy_dialog/giffy_dialog.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:maps_launcher/maps_launcher.dart';

class HospitalsPage extends StatefulWidget {
  final List<GetHMGLocationsModel> findusHospitalModelList;

  HospitalsPage({Key key, this.findusHospitalModelList});

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

class _HospitalsPageState extends State<HospitalsPage> {
  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      isShowDecPage: false,
      body: SingleChildScrollView(
        child: Container(
          // margin: EdgeInsets.only(left: 15,right: 15,top: 70),
          margin: EdgeInsets.only(left: 15, right: 15, top: 70),
          child: Column(
            children: [
              ...List.generate(
                  widget.findusHospitalModelList.length,
                  (index) => Container(
                        decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          border: Border.all(color: Colors.white, width: 0.5),
                          borderRadius: BorderRadius.all(Radius.circular(5)),
                          color: Colors.white,
                        ),
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                              Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: <Widget>[
                                  Expanded(
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      crossAxisAlignment:
                                          CrossAxisAlignment.center,
                                      children: <Widget>[
                                        InkWell(
                                          onTap: () {
                                            showDialog(
                                                context: context,
                                                builder: (_) =>
                                                    AssetGiffyDialog(
                                                      title: Text(
                                                        widget
                                                            .findusHospitalModelList[
                                                                index]
                                                            .locationName,
                                                        style: TextStyle(
                                                            fontSize: 22.0,
                                                            fontWeight:
                                                                FontWeight
                                                                    .w600),
                                                      ),
                                                      image: Image.network(
                                                        widget
                                                            .findusHospitalModelList[
                                                                index]
                                                            .projectImageURL
                                                            .toString(),
                                                        fit: BoxFit.cover,
                                                      ),
                                                      buttonCancelText:
                                                          Text('cancel'),
                                                      buttonCancelColor:
                                                          Colors.grey,
                                                      onlyCancelButton: true,
                                                    ));
                                          },
                                          child: Container(
                                              width: 70,
                                              height: 70,
                                              child: Image.network(widget
                                                  .findusHospitalModelList[
                                                      index]
                                                  .projectImageURL
                                                  .toString())),
                                        ),
                                        Expanded(
                                            flex: 4,
                                            child: Container(
                                                margin: EdgeInsets.only(
                                                    left: 5,
                                                    right: 5,
                                                    top: 10,
                                                    bottom: 1),
                                                child: Texts(
                                                  '${widget.findusHospitalModelList[index].locationName}',
                                                  textAlign: TextAlign.start,
                                                ))), //model.cOCItemList[index].cOCTitl
                                        Expanded(
                                          flex: 2,
                                          child: Row(
                                            crossAxisAlignment:
                                                CrossAxisAlignment.center,
                                            children: [
                                              IconButton(
                                                icon: Icon(
                                                  Icons.location_on,
                                                  color: Theme.of(context)
                                                      .primaryColor,
                                                  size: 35,
                                                ),
                                                // icon: new Image.asset(
                                                //     'assets/images/new-design/navigate.png'),
                                                tooltip: '',
                                                onPressed: () {
                                                  setState(() {
                                                    MapsLauncher.launchCoordinates(
                                                        double.parse(widget
                                                            .findusHospitalModelList[
                                                                index]
                                                            .latitude),
                                                        double.parse(widget
                                                            .findusHospitalModelList[
                                                                index]
                                                            .longitude),
                                                        widget
                                                            .findusHospitalModelList[
                                                                index]
                                                            .locationName);
                                                  });
                                                },
                                              ),
                                              IconButton(
                                                icon: Icon(
                                                  Icons.phone,
                                                  color: Theme.of(context)
                                                      .primaryColor,
                                                  size: 35,
                                                ),
                                                // icon: new Image.asset(
                                                //     'assets/images/new-design/call.png'),
                                                tooltip: '',
                                                onPressed: () {
                                                  setState(() {
                                                    //  _volume += 10;
                                                    launch("tel://" +
                                                        widget
                                                            .findusHospitalModelList[
                                                                index]
                                                            .phoneNumber);
                                                  });
                                                },
                                              ),
                                            ],
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ],
                              ),
                              // Texts('${model.FindusHospitalModelList[index].locationName}'),
                              Divider(
                                height: 4.5,
                                color: Colors.grey[500],
                              )
                            ],
                          ),
                        ),
                      )),
              SizedBox(
                height: 8,
              ),
              Container(
                width: double.infinity,
                height: 100,
                color: Colors.white,
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    IconButton(
                      icon: new Image.asset(
                          'assets/images/new-design/youtube.png'),
                      iconSize: 70,
                      tooltip: 'Youtube',
                      onPressed: () {
                        setState(() {
                          launch(
                              "https://www.youtube.com/c/DrsulaimanAlhabibHospitals");
                        });
                      },
                    ),
                    IconButton(
                      icon: new Image.asset(
                          'assets/images/new-design/linkedin.png'),
                      tooltip: 'LinkedIn',
                      iconSize: 70,
                      onPressed: () {
                        setState(() {
                          launch(
                              "https://www.linkedin.com/company/drsulaiman-alhabib-medical-group");
                        });
                      },
                    ),
                    IconButton(
                      icon: new Image.asset(
                          'assets/images/new-design/twitter.png'),
                      tooltip: 'Twitter',
                      iconSize: 70,
                      onPressed: () {
                        setState(() {
                          launch("https://twitter.com/HMG");
                        });
                      },
                    ),
                    IconButton(
                      icon: new Image.asset(
                          'assets/images/new-design/facebook.png'),
                      tooltip: 'facebook',
                      iconSize: 70,
                      onPressed: () {
                        setState(() {
                          launch(
                              "https://www.facebook.com/DrSulaimanAlHabib?ref=tn_tnmn");
                        });
                      },
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
