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_update_screen.dart

486 lines
26 KiB
Dart

4 years ago
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
4 years ago
import 'package:diplomaticquarterapp/core/service/insurance_service.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/pages/insurance/insurance_details.dart';
4 years ago
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
4 years ago
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
4 years ago
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
4 years ago
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import '../base/base_view.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/core/viewModels/insurance_card_View_model.dart';
4 years ago
import 'insurance_card_update_details.dart';
class InsuranceUpdate extends StatefulWidget {
@override
_InsuranceUpdateState createState() => _InsuranceUpdateState();
}
class _InsuranceUpdateState extends State<InsuranceUpdate>
with SingleTickerProviderStateMixin {
TabController _tabController;
4 years ago
InsuranceCardService _insuranceCardService = locator<InsuranceCardService>();
4 years ago
List<ImagesInfo> imagesInfo = List();
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
4 years ago
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'));
}
void dispose() {
super.dispose();
_tabController.dispose();
}
Widget build(BuildContext context) {
return BaseView<InsuranceViewModel>(
onModelReady: (model) => model.getInsuranceUpdated(),
builder: (BuildContext context, InsuranceViewModel model, Widget child) =>
AppScaffold(
appBarTitle: TranslationBase.of(context).insurCards,
4 years ago
description: TranslationBase.of(context).infoInsurCards,
infoList: TranslationBase.of(context).infoPrescriptionsPoints,
imagesInfo: imagesInfo,
isShowAppBar: true,
4 years ago
isShowDecPage: true,
baseViewModel: model,
body: Scaffold(
extendBodyBehindAppBar: true,
appBar: PreferredSize(
preferredSize: Size.fromHeight(70.0),
child: Stack(
children: <Widget>[
Center(
child: Container(
height: 60.0,
margin: EdgeInsets.only(top: 10.0),
width: MediaQuery.of(context).size.width * 1.9,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Theme.of(context).dividerColor,
width: 5.7,
),
),
color: Colors.white,
),
child: Center(
child: TabBar(
controller: _tabController,
isScrollable: true,
indicatorWeight: 4.0,
indicatorColor: Theme.of(context).primaryColor,
labelColor: Theme.of(context).primaryColor,
labelPadding: EdgeInsets.symmetric(
horizontal: 13.0, vertical: 2.0),
unselectedLabelColor: Colors.grey,
tabs: <Widget>[
Container(
width: MediaQuery.of(context).size.width * 0.35,
child: Center(
child: Texts(TranslationBase.of(context)
.updateInsuranceSubtitle),
),
),
Container(
width: MediaQuery.of(context).size.width * 0.35,
child: Center(
child: Texts(TranslationBase.of(context).history),
),
),
],
),
),
),
)
],
),
),
body: Column(
children: <Widget>[
Expanded(
child: TabBarView(
physics: BouncingScrollPhysics(),
controller: _tabController,
children: <Widget>[
Container(
4 years ago
child: model.getAllSharedRecordsByStatusResponse
4 years ago
.getAllSharedRecordsByStatusList !=
null ??
4 years ago
false
? ListView.builder(
itemCount: model.getAllSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList.length,
itemBuilder: (BuildContext context, int index) {
4 years ago
return model
.getAllSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList[
index]
.status ==
3
4 years ago
? 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,
4 years ago
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(
model
.getAllSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList[
index]
.patientName,
fontSize: 14,
color: Colors.black,
fontWeight:
FontWeight.w500,
),
SizedBox(
height: 8,
),
Texts(
TranslationBase.of(
context)
.fileno +
": " +
model
.getAllSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList[
index]
.patientID
.toString(),
fontSize: 14,
color: Colors.black,
fontWeight:
FontWeight.w500,
)
],
),
),
4 years ago
),
Expanded(
flex: 2,
child: Container(
margin:
EdgeInsets.only(top: 2.0),
child: Column(
children: <Widget>[
Container(
child: SecondaryButton(
label: TranslationBase
.of(context)
.fetchData,
small: true,
textColor:
Colors.white,
onTap: () {
getDetails(
4 years ago
projectID: 15,
4 years ago
patientIdentificationID: model
.getAllSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList[
index]
.patientIdenficationNumber,
setupID:
'010266',
patientID: model
.getAllSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList[
index]
.responseID,
name: model
.getAllSharedRecordsByStatusResponse
.getAllSharedRecordsByStatusList[
index]
.patientName);
4 years ago
},
),
),
],
),
),
4 years ago
)
],
),
),
4 years ago
),
)
: Container();
})
4 years ago
: Container(
4 years ago
height: 80,
margin: EdgeInsets.all(10.0),
child: Column(
children: [
SizedBox(
height: 65,
),
Container(
color: Colors.white,
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(10.0),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
4 years ago
if (model.user != null)
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(
model.user.firstName ??
'' +
" " +
model.user.lastName ??
'',
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
),
SizedBox(
height: 8,
),
Texts(
TranslationBase.of(context)
.fileno +
": " +
model.user.patientID
.toString(),
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w500,
)
],
),
4 years ago
),
4 years ago
),
4 years ago
Expanded(
flex: 2,
child: Container(
margin: EdgeInsets.only(top: 2.0),
child: Column(
children: <Widget>[
Container(
child: SecondaryButton(
label: TranslationBase.of(
context)
.fetchData,
small: true,
textColor: Colors.white,
onTap: () {
getDetails(
setupID: '010266',
projectID: 15,
4 years ago
patientIdentificationID:
model.user
.patientIdentificationNo,
patientID: model
.user.patientID,
name: model.user
.firstName +
" " +
model
.user.lastName);
4 years ago
},
),
),
],
),
4 years ago
),
4 years ago
)
],
4 years ago
),
),
],
),
),
),
Container(
child: ListView.builder(
itemCount: model.insuranceUpdate == null
? 0
: model.insuranceUpdate.length,
itemBuilder: (BuildContext context, int index) {
return 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: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Flex(
direction: Axis.horizontal,
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(
model.user.firstName +
" " +
model.user.lastName,
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.black,
),
SizedBox(
height: 8,
),
Texts(
TranslationBase.of(context)
.fileno +
": " +
model
.insuranceUpdate[
index]
.patientID
.toString(),
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.black,
),
SizedBox(
height: 8,
),
Texts(
model.insuranceUpdate[index]
.createdOn,
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.black,
),
],
),
),
),
Expanded(
flex: 1,
child: Container(
margin: EdgeInsets.only(top: 20.0),
child: Column(
children: <Widget>[
Image.asset(
"assets/images/new-design/confirm_button.png",
width: 30.0,
height: 30.0),
Container(
margin: EdgeInsets.only(
top: 13.5, left: 2.0),
child: Texts(
model.insuranceUpdate[index]
.statusDescription,
textAlign: TextAlign.center,
fontSize: 12,
color: Colors.black,
),
),
],
),
),
)
],
),
],
),
),
),
);
}),
),
],
))
],
),
),
),
);
}
4 years ago
4 years ago
getDetails(
{String setupID,
int projectID,
String patientIdentificationID,
int patientID,
String name}) {
4 years ago
GifLoaderDialogUtils.showMyDialog(context);
4 years ago
_insuranceCardService
.getPatientInsuranceDetails(
setupID: setupID,
projectID: projectID,
patientID: patientID,
patientIdentificationID: patientIdentificationID)
.then((value) {
GifLoaderDialogUtils.hideDialog(context);
if (!_insuranceCardService.hasError && _insuranceCardService.isHaveInsuranceCard) {
4 years ago
Navigator.push(
context,
FadePage(
page: InsuranceCardUpdateDetails(
insuranceCardDetailsModel: _insuranceCardService.insuranceCardDetailsList,
4 years ago
patientID: patientID,
patientIdentificationID: patientIdentificationID,
name: name,
)));
4 years ago
} else {
AppToast.showErrorToast(message: _insuranceCardService.error);
}
});
4 years ago
}
}