lab result detail screen (cont.)

merge-update-with-lab-changes
Sikander Saleem 4 years ago
parent d1b45c8bcc
commit 3a1af590ff

@ -20,34 +20,33 @@ class LaboratoryResultPage extends StatefulWidget {
class _LaboratoryResultPageState extends State<LaboratoryResultPage> { class _LaboratoryResultPageState extends State<LaboratoryResultPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<LabsViewModel>( return BaseView<LabsViewModel>(
onModelReady: (model) => model.getLaboratoryResult( onModelReady: (model) => model.getLaboratoryResult(
invoiceNo: widget.patientLabOrders.invoiceNo, invoiceNo: widget.patientLabOrders.invoiceNo, clinicID: widget.patientLabOrders.clinicID, projectID: widget.patientLabOrders.projectID, orderNo: widget.patientLabOrders.orderNo),
clinicID: widget.patientLabOrders.clinicID,
projectID: widget.patientLabOrders.projectID,
orderNo: widget.patientLabOrders.orderNo),
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
isShowAppBar: true, isShowAppBar: true,
appBarTitle: TranslationBase.of(context).labResults, appBarTitle: widget.patientLabOrders.doctorName,
baseViewModel: model, baseViewModel: model,
body: Scaffold( showNewAppBar: true,
body: ListView.builder( showNewAppBarTitle: true,
itemBuilder: (context, index) => LaboratoryResultWidget( backgroundColor: Color(0xffF8F8F8),
onTap: ()async { body: ListView.builder(
GifLoaderDialogUtils.showMyDialog(context); physics: BouncingScrollPhysics(),
await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders,mes: TranslationBase.of(context).sendSuc); itemBuilder: (context, index) => LaboratoryResultWidget(
GifLoaderDialogUtils.hideDialog(context); onTap: () async {
}, GifLoaderDialogUtils.showMyDialog(context);
billNo: widget.patientLabOrders.invoiceNo, await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc);
details: model.patientLabSpecialResult[index].resultDataHTML, GifLoaderDialogUtils.hideDialog(context);
orderNo: widget.patientLabOrders.orderNo, },
patientLabOrder: widget.patientLabOrders, billNo: widget.patientLabOrders.invoiceNo,
), details: model.patientLabSpecialResult[index].resultDataHTML,
itemCount: model.patientLabSpecialResult.length, orderNo: widget.patientLabOrders.orderNo,
patientLabOrder: widget.patientLabOrders,
), ),
itemCount: model.patientLabSpecialResult.length,
), ),
), ),
); );

@ -3,15 +3,20 @@ import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_send_email_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_send_email_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/extensions/string_extensions.dart';
import 'package:diplomaticquarterapp/widgets/new_design/doctor_header.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/flutter_html.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:rating_bar/rating_bar.dart';
import '../../text.dart'; import '../../text.dart';
import 'LabResultWidget.dart'; import 'LabResultWidget.dart';
@ -23,14 +28,7 @@ class LaboratoryResultWidget extends StatefulWidget {
final String orderNo; final String orderNo;
final PatientLabOrders patientLabOrder; final PatientLabOrders patientLabOrder;
const LaboratoryResultWidget( const LaboratoryResultWidget({Key key, this.onTap, this.billNo, this.details, this.orderNo, this.patientLabOrder}) : super(key: key);
{Key key,
this.onTap,
this.billNo,
this.details,
this.orderNo,
this.patientLabOrder})
: super(key: key);
@override @override
_LaboratoryResultWidgetState createState() => _LaboratoryResultWidgetState(); _LaboratoryResultWidgetState createState() => _LaboratoryResultWidgetState();
@ -45,231 +43,161 @@ class _LaboratoryResultWidgetState extends State<LaboratoryResultWidget> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectViewModel = Provider.of(context); projectViewModel = Provider.of(context);
return BaseView<LabsViewModel>( return BaseView<LabsViewModel>(
onModelReady: (model) => // onModelReady: (model) => model.getPatientLabResult(patientLabOrder: widget.patientLabOrder),
model.getPatientLabResult(patientLabOrder: widget.patientLabOrder),
builder: (_, model, w) => NetworkBaseView( builder: (_, model, w) => NetworkBaseView(
baseViewModel: model, baseViewModel: model,
child: Container( child: Column(
margin: EdgeInsets.all(15), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: <Widget>[
children: <Widget>[ DoctorHeader(
Column( patientLabOrder: widget.patientLabOrder,
crossAxisAlignment: CrossAxisAlignment.start, invoiceNo: widget.billNo,
children: <Widget>[ email: model.user.emailAddress,
onTap: widget.onTap,
Container( ),
margin: EdgeInsets.all(8), SizedBox(height: 10),
child: Row( if (model.labResultLists.isNotEmpty)
mainAxisAlignment: MainAxisAlignment.spaceBetween, Container(
children: <Widget>[ child: Column(
Expanded( children: [
child: Container( InkWell(
decoration: BoxDecoration( onTap: () {
shape: BoxShape.rectangle, setState(
color: Colors.white, () {
borderRadius: BorderRadius.all( _isShowMoreGeneral = !_isShowMoreGeneral;
Radius.circular(5.0),
)),
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.only(left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Texts(TranslationBase.of(context).invoiceNo),
Texts(widget.billNo),
],
),
),
),
InkWell(
onTap: (){
showConfirmMessage(context,widget.onTap,model.user.emailAddress);
}, },
child: Container( );
margin: EdgeInsets.only(left: 5, right: 5), },
decoration: BoxDecoration( child: Container(
shape: BoxShape.rectangle, padding: EdgeInsets.only(left: 17, top: 14, right: 13, bottom: 10),
color: Theme.of(context).primaryColor, margin: EdgeInsets.only(left: 21, right: 21, top: 12),
borderRadius: BorderRadius.all( decoration: BoxDecoration(
Radius.circular(5.0),
)),
child: Container(
padding: EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.email,
color: Colors.white,
),
Texts(
TranslationBase.of(context).sendEmail,
color: Colors.white,
)
],
),
),
),
)
],
),
),
SizedBox(
height: 12,
),
if( model.labResultLists.isNotEmpty)
Container(
child: Column(
children: [
InkWell(
onTap: () {
setState(
() {
_isShowMoreGeneral = !_isShowMoreGeneral;
},
);
},
child: Container(
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.only(left: 5, right: 5),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(5.0),
)),
child: Row(
children: <Widget>[
Expanded(child: Texts(TranslationBase.of(context).generalResult)),
Container(
width: 25,
height: 25,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).primaryColor),
child: Icon(
_isShowMoreGeneral
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
color: Colors.white,
size: 22,
),
)
],
),
),
),
if (_isShowMoreGeneral)
AnimatedContainer(
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.only(left: 5, right: 5),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5.0),
bottomRight: Radius.circular(5.0),
),
),
duration: Duration(milliseconds: 7000),
child: Container(
width: double.infinity,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
...List.generate(
model.labResultLists.length,
(index) => LabResultWidget(
patientLabOrder: widget.patientLabOrder,
filterName: model
.labResultLists[index].filterName,
patientLabResultList: model
.labResultLists[index]
.patientLabResultList,
),
)
],
),
),
),
],
),
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
setState(() {
_isShowMore = !_isShowMore;
});
},
child: Container(
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.only(left: 5, right: 5),
decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(5.0), Radius.circular(10.0),
)), ),
child: Row( boxShadow: [
children: <Widget>[ BoxShadow(
Expanded(child: Texts(TranslationBase.of(context).specialResult)), color: Color(0xff000000).withOpacity(.05),
Container( //spreadRadius: 5,
width: 25, blurRadius: 27,
height: 25, offset: Offset(0, -3),
decoration: BoxDecoration(
shape: BoxShape.circle, color: Theme.of(context).primaryColor),
child: Icon(
_isShowMore
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
color: Colors.white,
size: 22,
), ),
) ],
], ),
child: Row(
children: <Widget>[
Expanded(child: Texts(TranslationBase.of(context).generalResult)),
Container(
width: 25,
height: 25,
decoration: BoxDecoration(shape: BoxShape.circle, color: Theme.of(context).primaryColor),
child: Icon(
_isShowMoreGeneral ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
color: Colors.white,
size: 22,
),
)
],
),
), ),
), ),
), if (_isShowMoreGeneral)
if (_isShowMore) AnimatedContainer(
AnimatedContainer( padding: EdgeInsets.all(10.0),
padding: EdgeInsets.all(10.0), margin: EdgeInsets.only(left: 5, right: 5),
margin: EdgeInsets.only(left: 5, right: 5), decoration: BoxDecoration(
decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5.0), bottomLeft: Radius.circular(5.0),
bottomRight: Radius.circular(5.0), bottomRight: Radius.circular(5.0),
)), ),
duration: Duration(milliseconds: 7000), ),
child: Container( duration: Duration(milliseconds: 7000),
child: Container(
width: double.infinity, width: double.infinity,
child: Html( child: Column(
data: widget.details ?? TranslationBase.of(context).noDataAvailable, crossAxisAlignment: CrossAxisAlignment.start,
)), children: <Widget>[
...List.generate(
model.labResultLists.length,
(index) => LabResultWidget(
patientLabOrder: widget.patientLabOrder,
filterName: model.labResultLists[index].filterName,
patientLabResultList: model.labResultLists[index].patientLabResultList,
),
)
],
),
),
),
],
),
),
InkWell(
onTap: () {
setState(() {
_isShowMore = !_isShowMore;
});
},
child: Container(
padding: EdgeInsets.only(left: 17, top: 14, right: 13, bottom: 10),
margin: EdgeInsets.only(left: 21, right: 21, top: 12),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
boxShadow: [
BoxShadow(
color: Color(0xff000000).withOpacity(.05),
//spreadRadius: 5,
blurRadius: 27,
offset: Offset(0, -3),
), ),
],
], ),
child: Row(
children: <Widget>[
Expanded(child: Texts(TranslationBase.of(context).specialResult)),
Container(
width: 25,
height: 25,
decoration: BoxDecoration(shape: BoxShape.circle, color: Theme.of(context).primaryColor),
child: Icon(
_isShowMore ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
color: Colors.white,
size: 22,
),
)
],
),
),
),
if (_isShowMore)
AnimatedContainer(
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.only(left: 5, right: 5),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5.0),
bottomRight: Radius.circular(5.0),
)),
duration: Duration(milliseconds: 7000),
child: Container(
width: double.infinity,
child: Html(
data: widget.details ?? TranslationBase.of(context).noDataAvailable,
)),
), ),
], ],
),
), ),
), ),
); );
} }
void showConfirmMessage(BuildContext context, GestureTapCallback onTap,String email) {
showDialog(
context: context,
child: ConfirmSendEmailDialog(
email: email,
onTapSendEmail: () {
onTap();
},
),
);
}
} }

@ -154,18 +154,19 @@ class DoctorCard extends StatelessWidget {
), ),
); );
} }
Widget myRichText(String title, String value) {
return RichText(
text: TextSpan(
text: title,
style: TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 18 / 10),
children: <TextSpan>[
TextSpan(
text: " $value",
style: TextStyle(fontSize: 14, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12),
)
]),
);
}
} }
// todo 'sikander' move this widget to separate file
Widget myRichText(String title, String value) {
return RichText(
text: TextSpan(
text: title,
style: TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 18 / 10),
children: <TextSpan>[
TextSpan(
text: " $value",
style: TextStyle(fontSize: 14, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12),
)
]),
);
}

@ -0,0 +1,138 @@
import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_send_email_dialog.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/extensions/string_extensions.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:rating_bar/rating_bar.dart';
class DoctorHeader extends StatelessWidget {
final PatientLabOrders patientLabOrder;
final String invoiceNo;
final String email;
final VoidCallback onTap;
DoctorHeader({Key key, @required this.patientLabOrder, @required this.email, @required this.invoiceNo, @required this.onTap}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.only(left: 21, right: 21, bottom: 21),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LargeAvatar(
name: patientLabOrder.doctorName,
url: patientLabOrder.doctorImageURL,
width: 51,
height: 51,
),
SizedBox(width: 10),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
(patientLabOrder?.speciality?.toString()?.toLowerCase()?.capitalizeFirstofEach ?? ""),
style: TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 18 / 12),
),
myRichText(TranslationBase.of(context).invoiceNo + ":", invoiceNo),
myRichText(TranslationBase.of(context).branch, patientLabOrder.projectName),
],
),
),
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
DateUtil.formatDateToDate(patientLabOrder.orderDate),
style: TextStyle(fontSize: 14, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12),
),
Text(
DateUtil.formatDateToTime(patientLabOrder.orderDate),
style: TextStyle(fontSize: 14, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Image.network(patientLabOrder.nationalityFlagURL, height: 16),
),
],
)
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(width: 21),
RatingBar.readOnly(
initialRating: patientLabOrder.doctorRate + 0.0,
size: 15.0,
filledColor: Color(0XFFD02127),
emptyColor: Color(0XFFD02127),
isHalfAllowed: true,
halfFilledIcon: Icons.star_half,
filledIcon: Icons.star,
emptyIcon: Icons.star_border,
),
SizedBox(width: 6),
Text(
"${patientLabOrder.actualDoctorRate} ${TranslationBase.of(context).reviews}",
style: TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12),
),
],
),
InkWell(
onTap: () {
showConfirmMessage(context, onTap, email);
},
child: Container(
padding: EdgeInsets.only(top: 10, bottom: 10, right: 21, left: 15),
decoration: BoxDecoration(color: Color(0XFFD02127), borderRadius: BorderRadius.only(topLeft: Radius.circular(10))),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
// todo: 'change icon for send email'
SvgPicture.asset('assets/images/new-design/covid-19-car.svg', width: 19.0),
SizedBox(width: 6),
Text(
TranslationBase.of(context).sendEmail,
style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.64, height: 25 / 16),
),
],
),
),
)
],
)
],
),
);
}
void showConfirmMessage(BuildContext context, GestureTapCallback onTap, String email) {
showDialog(
context: context,
child: ConfirmSendEmailDialog(
email: email,
onTapSendEmail: () {
onTap();
},
),
);
}
}
Loading…
Cancel
Save