|
|
|
import 'package:diplomaticquarterapp/config/size_config.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/service/insurance_service.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/insurance_card_View_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/locator.dart';
|
|
|
|
import 'package:diplomaticquarterapp/pages/insurance/insurance_details.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/button.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:diplomaticquarterapp/widgets/others/rounded_container.dart';
|
|
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../base/base_view.dart';
|
|
|
|
|
|
|
|
class InsuranceCard extends StatefulWidget {
|
|
|
|
int appointmentNo;
|
|
|
|
|
|
|
|
|
|
|
|
InsuranceCard({this.appointmentNo});
|
|
|
|
|
|
|
|
@override
|
|
|
|
_InsuranceCardState createState() => _InsuranceCardState();
|
|
|
|
}
|
|
|
|
class _InsuranceCardState extends State<InsuranceCard> {
|
|
|
|
InsuranceCardService _insuranceCardService = locator<InsuranceCardService>();
|
|
|
|
List<ImagesInfo> imagesInfo = List();
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
imagesInfo.add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/insurance-card/en/0.png',imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/insurance-card/ar/0.png'));
|
|
|
|
|
|
|
|
return BaseView<InsuranceViewModel>(
|
|
|
|
onModelReady: (model) => model.getInsurance(),
|
|
|
|
builder: (BuildContext context, InsuranceViewModel model, Widget child) =>
|
|
|
|
AppScaffold(
|
|
|
|
isShowAppBar: true,
|
|
|
|
baseViewModel: model,
|
|
|
|
image: 'assets/images/medical/insurance_card_icon.png',
|
|
|
|
appBarTitle: TranslationBase.of(context).insuranceCards,
|
|
|
|
description: TranslationBase.of(context).infoInsuranceCards,
|
|
|
|
infoList: TranslationBase.of(context).infoInsuranceCardsPoints,
|
|
|
|
imagesInfo: imagesInfo,
|
|
|
|
body: Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
left: SizeConfig.screenWidth * 0.004,
|
|
|
|
right: SizeConfig.screenWidth * 0.004,
|
|
|
|
top: SizeConfig.screenWidth * 0.04),
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: model.insurance == null ? 0 : model.insurance.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return RoundedContainer(
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
ExpansionTile(
|
|
|
|
title: Container(
|
|
|
|
height: 65.0,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 15.0),
|
|
|
|
child: Texts(
|
|
|
|
model.insurance[index].groupName,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(14),
|
|
|
|
width: double.infinity,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.rectangle,
|
|
|
|
border: Border.all(color: Colors.grey,width: 0.2),
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(2)),
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.white70,
|
|
|
|
),
|
|
|
|
|
|
|
|
]
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Texts(
|
|
|
|
TranslationBase.of(context).companyName +
|
|
|
|
model.insurance[index].companyName,
|
|
|
|
fontSize: 20.0,
|
|
|
|
),
|
|
|
|
Divider(
|
|
|
|
color: Colors.black,
|
|
|
|
height: 25.0,
|
|
|
|
thickness: 0.5,
|
|
|
|
),
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
TranslationBase.of(context).category +
|
|
|
|
model.insurance[index].subCategoryDesc,
|
|
|
|
style: TextStyle(fontSize: 18.5),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
TranslationBase.of(context).expirationDate +
|
|
|
|
convertDateFormat(
|
|
|
|
model.insurance[index].cardValidTo),
|
|
|
|
style: TextStyle(fontSize: 18.5),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
TranslationBase.of(context).patientCard +
|
|
|
|
model.insurance[index].patientCardID,
|
|
|
|
style: TextStyle(fontSize: 18.5),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
TranslationBase.of(context).policyNumber +
|
|
|
|
model
|
|
|
|
.insurance[index].insurancePolicyNumber,
|
|
|
|
style: TextStyle(fontSize: 18.5),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Column(
|
|
|
|
children: <Widget>[
|
|
|
|
model.insurance[index].isActive == true
|
|
|
|
? Text('Active',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.green,
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
fontSize: 17.9))
|
|
|
|
: Text('Not Active',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.red,
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
fontSize: 17.9))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 14.5,
|
|
|
|
),
|
|
|
|
if (model.insurance[index].isActive == true)
|
|
|
|
Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: SecondaryButton(
|
|
|
|
onTap:()=>{ getDetails(model.insurance[index])},
|
|
|
|
label: TranslationBase.of(context).seeDetails,
|
|
|
|
textColor: Colors.white,
|
|
|
|
),
|
|
|
|
width: double.infinity,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
convertDateFormat(String exDate) {
|
|
|
|
const start = "/Date(";
|
|
|
|
const end = "+0300)";
|
|
|
|
|
|
|
|
final startIndex = exDate.indexOf(start);
|
|
|
|
final endIndex = exDate.indexOf(end, startIndex + start.length);
|
|
|
|
|
|
|
|
var date = new DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
int.parse(exDate.substring(startIndex + start.length, endIndex)));
|
|
|
|
String newDate = date.year.toString() +
|
|
|
|
"-" +
|
|
|
|
date.month.toString().padLeft(2, '0') +
|
|
|
|
"-" +
|
|
|
|
date.day.toString().padLeft(2, '0');
|
|
|
|
|
|
|
|
return newDate.toString();
|
|
|
|
}
|
|
|
|
getDetails(data){
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
_insuranceCardService.getInsuranceDetails(data).then((value) => {
|
|
|
|
GifLoaderDialogUtils.hideDialog(context),
|
|
|
|
Navigator.push(context,
|
|
|
|
FadePage(page: InsuranceCardDetails(data:value[0]['CheckList'])))
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|