import 'package:circular_countdown_timer/circular_countdown_timer.dart'; import 'package:diplomaticquarterapp/models/FamilyFiles/PatientERVirtualHistoryResponse.dart'; import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart'; class LiveCarePendingRequest extends StatefulWidget { ErRequestHistoryList pendingERRequestHistoryList; final Function getLiveCareHistory; LiveCarePendingRequest( {@required this.getLiveCareHistory, this.pendingERRequestHistoryList}); @override _LiveCarePendingRequestState createState() => _LiveCarePendingRequestState(); } class _LiveCarePendingRequestState extends State { @override void initState() { // TODO: implement initState super.initState(); } @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( border: Border.all(color: Colors.grey[300]), borderRadius: BorderRadius.circular(10), color: Colors.white, shape: BoxShape.rectangle, ), margin: EdgeInsets.all(15.0), padding: EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Container( child: Text("In Progress:", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)), ), Container( alignment: Alignment.center, margin: EdgeInsets.only(top: 10.0), child: Text("Estimated Waiting Time: ", style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold)), ), Container( transform: Matrix4.translationValues(0.0, -50.0, 0.0), alignment: Alignment.center, child: CircularCountDownTimer( duration: widget.pendingERRequestHistoryList.watingtimeInteger * 60, width: MediaQuery.of(context).size.width / 3, height: MediaQuery.of(context).size.height / 3, color: Colors.white, fillColor: Colors.green[700], strokeWidth: 15.0, textStyle: TextStyle( fontSize: 22.0, color: Colors.black87, fontWeight: FontWeight.bold), isReverse: true, isTimerTextShown: true, onComplete: () { print('Countdown Ended'); }, ), ), Container( transform: Matrix4.translationValues(0.0, -60.0, 0.0), child: Divider( color: Colors.grey[500], thickness: 0.7, ), ), Container( transform: Matrix4.translationValues(0.0, -50.0, 0.0), child: Text("Requested date:", style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)), ), Container( transform: Matrix4.translationValues(0.0, -30.0, 0.0), child: Text( DateUtil.getDateFormatted( widget.pendingERRequestHistoryList.arrivalTime), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold)), ), Container( transform: Matrix4.translationValues(0.0, -20.0, 0.0), padding: EdgeInsets.all(7.0), decoration: BoxDecoration( shape: BoxShape.rectangle, borderRadius: BorderRadius.all(Radius.circular(5)), color: Colors.red[800], ), margin: EdgeInsets.only(top: 5.0, bottom: 5.0), child: Text(widget.pendingERRequestHistoryList.stringCallStatus, style: TextStyle(fontSize: 14.0, color: Colors.white)), ), Container( transform: Matrix4.translationValues(0.0, 0.0, 0.0), child: Divider( color: Colors.grey[500], thickness: 0.7, ), ), Container( alignment: Alignment.center, transform: Matrix4.translationValues(0.0, 10.0, 0.0), child: Text( "Your turn is after " + widget.pendingERRequestHistoryList.patCount.toString() + " Patients", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)), ), Container( transform: Matrix4.translationValues(0.0, 130.0, 0.0), alignment: Alignment.bottomCenter, width: MediaQuery.of(context).size.width, child: ButtonTheme( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), minWidth: MediaQuery.of(context).size.width, height: 45.0, child: RaisedButton( color: Colors.red[800], textColor: Colors.white, disabledTextColor: Colors.white, disabledColor: new Color(0xFFbcc2c4), onPressed: () { cancelLiveCareRequest(); }, child: Text(TranslationBase.of(context).cancel, style: TextStyle(fontSize: 18.0)), ), ), ), ], ), ); } cancelLiveCareRequest() { LiveCareService service = new LiveCareService(); service .cancelLiveCareRequest(widget.pendingERRequestHistoryList.vCID, context) .then((res) { AppToast.showSuccessToast( message: "LiveCare request cancelled successfully"); }) .catchError((err) { print(err); }) .showProgressBar( text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)) .then((value) { widget.getLiveCareHistory(); }); } }