You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
4.6 KiB
Dart
112 lines
4.6 KiB
Dart
import 'package:diplomaticquarterapp/core/model/contactus/get_hmg_locations.dart';
|
|
import 'package:diplomaticquarterapp/core/model/er/projectavgerwaitingtime.dart';
|
|
import 'package:diplomaticquarterapp/core/service/er/er_service.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
import 'package:diplomaticquarterapp/widgets/hospital_location.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../uitl/translations_delegate_base.dart';
|
|
|
|
class NearestEr extends StatefulWidget {
|
|
static const String _url = "assets/images/";
|
|
|
|
int appointmentNo;
|
|
int projectID;
|
|
|
|
NearestEr({this.appointmentNo, this.projectID});
|
|
|
|
@override
|
|
_NearestErState createState() => _NearestErState();
|
|
}
|
|
|
|
class _NearestErState extends State<NearestEr> {
|
|
List<ProjectAvgERWaitingTime> projectAvgERWaitingTimeModelList = List();
|
|
|
|
bool isDataLoaded;
|
|
|
|
@override
|
|
void initState() {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => getERList());
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var size = MediaQuery.of(context).size;
|
|
final double itemHeight = (size.height - kToolbarHeight - 24) / 2;
|
|
final double itemWidth = size.width / 2;
|
|
|
|
return AppScaffold(
|
|
isShowAppBar: true,
|
|
isShowDecPage: false,
|
|
showNewAppBarTitle: true,
|
|
showNewAppBar: true,
|
|
appBarTitle: TranslationBase.of(context).NearestEr,
|
|
body: isDataLoaded != null
|
|
? isDataLoaded
|
|
? ListView(
|
|
padding: EdgeInsets.all(21),
|
|
physics: BouncingScrollPhysics(),
|
|
children: <Widget>[
|
|
Text(
|
|
TranslationBase.of(context).NearestErDesc,
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16),
|
|
),
|
|
SizedBox(height: 21),
|
|
ListView.separated(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
padding: EdgeInsets.zero,
|
|
separatorBuilder: (context, index) => SizedBox(height: 14),
|
|
itemBuilder: (context, index) {
|
|
GetHMGLocationsModel location = GetHMGLocationsModel();
|
|
location.locationName = projectAvgERWaitingTimeModelList[index].projectName;
|
|
location.cityName = projectAvgERWaitingTimeModelList[index].projectName;
|
|
location.projectImageURL = projectAvgERWaitingTimeModelList[index].projectImageURL;
|
|
location.phoneNumber = projectAvgERWaitingTimeModelList[index].phoneNumber;
|
|
location.latitude = projectAvgERWaitingTimeModelList[index].latitude;
|
|
location.longitude = projectAvgERWaitingTimeModelList[index].longitude;
|
|
location.distanceInKilometers = projectAvgERWaitingTimeModelList[index].distanceInKilometers;
|
|
return HospitalLocation(location, waitingTime: projectAvgERWaitingTimeModelList[index].avgTimeInHHMM.toString());
|
|
},
|
|
itemCount: projectAvgERWaitingTimeModelList.length,
|
|
),
|
|
],
|
|
)
|
|
: Center(
|
|
child: Texts('No Data'),
|
|
)
|
|
: SizedBox(),
|
|
);
|
|
}
|
|
|
|
getERList() async {
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
ErService service = new ErService();
|
|
service.getProjectAvgERWaitingTimeOrders().then((response) {
|
|
if (response != null && response['MessageStatus'] == 1) {
|
|
setState(() {
|
|
projectAvgERWaitingTimeModelList.clear();
|
|
response['List_ProjectAvgERWaitingTime'].forEach((vital) {
|
|
projectAvgERWaitingTimeModelList.add(ProjectAvgERWaitingTime.fromJson(vital));
|
|
});
|
|
isDataLoaded = true;
|
|
});
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
} else {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
AppToast.showErrorToast(message: TranslationBase.of(context).serviceNotAvailable);
|
|
isDataLoaded = false;
|
|
}
|
|
}).catchError((err) {
|
|
print(err);
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
AppToast.showErrorToast(message: err.toString());
|
|
});
|
|
}
|
|
}
|