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/insurance/insurance_card_update_detai...

348 lines
15 KiB
Dart

import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/insurance/Insurance_card_details.dart';
import 'package:diplomaticquarterapp/core/viewModels/insurance_card_View_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'AttachInsuranceCardImageDialog.dart';
class InsuranceCardUpdateDetails extends StatelessWidget {
final List<InsuranceCardDetailsModel> insuranceCardDetailsModel;
final String patientIdentificationID;
final int patientID;
final String name;
const InsuranceCardUpdateDetails(
{Key key,
this.insuranceCardDetailsModel,
this.patientIdentificationID,
this.patientID,
this.name})
: super(key: key);
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<InsuranceViewModel>(
builder: (context, model, w) => AppScaffold(
isShowAppBar: true,
isShowDecPage: false,
appBarTitle: TranslationBase.of(context).cardDetail,
body: SingleChildScrollView(
child: Column(
children: [
...List.generate(
insuranceCardDetailsModel.length,
(index) => Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: double.maxFinite,
margin: EdgeInsets.only(left: 8, right: 8, top: 8),
height: projectViewModel.isArabic ? 320 : 240,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: Color(0xff515B5D),
),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
insuranceCardDetailsModel[index].memberID,
textScaleFactor: 2.1,
style: TextStyle(
color: Colors.white,
letterSpacing: 8.0,
fontWeight: FontWeight.w400,
fontSize: 15),
),
SizedBox(
height: 5,
),
Texts(
insuranceCardDetailsModel[index].companyName,
fontSize: 14,
color: Colors.white,
),
SizedBox(
height: 25,
),
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Texts(
TranslationBase.of(context).policyHolder,
color: Colors.white,
fontSize: 14,
),
Texts(
insuranceCardDetailsModel[index]
.memberName,
color: Colors.white,
fontSize: 14,
),
],
),
),
Expanded(
child: Column(
children: [
Texts(TranslationBase.of(context).policyNo,
color: Colors.white),
Texts(
insuranceCardDetailsModel[index]
.policyNumber,
color: Colors.white),
],
),
),
],
),
SizedBox(
height: 25,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Texts(
TranslationBase.of(context)
.expiryDateTitle,
color: Colors.white,
fontSize: 12,
),
Texts(
insuranceCardDetailsModel[index].dOB,
color: Colors.white,
fontSize: 12,
),
],
),
),
Expanded(
child: Column(
children: [
Texts(
TranslationBase.of(context).classTitle,
color: Colors.white,
fontSize: 12,
),
Texts(
insuranceCardDetailsModel[index]
.subCategory,
color: Colors.white,
fontSize: 12,
),
],
),
),
Expanded(
child: Column(
children: [
Texts(
TranslationBase.of(context).approval,
color: Colors.white,
fontSize: 12,
),
Texts(
insuranceCardDetailsModel[index]
.approvalLimit
.toString(),
color: Colors.white,
fontSize: 12,
),
],
),
),
],
)
],
),
),
),
),
),
if(insuranceCardDetailsModel.isEmpty)
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.all(10.0),
child: Card(
margin: EdgeInsets.fromLTRB(
8.0, 16.0, 8.0, 8.0),
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10),
),
child: Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(10.0),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
flex: 3,
child: Container(
margin: EdgeInsets.only(
top: 2.0,
left: 10.0,
right: 20.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
children: <Widget>[
Texts(
name,
fontSize: 14,
color: Colors.black,
fontWeight:
FontWeight.w500,
),
SizedBox(
height: 8,
),
Texts(
TranslationBase.of(
context)
.fileno +
": " +patientID.toString(),
fontSize: 14,
color: Colors.black,
fontWeight:
FontWeight.w500,
)
],
),
),
),
],
),
),
),
),
SizedBox(height: 150,),
Image.asset('assets/images/no-data-found.png',width: 80,height: 80,),
SizedBox(height: 8,),
Texts(TranslationBase.of(context).noDataAvailable)
],
)
],
),
),
bottomSheet: Container(
width: double.infinity,
height:insuranceCardDetailsModel.isEmpty? MediaQuery.of(context).size.height * 0.14:MediaQuery.of(context).size.height * 0.21,
child: Container(
margin: EdgeInsets.only(left: 8, right: 8),
child: Column(
children: [
SizedBox(
height: 8,
),
if(insuranceCardDetailsModel.isEmpty)
SecondaryButton(
textColor: Colors.white,
label: TranslationBase.of(context).scanNow.toUpperCase(),
color: Theme.of(context).primaryColor,
small: true,
onTap: () async {
confirmAttachInsuranceCardImageDialogDialog(
context: context,
name: name,
fileNo: patientID.toString(),
model: model);
},
),
if(insuranceCardDetailsModel.isNotEmpty)
SecondaryButton(
textColor: Colors.white,
label: TranslationBase.of(context).agree.toUpperCase(),
color: Theme.of(context).primaryColor,
onTap: () async {
GifLoaderDialogUtils.showMyDialog(context);
await model.uploadInsuranceCard(
patientIdentificationID: patientIdentificationID,
patientID: patientID);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
AppToast.showErrorToast(message: model.error);
} else {
AppToast.showSuccessToast(
message: TranslationBase.of(context).requestSent);
}
},
),if(insuranceCardDetailsModel.isNotEmpty)
SizedBox(
height: 12,
),if(insuranceCardDetailsModel.isNotEmpty)
SecondaryButton(
textColor: Colors.white,
label: TranslationBase.of(context).disagree.toUpperCase(),
color: Colors.grey[800],
onTap: () async {
confirmAttachInsuranceCardImageDialogDialog(
context: context,
name: name,
fileNo: patientID.toString(),
model: model);
},
)
],
),
),
),
),
);
}
void confirmAttachInsuranceCardImageDialogDialog(
{BuildContext context,
String name,
String fileNo,
InsuranceViewModel model}) {
showDialog(
context: context,
child: AttachInsuranceCardImageDialog(
fileNo: fileNo,
name: name,
image: (file, image) async {
GifLoaderDialogUtils.showMyDialog(context);
await model.uploadInsuranceCard(
patientIdentificationID: patientIdentificationID,
patientID: patientID,
image: image);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal ||
model.state == ViewState.Error) {
AppToast.showErrorToast(message: model.error);
} else {
AppToast.showSuccessToast(
message: TranslationBase.of(context).requestSent);
}
Navigator.pop(context);
},
),
);
}
}