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.
PatientApp-KKUMC/lib/pages/InPatientServices/inpatient_home.dart

170 lines
5.7 KiB
Dart

import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/InPatientServices/get_general_instructions_response_model.dart';
import 'package:diplomaticquarterapp/pages/InPatientServices/general_instructions.dart';
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class InPatientServicesHome extends StatelessWidget {
ProjectViewModel projectViewModel;
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
List<Widget> inPatientServiceList = getInPatientServicesList(context);
return AppScaffold(
isShowAppBar: true,
isShowDecPage: false,
showNewAppBarTitle: true,
showNewAppBar: true,
appBarTitle: TranslationBase.of(context).InPatientServicesHeader,
body: Container(
margin: EdgeInsets.all(20.0),
child: Column(
children: [
Padding(
padding: EdgeInsets.only(left: 12, right: 12),
child: GridView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12),
padding: EdgeInsets.zero,
itemCount: inPatientServiceList.length,
itemBuilder: (BuildContext context, int index) {
return inPatientServiceList[index];
},
),
),
],
),
),
);
}
List<Widget> getInPatientServicesList(BuildContext context) {
List<Widget> serviceList = List();
serviceList.add(
InkWell(
onTap: () {
// Navigator.push(context, FadePage(page: AdvancePaymentPage()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context).admissionGeneral,
imagePath: 'assets/images/new/consent.jpg',
subTitle: TranslationBase.of(context).consent,
isPngImage: true,
width: 50.0,
height: 40.0,
),
),
);
serviceList.add(
InkWell(
onTap: () {
openGeneralInstructions(context);
},
child: MedicalProfileItem(
title: TranslationBase.of(context).generalInstructionsTitle,
imagePath: 'assets/images/new/instructions.jpg',
subTitle: TranslationBase.of(context).generalInstructionsSubTitle,
isPngImage: true,
width: 50.0,
height: 40.0,
),
),
);
serviceList.add(
InkWell(
onTap: () {
// Navigator.push(context, FadePage(page: AdvancePaymentPage()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context).medicalInstructionsTitle,
imagePath: 'assets/images/new/medical_instructions.png',
subTitle: TranslationBase.of(context).medicalInstructionsSubTitle,
isPngImage: true,
width: 50.0,
height: 40.0,
),
),
);
serviceList.add(
InkWell(
onTap: () {
// Navigator.push(context, FadePage(page: AdvancePaymentPage()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context).mealPlanTitle,
imagePath: 'assets/images/new/meal_plan.png',
subTitle: TranslationBase.of(context).mealPlanSubTitle,
isPngImage: true,
width: 50.0,
height: 40.0,
),
),
);
serviceList.add(
InkWell(
onTap: () {
// Navigator.push(context, FadePage(page: AdvancePaymentPage()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context).birthNotificationTitle,
imagePath: 'assets/images/new/birth.png',
subTitle: TranslationBase.of(context).birthNotificationSubTitle,
isPngImage: true,
width: 50.0,
height: 40.0,
),
),
);
serviceList.add(
InkWell(
onTap: () {
// Navigator.push(context, FadePage(page: AdvancePaymentPage()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context).admissionNoticeTitle,
imagePath: 'assets/images/new/admission_notice.png',
subTitle: TranslationBase.of(context).admissionNoticeSubTitle,
isPngImage: true,
width: 50.0,
height: 40.0,
),
),
);
return serviceList;
}
void openGeneralInstructions(BuildContext context) {
ClinicListService service = new ClinicListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getGeneralInstructions(projectViewModel.inPatientProjectID, context).then((res) {
List<GetGeneralInstructions> getGeneralInstructionsList = [];
res['generalInstructions'].forEach((v) {
getGeneralInstructionsList.add(new GetGeneralInstructions.fromJson(v));
});
GifLoaderDialogUtils.hideDialog(context);
print(res['generalInstructions']);
Navigator.push(context, FadePage(page: GeneralInstructions(getGeneralInstructionsList: getGeneralInstructionsList)));
}).catchError((err) {
print(err);
});
}
}