import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/models/AppointmentType.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:flutter_countdown_timer/current_remaining_time.dart'; import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; import '../AppointmentDetails.dart'; class AppointmentCard extends StatefulWidget { AppoitmentAllHistoryResultList appo; final Function onReloadAppointmentHistory; AppointmentCard( {@required this.appo, @required this.onReloadAppointmentHistory}); @override _ApointmentCardState createState() => _ApointmentCardState(); } class _ApointmentCardState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return InkWell( onTap: () { navigateToAppointmentDetails(context, widget.appo); }, child: Card( // margin: EdgeInsets.fromLTRB(10.0, 16.0, 10.0, 8.0), color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), child: Container( decoration: BoxDecoration(), padding: EdgeInsets.all(7.0), width: MediaQuery.of(context).size.width, child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ ClipRRect( borderRadius: BorderRadius.circular(100.0), child: Image.network(widget.appo.doctorImageURL, fit: BoxFit.fill, height: 60.0, width: 60.0), ), Container( width: MediaQuery.of(context).size.width * 0.61, margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( widget.appo.doctorTitle + " " + widget.appo.doctorNameObj, style: TextStyle( fontSize: 14.0, color: Colors.grey[700], letterSpacing: 1.0)), Container( margin: EdgeInsets.only(top: 3.0), child: Text(widget.appo.clinicName, style: TextStyle( fontSize: 12.0, color: Colors.grey[600], letterSpacing: 1.0)), ), Container( margin: EdgeInsets.only(top: 3.0), child: Text(widget.appo.projectName, style: TextStyle( fontSize: 12.0, color: Colors.grey[600], letterSpacing: 1.0)), ), Container( margin: EdgeInsets.only(top: 3.0, bottom: 3.0), child: Text( DateUtil.getWeekDayMonthDayYearDateFormatted( DateUtil.convertStringToDate( widget.appo.appointmentDate), projectViewModel.isArabic ? "ar" : "en") .trim(), style: TextStyle( fontSize: 12.0, color: Colors.grey[600], letterSpacing: 1.0)), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: [ RatingBar.readOnly( initialRating: widget.appo.actualDoctorRate.toDouble(), size: 20.0, filledColor: Colors.yellow[700], emptyColor: Colors.grey[500], isHalfAllowed: true, halfFilledIcon: Icons.star_half, filledIcon: Icons.star, emptyIcon: Icons.star, ), Container( transform: Matrix4.translationValues(15.0, -40.0, 0.0), child: projectViewModel.isArabic ? Image.asset( "assets/images/new-design/arrow_menu_black-ar.png", width: 25.0, height: 25.0) : Image.asset( "assets/images/new-design/arrow_menu_black-en.png", width: 25.0, height: 25.0), ), ], ), (widget.appo.patientStatusType == AppointmentType.BOOKED || widget.appo.patientStatusType == AppointmentType.CONFIRMED) ? Container( child: CountdownTimer( endTime: DateTime.now().millisecondsSinceEpoch + (widget.appo.remaniningHoursTocanPay * 1000) * 60, widgetBuilder: (_, CurrentRemainingTime time) { return Text( '${time.days}:${time.hours}:${time.min}:${time.sec} ' + TranslationBase.of(context) .upcomingTimeLeft, style: TextStyle( fontSize: 12.0, color: Color(0xff40ACC9))); }, ), ) : Container(), ], ), ), ], ), ), ), ); } String getDate(String date) { DateTime dateObj = DateUtil.convertStringToDate(date); return DateUtil.getWeekDay(dateObj.weekday) + ", " + dateObj.day.toString() + " " + DateUtil.getMonth(dateObj.month) + " " + dateObj.year.toString(); } String getDoctorSpeciality(List docSpecial) { String docSpeciality = ""; docSpecial.forEach((v) { docSpeciality = docSpeciality + v + "\n"; }); return docSpeciality; } Future navigateToAppointmentDetails(context, appo) async { Navigator.push( context, MaterialPageRoute( builder: (context) => AppointmentDetails(appo: appo))) .then((value) { widget.onReloadAppointmentHistory(); }); } }