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.
diplomatic-quarter/lib/pages/BookAppointment/widgets/DoctorView.dart

202 lines
7.5 KiB
Dart

import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorProfile.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:rating_bar/rating_bar.dart';
import '../DoctorProfile.dart';
class DoctorView extends StatelessWidget {
final DoctorList doctor;
bool isLiveCareAppointment;
DoctorView({@required this.doctor, @required this.isLiveCareAppointment});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
getDoctorsProfile(context, doctor);
},
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: <Widget>[
Expanded(
flex: 1,
child: ClipRRect(
borderRadius: BorderRadius.circular(100.0),
child: Image.network(this.doctor.doctorImageURL,
fit: BoxFit.fill, height: 60.0, width: 60.0),
),
),
Expanded(
flex: 4,
child: Container(
width: MediaQuery.of(context).size.width * 0.55,
margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (doctor.doctorTitle != null)
Text(this.doctor.doctorTitle + " " + this.doctor.name,
style: TextStyle(
fontSize: 14.0,
color: Colors.grey[700],
letterSpacing: 1.0)),
Container(
margin: EdgeInsets.only(top: 3.0),
child: Text(
this.doctor.clinicName != null
? this.doctor.clinicName
: "",
style: TextStyle(
fontSize: 12.0,
color: Colors.grey[600],
letterSpacing: 1.0)),
),
Container(
margin: EdgeInsets.only(top: 3.0),
child: Text(this.doctor.projectName,
style: TextStyle(
fontSize: 12.0,
color: Colors.grey[600],
letterSpacing: 1.0)),
),
if (doctor.speciality != null)
Container(
margin: EdgeInsets.only(top: 3.0, bottom: 3.0),
child: Text(
getDoctorSpeciality(this.doctor.speciality)
.trim(),
style: TextStyle(
fontSize: 12.0,
color: Colors.grey[600],
letterSpacing: 1.0)),
),
this.doctor.nearestFreeSlot != null
? Container(
margin: EdgeInsets.only(top: 3.0, bottom: 3.0),
child: Text(getDate(this.doctor.nearestFreeSlot),
style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.bold,
color: Colors.green[600],
letterSpacing: 1.0)),
)
: Container(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
RatingBar.readOnly(
initialRating:
this.doctor.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(
child: Image.network(this.doctor.nationalityFlagURL,
width: 25.0, height: 25.0),
),
],
),
],
),
),
),
],
),
),
),
);
}
String getDoctorSpeciality(List<String> docSpecial) {
String docSpeciality = "";
docSpecial.forEach((v) {
docSpeciality = docSpeciality + v + "\n";
});
return docSpeciality;
}
getDoctorsProfile(context, DoctorList docObject, {isAppo}) {
GifLoaderDialogUtils.showMyDialog(context);
List<DoctorProfileList> docProfileList = [];
DoctorsListService service = new DoctorsListService();
service
.getDoctorsProfile(docObject.doctorID, docObject.clinicID,
docObject.projectID, context)
.then((res) {
GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) {
if (res['DoctorProfileList'].length != 0) {
res['DoctorProfileList'].forEach((v) {
docProfileList.add(new DoctorProfileList.fromJson(v));
});
} else {}
navigateToDoctorProfile(context, docObject, docProfileList[0],
isAppo: isAppo);
} else {
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
}
}).catchError((err) {
print(err);
});
}
String getDate(String date) {
DateTime dateObj = DateUtil.convertStringToDate(date);
return DateUtil.getWeekDay(dateObj.weekday) +
", " +
dateObj.day.toString() +
" " +
DateUtil.getMonth(dateObj.month) +
" " +
dateObj.year.toString() +
" " +
dateObj.hour.toString() +
":" +
getMinute(dateObj);
}
String getMinute(DateTime dateObj) {
if (dateObj.minute == 0) {
return dateObj.minute.toString() + "0";
} else {
return dateObj.minute.toString();
}
}
Future navigateToDoctorProfile(context, docObject, docProfile,
{isAppo}) async {
Navigator.push(
context,
FadePage(
page: DoctorProfile(
doctor: docObject,
isLiveCareAppointment: isLiveCareAppointment,
docProfileList: docProfile,
isOpenAppt: isAppo,
)));
}
}