import 'package:hmg_patient_app/core/viewModels/appointment_rate_view_model.dart'; import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; import 'package:hmg_patient_app/models/Appointments/DoctorListResponse.dart'; import 'package:hmg_patient_app/pages/BookAppointment/widgets/DoctorView.dart'; import 'package:hmg_patient_app/pages/base/base_view.dart'; import 'package:hmg_patient_app/pages/insurance/insurance_update_screen.dart'; import 'package:hmg_patient_app/pages/landing/landing_page.dart'; import 'package:hmg_patient_app/pages/rateAppointment/rate_appointment_clinic.dart'; import 'package:hmg_patient_app/theme/colors.dart'; import 'package:hmg_patient_app/uitl/app_toast.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/utils_new.dart'; import 'package:hmg_patient_app/widgets/buttons/defaultButton.dart'; import 'package:hmg_patient_app/widgets/dialogs/confirm_dialog.dart'; import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart'; import 'package:hmg_patient_app/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class RateAppointmentDoctor extends StatefulWidget { bool isFromRegistration; RateAppointmentDoctor({Key? key, this.isFromRegistration = false}) : super(key: key); @override _RateAppointmentDoctorState createState() => _RateAppointmentDoctorState(); } class _RateAppointmentDoctorState extends State { final formKey = GlobalKey(); String note = ""; int rating = 0; ProjectViewModel? projectViewModel; @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, showNewAppBar: true, showNewAppBarTitle: true, baseViewModel: model, appBarTitle: TranslationBase.of(context).rateDoctor, body: SingleChildScrollView( child: Container( padding: EdgeInsets.all(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( TranslationBase.of(context).lastVisit, style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), ), SizedBox( height: 25, ), Container( child: DoctorView( doctor: getDoctorObject(model), isLiveCareAppointment: false, isShowFlag: false, ), ), SizedBox( height: 12, ), Container( width: double.infinity, child: Container( decoration: cardRadius(10), child: Padding( padding: const EdgeInsets.all(12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( TranslationBase.of(context).tapTitle, style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), ), SizedBox( height: 12, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ ...List.generate( 5, (index) => AnimatedSwitcher( duration: Duration(milliseconds: 1000), switchInCurve: Curves.elasticOut, switchOutCurve: Curves.elasticIn, transitionBuilder: (Widget child, Animation animation) { return ScaleTransition( child: child, scale: animation); }, child: Container( key: ValueKey(rating), child: IconButton( iconSize: 45.0, onPressed: () { setState(() { rating = index + 1; }); }, color: rating >= (index + 1) ? Color.fromRGBO(255, 186, 0, 1.0) : Colors.grey[400], icon: Icon(rating >= (index + 1) ? Icons.star : Icons.star)), ), ), ) ], ), ], ), ), ), ), SizedBox( height: 12, ), Container( decoration: cardRadius(10), child: Padding( padding: EdgeInsets.all(8.0), child: TextField( maxLines: 5, decoration: InputDecoration.collapsed( hintText: TranslationBase.of(context).notes, hintStyle: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16)), onChanged: (value) { setState(() { note = value; }); }, ))), ], ), ), ), bottomSheet: Container( color: Colors.white, padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), child: Row( mainAxisSize: MainAxisSize.min, children: [ Expanded( child: DefaultButton( TranslationBase.of(context).later, () { if(widget.isFromRegistration) { ConfirmDialog dialog = new ConfirmDialog( context: context, confirmMessage: TranslationBase.of(context).validInsurance, okText: TranslationBase.of(context).yes, cancelText: TranslationBase.of(context).no, okFunction: () { ConfirmDialog.closeAlertDialog(context); Navigator.pushAndRemoveUntil( context, MaterialPageRoute(builder: (context) => LandingPage()), (Route route) => false, ); Navigator.push(context, FadePage(page: InsuranceUpdate())); }, cancelFunction: () { Navigator.pushAndRemoveUntil( context, MaterialPageRoute(builder: (context) => LandingPage()), (Route route) => false, ); }); dialog.showAlertDialog(context); } else { Navigator.pushReplacement( context, FadePage( page: LandingPage(), ), ); // if(projectViewModel.isLoginChild) { // Navigator.pushReplacement( // context, // FadePage( // page: LandingPage(), // ), // ); // } else { // Navigator.pop( // context, // // FadePage( // // page: LandingPage(), // // ), // ); // } } }, color: CustomColors.accentColor, textColor: Colors.white, ), ), SizedBox(width: 10), Expanded( child: DefaultButton( TranslationBase.of(context).next, rating <= 0 ? null : () { Navigator.push( context, FadePage( page: RateAppointmentClinic( appointmentDetails: model.appointmentDetails, doctorNote: note, doctorRate: rating, ), ), ); }, // iconData: Icons.notifications_active, color: Color(0xff359846), disabledColor: Colors.grey, ), ), ], ), ), ), ); } DoctorList getDoctorObject(AppointmentRateViewModel model) { DoctorList doctor = new DoctorList(); doctor.name = model.appointmentDetails.doctorName; doctor.doctorImageURL = model.appointmentDetails.doctorImageURL; doctor.clinicName = model.appointmentDetails.clinicName; doctor.projectName = model.appointmentDetails.projectName; doctor.date = model.appointmentDetails.appointmentDate; doctor.actualDoctorRate = 5; return doctor; } }