From 62d96a3f1ccfa8396aa20f12704e41f1d9e2e493 Mon Sep 17 00:00:00 2001 From: Amjad amireh Date: Wed, 9 Sep 2020 10:17:16 +0300 Subject: [PATCH] edit card_position.dart --- lib/core/service/er/er_service.dart | 4 +- .../er/near_hospital_view_model.dart | 35 +- lib/pages/ErService/NearestEr.dart | 607 +++++++++--------- 3 files changed, 312 insertions(+), 334 deletions(-) diff --git a/lib/core/service/er/er_service.dart b/lib/core/service/er/er_service.dart index 87367f62..bd3b6116 100644 --- a/lib/core/service/er/er_service.dart +++ b/lib/core/service/er/er_service.dart @@ -20,8 +20,8 @@ class ErService extends BaseService { } var lat = await sharedPref.getDouble(USER_LAT); var long = await sharedPref.getDouble(USER_LONG); - body['Latitude'] = lat; - body['Longitude'] = long; + body['Latitude'] = lat ?? 0; + body['Longitude'] = long ?? 0; await baseAppClient.post(GET_NEAREST_HOSPITAL, onSuccess: (dynamic response, int statusCode) { diff --git a/lib/core/viewModels/er/near_hospital_view_model.dart b/lib/core/viewModels/er/near_hospital_view_model.dart index f1d1c350..f12aa28f 100644 --- a/lib/core/viewModels/er/near_hospital_view_model.dart +++ b/lib/core/viewModels/er/near_hospital_view_model.dart @@ -8,27 +8,24 @@ import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/BranchView.da import '../../../locator.dart'; class NearHospitalViewModel extends BaseViewModel { - - ErService _erService = locator(); + List get ProjectAvgERWaitingTimeModeList => _erService.projectAvgERWaitingTimeModelList; - getProjectAvgERWaitingTimeOrders({int id, int projectID}) async { - setState(ViewState.Busy); - - if (id != null && projectID != null) { - - await _erService.getProjectAvgERWaitingTimeOrders(id: id,projectID: projectID); - } else { - await _erService.getProjectAvgERWaitingTimeOrders(); - } - if (_erService.hasError) { - error = _erService.error; - setState(ViewState.Error); - } else - setState(ViewState.Idle); - } - - + getProjectAvgERWaitingTimeOrders({int id, int projectID}) async { + setState(ViewState.Busy); + + if (id != null && projectID != null) { + await _erService.getProjectAvgERWaitingTimeOrders( + id: id, projectID: projectID); + } else { + await _erService.getProjectAvgERWaitingTimeOrders(); + } + if (_erService.hasError) { + error = _erService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } } diff --git a/lib/pages/ErService/NearestEr.dart b/lib/pages/ErService/NearestEr.dart index 1cc741ff..e167770b 100644 --- a/lib/pages/ErService/NearestEr.dart +++ b/lib/pages/ErService/NearestEr.dart @@ -10,358 +10,339 @@ 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/"; + static const String _url = "assets/images/"; int appointmentNo; int projectID; + NearestEr({this.appointmentNo, this.projectID}); + @override Widget build(BuildContext context) { return BaseView( onModelReady: appointmentNo != null && projectID != null ? (model) => model.getProjectAvgERWaitingTimeOrders( - id: appointmentNo, projectID: projectID) + 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: [ - 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: [ - Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - 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 , + child: ListView( + children: [ + 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: [ + Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + 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, + ), + flex: 0, + ), + Expanded( + 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, + ), + flex: 0, + ) + ], ), - flex: 0, - - ), - Expanded( - 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 , - ), - flex: 0, - - ) - ], - ), - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: CardPosition( - + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: CardPosition( // mode // .vitalSignResModelList[ // mode.vitalSignResModelList.length - 1] // .heightCm // .toString() - 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 , - - ), - flex: 0, - ), - Expanded( - 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, + ), + flex: 0, + ), + Expanded( + child: CardPosition( // mode // .vitalSignResModelList[ // mode.vitalSignResModelList.length - 1] // .heightCm // .toString() - 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 , + 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, + ) + ], ), - flex: 0, - ) - ], - ), - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: CardPosition( - + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: CardPosition( // mode // .vitalSignResModelList[ // mode.vitalSignResModelList.length - 1] // .heightCm // .toString() - 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 , - ), - flex: 0, - ), - Expanded( - 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 , + 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, + ), + flex: 0, + ), + Expanded( + 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, + ), + flex: 0, + ) + ], ), - flex: 0, - - ) - ], - ), - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - 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 , + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + 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, + ), + ], ), - flex: 0, - ), - - ], - ), - ], - ) - ), - ], - ), - ) + ], + )), + ], + ), + ) : Center( - child: Texts('No Data'), - ), + child: Texts('No Data'), + ), ), ); } } - - -//class NearestEr extends StatefulWidget { -// static const String url = "assets/images/"; -// final bool isAppbar; -// -// -// const NearestEr({Key key, this.isAppbar}) : super(key: key); -// @override -// _NearestErState createState() => _NearestErState(); -//} -// -//class _NearestErState extends State { -// LocationUtils locationUtils; -// @override -// void initState() { -// locationUtils = -// new LocationUtils(isShowConfirmDialog: true, context: context); -// WidgetsBinding.instance -// .addPostFrameCallback((_) => locationUtils.getCurrentLocation()); -// -// super.initState(); -// } -// @override -// Widget build(BuildContext context) { -// return AppScaffold( -// isShowAppBar: widget.isAppbar, -// appBarTitle: TranslationBase.of(context).bookAppo, -// body: Container( -// margin: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 10.0), -// child: ListView( -// -// children: [ -// Text(TranslationBase.of(context).searchBy, -// style: TextStyle( -// fontSize: 24.0, -// letterSpacing: 1.0, -// fontWeight: FontWeight.bold, -// color: new Color(0xFF60686b))), -// Container( -// margin: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0), -// -// child: Column( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Row( -// mainAxisSize: MainAxisSize.min, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Expanded( -// child: CardPosition( -// text: "Olaya Hospital", -// image: 'assets/images/new-design/find_us_icon.png', -// -// subText: TranslationBase.of(context).requestA, -// type: 3, -// ), -// flex: 0, -// -// ), -// Expanded( -// child: CardPosition( -// image: 'assets/images/new-design/find_us_icon.png', -// text: "Takhassusi Hospital", -// subText: TranslationBase.of(context).locationa, -// type: 5), -// flex: 0, -// -// ) -// ], -// ), -// Row( -// mainAxisSize: MainAxisSize.max, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Expanded( -// child: CardPosition( -// image: 'assets/images/new-design/find_us_icon.png', -// text: "Arryan Hospital", -// subText: TranslationBase.of(context).requestA, -// type: 4, -// ), -// flex: 0, -// ), -// Expanded( -// child: CardPosition( -// image: 'assets/images/new-design/find_us_icon.png', -// text: "Suwaidi Hospital", -// subText: TranslationBase.of(context).locationa, -// type: 6), -// flex: 0, -// ) -// ], -// ), -// Row( -// mainAxisSize: MainAxisSize.max, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Expanded( -// child: CardPosition( -// image: 'assets/images/new-design/find_us_icon.png', -// text: "Al Qassim Hospital", -// subText: TranslationBase.of(context).requestA, -// type: 7, -// ), -// flex: 0, -// ), -// Expanded( -// child: CardPosition( -// image: 'assets/images/new-design/find_us_icon.png', -// text: "Khobar Hospital", -// subText: TranslationBase.of(context).locationa, -// type: 8), -// flex: 0, -// -// ) -// ], -// ), -// Row( -// mainAxisSize: MainAxisSize.max, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Expanded( -// child: CardPosition( -// image: 'assets/images/new-design/find_us_icon.png', -// text: "Dubai Hospital", -// subText: TranslationBase.of(context).requestA, -// type: 1, -// -// ), -// flex: 0, -// ), -// -// ], -// ), -// ], -// ) -// ), -// ], -// ), -// ), -// ); -// } -//}