import 'package:diplomaticquarterapp/core/viewModels/er/near_hospital_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/location_util.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/pages/ErService/widgets/card_common.dart';
import 'widgets/card_position.dart';

class NearestEr extends StatelessWidget {
  static const String _url = "assets/images/";

  int appointmentNo;
  int projectID;

  NearestEr({this.appointmentNo, this.projectID});

  @override
  Widget build(BuildContext context) {
    return BaseView<NearHospitalViewModel>(
      onModelReady: appointmentNo != null && projectID != null
          ? (model) => model.getProjectAvgERWaitingTimeOrders(
              id: appointmentNo, projectID: projectID)
          : (model) => model.getProjectAvgERWaitingTimeOrders(),
      builder: (_, mode, widget) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: 'Nearest ER',
        baseViewModel: mode,
        body: mode.ProjectAvgERWaitingTimeModeList.length > 0
            ? Container(
                child: ListView(
                  children: <Widget>[
                    Text(
                        "\nThis service Displays nearest branch\n among all the branches  of All Habib \n medical Group based on your current Location",
                        textAlign: TextAlign.center,
                        style: TextStyle(
                            fontSize: 18.0,
                            letterSpacing: 1.0,
                            fontWeight: FontWeight.w900,
                            color: new Color(0xFF60686b))),
                    Container(
                        margin: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            Row(
                              mainAxisSize: MainAxisSize.min,
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                                Expanded(
                                  child: Container(
                                    child: CardPosition(
                                      text: mode
                                          .ProjectAvgERWaitingTimeModeList[0]
                                          .projectName
                                          .toString(),
                                      image:
                                          'assets/images/new-design/find_us_icon.png',
                                      subText: mode
                                          .ProjectAvgERWaitingTimeModeList[0]
                                          .distanceInKilometers
                                          .toString(),
                                      type: mode
                                          .ProjectAvgERWaitingTimeModeList[0].iD
                                          .toString(),
                                      telephone: mode
                                          .ProjectAvgERWaitingTimeModeList[0]
                                          .phoneNumber
                                          .toString(),
                                      networkImage: mode
                                          .ProjectAvgERWaitingTimeModeList[0]
                                          .projectImageURL
                                          .toString(),
                                      latitude: mode
                                          .ProjectAvgERWaitingTimeModeList[0]
                                          .latitude,
                                      longitude: mode
                                          .ProjectAvgERWaitingTimeModeList[0]
                                          .longitude,
                                      projectname: mode
                                          .ProjectAvgERWaitingTimeModeList[0]
                                          .projectName,
                                    ),
                                  ),

                                ),
                                Expanded(
                                  child: Container(
                                    child: CardPosition(
                                      text: mode
                                          .ProjectAvgERWaitingTimeModeList[1]
                                          .projectName
                                          .toString(),
                                      image:
                                          'assets/images/new-design/find_us_icon.png',
                                      subText: mode
                                          .ProjectAvgERWaitingTimeModeList[1]
                                          .distanceInKilometers
                                          .toString(),
                                      type: mode
                                          .ProjectAvgERWaitingTimeModeList[1].iD
                                          .toString(),
                                      telephone: mode
                                          .ProjectAvgERWaitingTimeModeList[1]
                                          .phoneNumber
                                          .toString(),
                                      networkImage: mode
                                          .ProjectAvgERWaitingTimeModeList[1]
                                          .projectImageURL
                                          .toString(),
                                      latitude: mode
                                          .ProjectAvgERWaitingTimeModeList[1]
                                          .latitude,
                                      longitude: mode
                                          .ProjectAvgERWaitingTimeModeList[1]
                                          .longitude,
                                      projectname: mode
                                          .ProjectAvgERWaitingTimeModeList[1]
                                          .projectName,
                                    ),
                                  ),

                                )
                              ],
                            ),
                            Row(
                              mainAxisSize: MainAxisSize.min,
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                                Expanded(
                                  child: Container(
                                    child: CardPosition(

                                      text: mode
                                          .ProjectAvgERWaitingTimeModeList[2]
                                          .projectName
                                          .toString(),
                                      image:
                                          'assets/images/new-design/find_us_icon.png',

                                      subText: mode
                                          .ProjectAvgERWaitingTimeModeList[2]
                                          .distanceInKilometers
                                          .toString(),
                                      type: mode
                                          .ProjectAvgERWaitingTimeModeList[2].iD
                                          .toString(),
                                      telephone: mode
                                          .ProjectAvgERWaitingTimeModeList[2]
                                          .phoneNumber
                                          .toString(),
                                      networkImage: mode
                                          .ProjectAvgERWaitingTimeModeList[2]
                                          .projectImageURL
                                          .toString(),
                                      latitude: mode
                                          .ProjectAvgERWaitingTimeModeList[2]
                                          .latitude,
                                      longitude: mode
                                          .ProjectAvgERWaitingTimeModeList[2]
                                          .longitude,
                                      projectname: mode
                                          .ProjectAvgERWaitingTimeModeList[2]
                                          .projectName,
                                    ),
                                  ),

                                ),
                                Expanded(
                                  child: Container(
                                    child: CardPosition(

                                      text: mode
                                          .ProjectAvgERWaitingTimeModeList[3]
                                          .projectName
                                          .toString(),
                                      image:
                                          'assets/images/new-design/find_us_icon.png',

                                      subText: mode
                                          .ProjectAvgERWaitingTimeModeList[3]
                                          .distanceInKilometers
                                          .toString(),
                                      type: mode
                                          .ProjectAvgERWaitingTimeModeList[3].iD
                                          .toString(),
                                      telephone: mode
                                          .ProjectAvgERWaitingTimeModeList[3]
                                          .phoneNumber
                                          .toString(),
                                      networkImage: mode
                                          .ProjectAvgERWaitingTimeModeList[3]
                                          .projectImageURL
                                          .toString(),
                                      latitude: mode
                                          .ProjectAvgERWaitingTimeModeList[3]
                                          .latitude,
                                      longitude: mode
                                          .ProjectAvgERWaitingTimeModeList[3]
                                          .longitude,
                                      projectname: mode
                                          .ProjectAvgERWaitingTimeModeList[3]
                                          .projectName,
                                    ),
                                  ),
                                  flex: 0,
                                )
                              ],
                            ),
                            Row(
                              mainAxisSize: MainAxisSize.max,
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                                Expanded(
                                  child: Container(
                                    child: CardPosition(

                                      text: mode
                                          .ProjectAvgERWaitingTimeModeList[4]
                                          .projectName
                                          .toString(),
                                      image:
                                          'assets/images/new-design/find_us_icon.png',

                                      subText: mode
                                          .ProjectAvgERWaitingTimeModeList[4]
                                          .distanceInKilometers
                                          .toString(),
                                      type: mode
                                          .ProjectAvgERWaitingTimeModeList[4].iD
                                          .toString(),
                                      telephone: mode
                                          .ProjectAvgERWaitingTimeModeList[4]
                                          .phoneNumber
                                          .toString(),
                                      networkImage: mode
                                          .ProjectAvgERWaitingTimeModeList[4]
                                          .projectImageURL
                                          .toString(),
                                      latitude: mode
                                          .ProjectAvgERWaitingTimeModeList[4]
                                          .latitude,
                                      longitude: mode
                                          .ProjectAvgERWaitingTimeModeList[4]
                                          .longitude,
                                      projectname: mode
                                          .ProjectAvgERWaitingTimeModeList[4]
                                          .projectName,
                                    ),
                                  ),

                                ),
                                Expanded(
                                  child: Container(
                                    child: CardPosition(
                                      text: mode
                                          .ProjectAvgERWaitingTimeModeList[5]
                                          .projectName
                                          .toString(),
                                      image:
                                          'assets/images/new-design/find_us_icon.png',
                                      subText: mode
                                          .ProjectAvgERWaitingTimeModeList[5]
                                          .distanceInKilometers
                                          .toString(),
                                      type: mode
                                          .ProjectAvgERWaitingTimeModeList[5].iD
                                          .toString(),
                                      telephone: mode
                                          .ProjectAvgERWaitingTimeModeList[5]
                                          .phoneNumber
                                          .toString(),
                                      networkImage: mode
                                          .ProjectAvgERWaitingTimeModeList[5]
                                          .projectImageURL
                                          .toString(),
                                      latitude: mode
                                          .ProjectAvgERWaitingTimeModeList[5]
                                          .latitude,
                                      longitude: mode
                                          .ProjectAvgERWaitingTimeModeList[5]
                                          .longitude,
                                      projectname: mode
                                          .ProjectAvgERWaitingTimeModeList[5]
                                          .projectName,
                                    ),
                                  ),

                                )
                              ],
                            ),
                            Row(
                              mainAxisSize: MainAxisSize.max,
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                                Expanded(
                                  child: Container(
                                    child: CardPosition(
                                      text: mode
                                          .ProjectAvgERWaitingTimeModeList[6]
                                          .projectName
                                          .toString(),
                                      image:
                                          'assets/images/new-design/find_us_icon.png',
                                      subText: mode
                                          .ProjectAvgERWaitingTimeModeList[6]
                                          .distanceInKilometers
                                          .toString(),
                                      type: mode
                                          .ProjectAvgERWaitingTimeModeList[6].iD
                                          .toString(),
                                      telephone: mode
                                          .ProjectAvgERWaitingTimeModeList[6]
                                          .phoneNumber
                                          .toString(),
                                      networkImage: mode
                                          .ProjectAvgERWaitingTimeModeList[6]
                                          .projectImageURL
                                          .toString(),
                                      latitude: mode
                                          .ProjectAvgERWaitingTimeModeList[6]
                                          .latitude,
                                      longitude: mode
                                          .ProjectAvgERWaitingTimeModeList[6]
                                          .longitude,
                                      projectname: mode
                                          .ProjectAvgERWaitingTimeModeList[6]
                                          .projectName,
                                    ),
                                  ),
                                  flex: 0,
                                ),
                              ],
                            ),
                          ],
                        )),
                  ],
                ),
              )
            : Center(
                child: Texts('No Data'),
              ),
      ),
    );
  }
}

