import 'package:doctor_app_flutter/models/my_referral_patient_model.dart'; import 'package:doctor_app_flutter/models/my_referred_patient_model.dart'; import 'package:flutter/material.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/providers/referred_patient_provider.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:provider/provider.dart'; class MyReferredPatientWidget extends StatefulWidget { final MyReferredPatientModel myReferredPatientModel; MyReferredPatientWidget({Key key, this.myReferredPatientModel}); @override _MyReferredPatientWidgetState createState() => _MyReferredPatientWidgetState(); } class _MyReferredPatientWidgetState extends State { bool _showDetails = false; bool _isLoading = false; final _formKey = GlobalKey(); String error; TextEditingController answerController; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return CardWithBgWidgetNew( widget: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ AppText( '${widget.myReferredPatientModel.firstName} ${widget.myReferredPatientModel.lastName}', fontSize: 2.5 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), InkWell( onTap: () { setState(() { _showDetails = !_showDetails; }); }, child: Icon(_showDetails ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down)), ], ), !_showDetails ? Container() : AnimatedContainer( duration: Duration(milliseconds: 200), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Divider(color: Colors.grey), // VerticalDivider(color: Colors.black, // thickness: 2, width: 20, // indent: 200, // endIndent: 200,), Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( 'File No', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), AppText( '${widget.myReferredPatientModel.patientId}', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.w300, ) ], ), ), Container( height: SizeConfig.realScreenWidth * .1,//0.1, width: 0.8, color: Colors.grey, margin: EdgeInsets.only(left: 15, right: 15), ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( 'Referral Doctor', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), Texts( widget.myReferredPatientModel .referralDoctorName, maxLength: 80, readMore: true, ), ], ), ), ], ), Divider(color: Colors.grey), Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( 'Referring Clinic', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), AppText( '${widget.myReferredPatientModel.referralClinicDescription}', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.w300, ) ], ), ), Container( height: SizeConfig.realScreenWidth * 0.1, width: 0.8, color: Colors.grey, margin: EdgeInsets.only(left: 15, right: 15), ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( 'Frequency', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), AppText( widget.myReferredPatientModel .frequencyDescription, fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.w300, ) ], ), ), ], ), Divider(color: Colors.grey), Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( 'Priority', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), AppText( '${widget.myReferredPatientModel.priorityDescription}', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.w300, ) ], ), ), Container( height: SizeConfig.realScreenWidth * 0.1, width: 0.8, color: Colors.grey, margin: EdgeInsets.only(left: 15, right: 15), ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( 'Max Response Time', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), AppText( Helpers.getDateFormatted(widget .myReferredPatientModel .maxResponseTime), fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.w300, ) ], ), ), ], ), Divider(color: Colors.grey), AppText( 'Clinic Details and Remarks', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, textAlign: TextAlign.start, ), SizedBox( height: 5, ), Texts( '${widget.myReferredPatientModel.referringDoctorRemarks}', style: "bodyText1", readMore: true, textAlign: TextAlign.start, maxLength: 100), SizedBox( height: 5, ), AppText( 'Answer/Suggestions', fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, textAlign: TextAlign.start, ), SizedBox( height: 5, ), Texts( '${widget.myReferredPatientModel.referredDoctorRemarks}', style: "bodyText1", readMore: true, textAlign: TextAlign.start, maxLength: 100), SizedBox( height: 5, ), SizedBox(height: 10.0), if (error != null && error.isNotEmpty) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(6.0), color: Theme.of(context) .errorColor .withOpacity(0.06), ), padding: EdgeInsets.symmetric( vertical: 8.0, horizontal: 12.0), child: Row( children: [ Expanded( child: Texts(error ?? "", style: "bodyText1", color: Theme.of(context) .errorColor)), ], ), ), SizedBox(height: 10.0), ], ), SizedBox(height: 10.0), Container( width: double.infinity, child: Button( onTap: () async { final form = _formKey.currentState; try { await Provider.of(context, listen: false).replay(widget.myReferredPatientModel); setState(() { _isLoading = false; }); } catch (e) { setState(() { error = e.toString(); _isLoading = false; }); } }, title: 'Verify', loading: _isLoading, ), ) ], ) ], ), ) ], ), ), ); } }