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.
HMG_Patient_App/lib/pages/landing/fragments/home_page_fragment2.dart

686 lines
32 KiB
Dart

import 'package:hmg_patient_app/config/config.dart';
import 'package:hmg_patient_app/config/size_config.dart';
import 'package:hmg_patient_app/core/viewModels/dashboard_view_model.dart';
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:hmg_patient_app/models/Appointments/toDoCountProviderModel.dart';
import 'package:hmg_patient_app/models/Authentication/authenticated_user.dart';
import 'package:hmg_patient_app/models/apple_pay_response.dart';
import 'package:hmg_patient_app/models/gradient_color.dart';
import 'package:hmg_patient_app/models/hmg_services.dart';
import 'package:hmg_patient_app/models/slider_data.dart';
import 'package:hmg_patient_app/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart';
import 'package:hmg_patient_app/pages/ErService/ErOptions.dart';
import 'package:hmg_patient_app/pages/landing/fragments/offer_banner.dart';
import 'package:hmg_patient_app/pages/landing/fragments/offer_details_page.dart';
import 'package:hmg_patient_app/pages/landing/widgets/logged_slider_view.dart';
import 'package:hmg_patient_app/pages/landing/widgets/services_view.dart';
import 'package:hmg_patient_app/pages/landing/widgets/slider_view.dart';
import 'package:hmg_patient_app/pages/packages_offers/packages_offers_tab_pager.dart';
import 'package:hmg_patient_app/theme/colors.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/uitl/utils.dart';
import 'package:hmg_patient_app/uitl/utils_new.dart';
import 'package:hmg_patient_app/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
class HomePageFragment2 extends StatefulWidget {
DashboardViewModel model;
VoidCallback? onPharmacyClick, onLoginClick, onMedicalFileClick;
HomePageFragment2(this.model, {this.onLoginClick, this.onPharmacyClick, this.onMedicalFileClick});
@override
_HomePageFragment2State createState() => _HomePageFragment2State();
}
class _HomePageFragment2State extends State<HomePageFragment2> {
late ProjectViewModel projectViewModel;
List<HmgServices> hmgServices = [];
List<AppoitmentAllHistoryResultList> appoList = [];
late ApplePayResponse applePayResponse;
// bool isPatientAdmitted = true;
@override
void initState() {
// TODO: implement initState
super.initState();
// getPatientAppointmentHistory1();
// getFamilyFiles();
}
initialiseHmgServices(bool isLogin) {
hmgServices.clear();
hmgServices.add(HmgServices(0, TranslationBase.of(context).book, TranslationBase.of(context).appointmentLabel, "assets/images/new/book appointment.svg", isLogin));
hmgServices.add(HmgServices(1, TranslationBase.of(context).liveCare, TranslationBase.of(context).onlineConsulting, "assets/images/new/Live_Care.svg", isLogin));
projectViewModel.isIndoorNavigationEnabled
? hmgServices.add(HmgServices(2, TranslationBase.of(context).hospitalNavigationTitle, TranslationBase.of(context).hospitalNavigationSubtitle, "assets/images/new/indoor_nav_home.svg", isLogin,
isLocked: !projectViewModel.havePrivilege(107)))
: hmgServices.add(HmgServices(2, TranslationBase.of(context).emergencyTitle, TranslationBase.of(context).emergencySubtitle, "assets/images/new/emergency.svg", isLogin));
hmgServices.add(
HmgServices(9, TranslationBase.of(context).emergency, TranslationBase.of(context).checkinOptions, "assets/images/new/emergency.svg", isLogin, isLocked: !projectViewModel.havePrivilege(108)));
hmgServices.add(HmgServices(3, TranslationBase.of(context).hhcHome, TranslationBase.of(context).healthCare, "assets/images/new/HHC.svg", isLogin));
hmgServices.add(HmgServices(4, TranslationBase.of(context).checkup, TranslationBase.of(context).comprehensive, "assets/images/new/comprehensive_checkup.svg", isLogin));
hmgServices.add(HmgServices(5, TranslationBase.of(context).online, TranslationBase.of(context).payment, "assets/images/new/paymentMethods.png", isLogin));
hmgServices.add(HmgServices(6, TranslationBase.of(context).ereferralTitle, TranslationBase.of(context).ereferralSubtitle, "assets/images/new/E_Referral.svg", isLogin));
hmgServices.add(HmgServices(7, TranslationBase.of(context).covidTest, TranslationBase.of(context).driveThru, "assets/images/new/CoronaIcon.svg", isLogin));
hmgServices.add(HmgServices(8, TranslationBase.of(context).connectTitle, TranslationBase.of(context).connectSubtitle, "assets/images/new/reach_us.svg", isLogin));
}
initialiseInPatientHmgServices(bool isLogin) {
hmgServices.clear();
// hmgServices.add(new HmgServices(0, TranslationBase.of(context).liveCare, TranslationBase.of(context).onlineConsulting, "assets/images/new/Live_Care.svg", isLogin));
// hmgServices.add(new HmgServices(1, TranslationBase.of(context).covidTest, TranslationBase.of(context).driveThru, "assets/images/new/CoronaIcon.svg", isLogin));
// hmgServices.add(new HmgServices(2, TranslationBase.of(context).online, TranslationBase.of(context).payment, "assets/images/new/paymentMethods.png", isLogin));
projectViewModel.isIndoorNavigationEnabled
? hmgServices.add(HmgServices(2, TranslationBase.of(context).hospitalNavigationTitle, TranslationBase.of(context).hospitalNavigationSubtitle, "assets/images/new/indoor_nav_home.svg", isLogin,
isLocked: !projectViewModel.havePrivilege(107)))
: hmgServices.add(HmgServices(2, TranslationBase.of(context).emergencyTitle, TranslationBase.of(context).emergencySubtitle, "assets/images/new/emergency.svg", isLogin));
hmgServices.add(new HmgServices(9, TranslationBase.of(context).emergency, TranslationBase.of(context).checkinOptions, "assets/images/new/emergency.svg", isLogin,
isLocked: !projectViewModel.havePrivilege(108)));
hmgServices.add(new HmgServices(3, TranslationBase.of(context).hhcHome, TranslationBase.of(context).healthCare, "assets/images/new/HHC.svg", isLogin));
hmgServices.add(new HmgServices(4, TranslationBase.of(context).checkup, TranslationBase.of(context).comprehensive, "assets/images/new/comprehensive_checkup.svg", isLogin));
// hmgServices.add(new HmgServices(2, TranslationBase.of(context).emergencyTitle, TranslationBase.of(context).emergencySubtitle, "assets/images/new/emergency.svg", isLogin));
hmgServices.add(new HmgServices(6, TranslationBase.of(context).ereferralTitle, TranslationBase.of(context).ereferralSubtitle, "assets/images/new/E_Referral.svg", isLogin));
hmgServices.add(new HmgServices(7, "H\u2082O", TranslationBase.of(context).dailyWater, "assets/images/new/h2o.svg", isLogin));
hmgServices.add(new HmgServices(8, TranslationBase.of(context).connectTitle, TranslationBase.of(context).connectSubtitle, "assets/images/new/reach_us.svg", isLogin));
}
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
if (projectViewModel.isPatientAdmitted || projectViewModel.patientHasAdmissionRequest) {
initialiseInPatientHmgServices(false);
} else {
initialiseHmgServices(false);
}
var appoCountProvider = Provider.of<ToDoCountProviderModel>(context);
// var userProvider = Provider.of<ToDoCountProviderModel>(context);
List<Widget> myMedicalList = Utils.myMedicalListHomePage(projectViewModel: projectViewModel, context: context, count: appoCountProvider.count, isLogin: projectViewModel.isLogin);
return Container(
width: double.infinity,
child: Column(
children: [
projectViewModel.isLogin
? AspectRatio(
aspectRatio: 2.6,
child: Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 8, bottom: 6),
child: InkWell(
onTap: () {
widget.onMedicalFileClick!();
},
child: LoggedSliderView(
projectViewModel,
new SliderData(
TranslationBase.of(context).fileno + ": " + (projectViewModel.user.patientID.toString() ?? ""),
projectViewModel.user.firstName! + ' ' + (projectViewModel.user.lastName ?? ""),
"",
bannerColor[0].darkColor,
bannerColor[0].lightColor,
),
widget.model,
),
),
),
)
: AspectRatio(
aspectRatio: 2.6,
child: Container(
margin: EdgeInsets.only(left: 20, right: 20, top: 8, bottom: 6),
child: SliderView(
onLoginClick: () {
widget.onLoginClick!();
projectViewModel.analytics.loginRegistration.login_register_initiate();
},
),
// height: MediaQuery.of(context).size.width / 2.6,
),
),
(projectViewModel.havePrivilege(111) && projectViewModel.hisProjectOffers.isNotEmpty)
? Padding(
padding: const EdgeInsets.only(left: 20, right: 20),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => OfferDetailsPage(
title: projectViewModel.isArabic
? projectViewModel.hisProjectOffers.first.titleArabic!.split("\$")[0].trim()
: projectViewModel.hisProjectOffers.first.titleName!.split("\$")[0].trim(),
onLoginClick: widget.onLoginClick!,
),
),
);
},
child: SvgPicture.network(
// "https://marathoon.com/service/hmgvideo/Banner_English.svg",
// "https://marathoon.com/service/hmgvideo/Banner_Arabic.svg",
BASE_URL.contains("uat.") ? "https://marathoon.com/service/hmgvideo/Banner_English.svg" : projectViewModel.isArabic ? projectViewModel.hisProjectOffers.first.titleArabic!.split("\$")[1].trim() : projectViewModel.hisProjectOffers.first.titleName!.split("\$")[1].trim(),
// height: 300,
width: MediaQuery.of(context).size.width,
fit: BoxFit.contain,
// color: color,
),
// DiscountCardWidget(),
),
)
: SizedBox.shrink(),
projectViewModel.isLogin
? Column(
children: [
Padding(
padding: projectViewModel.isArabic
? EdgeInsets.only(
right: 20,
left: 8,
)
: EdgeInsets.only(
left: 20,
right: 8,
),
child: Row(
children: [
Expanded(
child: Text(
TranslationBase.of(context).myMedicalFile,
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.bold,
letterSpacing: -0.96,
height: 19 / 16,
),
),
),
TextButton(
onPressed: () {
widget.onMedicalFileClick!();
// navigateTo(context, MedicalProfilePageNew());
},
child: Text(
TranslationBase.of(context).viewMedicalFile,
style: TextStyle(
color: CustomColors.accentColor,
fontSize: 12,
letterSpacing: -0.72,
height: 23 / 12,
),
),
),
],
),
),
mHeight(4),
Container(
width: double.infinity,
height: MediaQuery.of(context).size.width * 0.26,
child: ListView.separated(
itemCount: myMedicalList.length,
padding: EdgeInsets.zero,
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
itemBuilder: (context, index) {
return projectViewModel.isArabic
? Container(
child: myMedicalList[index],
width: MediaQuery.of(context).size.width * 0.26,
height: MediaQuery.of(context).size.width * 0.26,
margin: EdgeInsets.only(left: index == 4 ? 20 : 0, right: index == 0 ? 20 : 0),
)
: Container(
child: myMedicalList[index],
width: MediaQuery.of(context).size.width * 0.26,
height: MediaQuery.of(context).size.width * 0.26,
margin: EdgeInsets.only(left: index == 0 ? 20 : 0, right: index == 4 ? 20 : 0),
);
},
separatorBuilder: (BuildContext context, int index) {
return mWidth(12);
},
),
),
],
)
: Container(),
mHeight(16),
Column(
children: [
Divider(
height: 1,
color: Color(0xFFC7C7C7),
),
Container(
width: double.infinity,
height: MediaQuery.of(context).size.width * 0.3,
padding: EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14),
color: Colors.white,
child: Row(
children: [
offersButton(),
mWidth(10),
hmgButton(),
],
),
),
Divider(
height: 1,
color: Color(0xFFC7C7C7),
),
],
),
mHeight(12),
Column(
children: [
Padding(
padding: projectViewModel.isArabic
? const EdgeInsets.only(
left: 8,
right: 20,
)
: const EdgeInsets.only(
left: 20,
right: 8,
),
child: Row(
children: [
Expanded(
child: Text(
TranslationBase.of(context).hMGService,
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.bold,
letterSpacing: -0.96,
height: 19 / 16,
),
),
),
TextButton(
onPressed: () {
// AppSharedPreferences().getAll().then((value){
// debugPrint("ALL SHARED PREFERENCES!!!!!");
// debugPrint(jsonEncode(value));
// });
Navigator.push(context, FadePage(page: AllHabibMedicalSevicePage2()));
projectViewModel.analytics.hmgServices.viewAll();
},
child: Text(
TranslationBase.of(context).viewAllServices,
style: TextStyle(
color: CustomColors.accentColor,
fontSize: 12,
letterSpacing: -0.72,
height: 23 / 12,
),
),
),
],
),
),
projectViewModel.isPatientAdmitted || projectViewModel.patientHasAdmissionRequest
? Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 12.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
flex: 9,
child: Container(
margin: projectViewModel.isArabic ? EdgeInsets.only(left: 12.0) : EdgeInsets.only(right: 12.0),
child: AspectRatio(
aspectRatio: 2.15,
child: ServicesView(
new HmgServices(23, TranslationBase.of(context).InPatient, TranslationBase.of(context).inPatientServices, "assets/images/new/InPatient.svg", false),
23,
true,
projectViewModel)),
),
),
Expanded(
flex: 4,
child: AspectRatio(
aspectRatio: 1.0,
child: ServicesView(new HmgServices(5, TranslationBase.of(context).online, TranslationBase.of(context).payment, "assets/images/new/paymentMethods.png", false), 2,
true, projectViewModel)),
),
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 20,
right: 20,
top: 0,
),
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12),
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: hmgServices.length,
padding: EdgeInsets.zero,
itemBuilder: (BuildContext context, int index) {
return ServicesView(hmgServices[index], index, true, projectViewModel);
},
),
),
],
)
: Padding(
padding: const EdgeInsets.only(
left: 20,
right: 20,
top: 0,
),
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12),
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: hmgServices.length,
padding: EdgeInsets.zero,
itemBuilder: (BuildContext context, int index) {
// return ServicesView(hmgServices[index], index, true, projectViewModel,
// isLocked: (hmgServices[index].action == 2 && projectViewModel.isIndoorNavigationEnabled) ? !projectViewModel.havePrivilege(107) : false);
return ServicesView(hmgServices[index], index, true, projectViewModel, isLocked: hmgServices[index].isLocked);
},
),
),
],
),
mHeight(140),
],
),
);
}
Widget offersButton() {
final bypassPrivilageCheck = false;
return Expanded(
flex: 1,
child: InkWell(
onTap: () {
// Navigator.of(context).push(MaterialPageRoute(builder: (context) => ErOptions(isAppbar: true)));
Navigator.push(context, FadePage(page: ErOptions(isAppbar: true)));
},
child: Stack(
children: [
Container(
width: double.infinity,
height: double.infinity,
clipBehavior: Clip.antiAlias,
decoration: containerRadiusWithGradientServices(20, lightColor: CustomColors.lightGreyColor, darkColor: CustomColors.lightGreyColor),
child: Stack(
children: [
Container(
width: double.infinity,
height: double.infinity,
// color: Color(0xFF2B353E),
decoration: containerRadius(CustomColors.accentColor, 20),
),
Container(
width: double.infinity,
height: double.infinity,
clipBehavior: Clip.antiAlias,
decoration: projectViewModel.isArabic
? containerBottomRightRadiusWithGradientForAr(60, lightColor: CustomColors.lightGreyColor, darkColor: CustomColors.lightGreyColor)
: containerBottomRightRadiusWithGradient(60, lightColor: CustomColors.lightGreyColor, darkColor: CustomColors.lightGreyColor),
child: Stack(
children: [
SvgPicture.asset(
"assets/images/new/strips.svg",
width: double.infinity,
height: double.infinity,
fit: BoxFit.cover,
),
],
),
),
projectViewModel.isArabic
? Positioned(
left: 20,
top: 12,
child: Opacity(
opacity: 0.5,
child: SvgPicture.asset(
"assets/images/new/emergency_services_back.svg",
height: MediaQuery.of(context).size.width * 0.14,
),
),
)
: Positioned(
right: 20,
top: 12,
child: Opacity(
opacity: 0.5,
child: SvgPicture.asset(
"assets/images/new/emergency_services_back.svg",
height: MediaQuery.of(context).size.width * 0.14,
),
),
),
Container(
width: double.infinity,
height: double.infinity,
padding: EdgeInsets.all(SizeConfig.widthMultiplier! * 3.4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: SvgPicture.asset(
"assets/images/new/emergency_services.svg",
height: MediaQuery.of(context).size.width * 0.08,
),
),
mFlex(1),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
TranslationBase.of(context).emergencyServices,
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,
letterSpacing: -0.45,
height: 1,
),
),
projectViewModel.isArabic ? mHeight(5) : Container(),
Text(
TranslationBase.of(context).emergencyServicesSubtitle,
style: TextStyle(
color: Colors.black,
fontSize: 9,
fontWeight: FontWeight.w600,
letterSpacing: -0.27,
height: projectViewModel.isArabic ? 0.2 : 1,
),
),
],
),
],
),
),
],
),
),
// projectViewModel.havePrivilege(82) || bypassPrivilageCheck
// ? Container()
// : Container(
// width: double.infinity,
// height: double.infinity,
// clipBehavior: Clip.antiAlias,
// decoration: containerRadiusWithGradientServices(20, lightColor: CustomColors.lightGreyColor.withOpacity(0.7), darkColor: CustomColors.lightGreyColor.withOpacity(0.7)),
// child: Icon(
// Icons.lock_outline,
// size: 40,
// ),
// )
],
),
),
);
}
Widget hmgButton() {
return Expanded(
flex: 1,
child: InkWell(
onTap: () {
if (projectViewModel.havePrivilege(100)) widget.onPharmacyClick!();
},
child: Stack(children: [
Container(
width: double.infinity,
height: double.infinity,
clipBehavior: Clip.antiAlias,
decoration: containerRadiusWithGradientServices(20, lightColor: CustomColors.lightGreyColor, darkColor: CustomColors.lightGreyColor),
child: Stack(
children: [
Container(
width: double.infinity,
height: double.infinity,
// color: Color(0xFF2B353E),
decoration: containerRadius(Color(0xFF359846), 20),
),
Container(
width: double.infinity,
height: double.infinity,
clipBehavior: Clip.antiAlias,
decoration: projectViewModel.isArabic
? containerBottomRightRadiusWithGradientForAr(60, lightColor: CustomColors.lightGreyColor, darkColor: CustomColors.lightGreyColor)
: containerBottomRightRadiusWithGradient(60, lightColor: CustomColors.lightGreyColor, darkColor: CustomColors.lightGreyColor),
child: Stack(
children: [
SvgPicture.asset(
"assets/images/new/strips.svg",
width: double.infinity,
height: double.infinity,
fit: BoxFit.cover,
),
],
),
),
projectViewModel.isArabic
? Positioned(
left: 20,
top: 12,
child: Opacity(
opacity: 0.25,
child: SvgPicture.asset(
"assets/images/new/Pharmacy.svg",
height: MediaQuery.of(context).size.width * 0.15,
),
),
)
: Positioned(
right: 20,
top: 12,
child: Opacity(
opacity: 0.25,
child: SvgPicture.asset(
"assets/images/new/Pharmacy.svg",
height: MediaQuery.of(context).size.width * 0.15,
),
),
),
Container(
width: double.infinity,
height: double.infinity,
padding: EdgeInsets.all(SizeConfig.widthMultiplier! * 3.4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: SvgPicture.asset(
"assets/images/new/Pharmacy.svg",
height: MediaQuery.of(context).size.width * 0.08,
),
),
mFlex(1),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
TranslationBase.of(context).onlinePharmacy,
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,
letterSpacing: -0.45,
height: 1,
),
),
projectViewModel.isArabic ? mHeight(5) : Container(),
Text(
TranslationBase.of(context).ecommerceSolution,
style: TextStyle(
color: Colors.black,
fontSize: 9,
fontWeight: FontWeight.w600,
letterSpacing: -0.27,
height: projectViewModel.isArabic ? 0.2 : 1,
),
),
],
),
],
),
),
],
),
),
projectViewModel.havePrivilege(100)
? Container()
: Container(
width: double.infinity,
height: double.infinity,
clipBehavior: Clip.antiAlias,
decoration: containerRadiusWithGradientServices(20, lightColor: CustomColors.lightGreyColor.withOpacity(0.7), darkColor: CustomColors.lightGreyColor.withOpacity(0.7)),
child: Icon(
Icons.lock_outline,
size: 40,
),
)
]),
),
);
}
Widget getInpatientButton() {
return Container(
height: 50.0,
);
}
Widget showFloating(String icon) {
return Container(
width: MediaQuery.of(context).size.width * 0.06,
height: MediaQuery.of(context).size.width * 0.06,
decoration: containerRadius(CustomColors.accentColor, 100),
padding: EdgeInsets.all(4),
child: SvgPicture.asset(icon),
);
}
}