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/landing/home_page.dart

1031 lines
54 KiB
Dart

import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/all_habib_medical_service_page.dart';
import 'package:diplomaticquarterapp/pages/ContactUs/contact_us_page.dart';
import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-drivethru-location.dart';
import 'package:diplomaticquarterapp/pages/ErService/ErOptions.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/livecare/livecare_home.dart';
import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesPage.dart';
import 'package:diplomaticquarterapp/pages/paymentService/payment_service.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import 'landing_page_pharmcy.dart';
class HomePage extends StatefulWidget {
final Function goToMyProfile;
HomePage({Key key, this.goToMyProfile});
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
PharmacyModuleViewModel pharmacyModuleViewModel =
locator<PharmacyModuleViewModel>();
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<DashboardViewModel>(
onModelReady: (model) => () async {},
builder: (_, model, wi) => AppScaffold(
isShowDecPage: false,
isHelp: true,
body: Container(
width: double.infinity,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Stack(
children: <Widget>[
Column(
children: <Widget>[
Container(
width: double.infinity,
height: 210,
decoration: BoxDecoration(
image: DecorationImage(
image: ExactAssetImage(
'assets/images/dashboard_top_bg.png'),
fit: BoxFit.cover),
),
child: Stack(
children: <Widget>[
Positioned(
top: 15,
left: 5,
right: 5,
child: Container(
width:
MediaQuery.of(context).size.width * 0.8,
child: Row(
children: <Widget>[
Expanded(
child: Container(
height: 125,
padding: EdgeInsets.all(5),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/images/new-design/covid_bg_transparent.png"),
fit: BoxFit.fill,
),
color:
Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.all(
Radius.circular(5))),
child: Container(
child: Column(
children: <Widget>[
Texts(
TranslationBase.of(context)
.covidTest,
color: Colors.white,
fontWeight: FontWeight.w700,
),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceAround,
children: <Widget>[
Container(
margin: EdgeInsets.only(
top: 15.0,
),
child: SvgPicture.asset(
'assets/images/new-design/covid-19-car.svg',
width: 45.0,
height: 45.0),
),
Container(
margin: EdgeInsets.only(
top: 5.0),
child: Column(
children: <Widget>[
Texts(
TranslationBase.of(
context)
.driveThru,
fontWeight:
FontWeight.w700,
color: Colors.white,
),
ButtonTheme(
shape:
RoundedRectangleBorder(
borderRadius:
BorderRadius
.circular(
5.0),
),
minWidth: MediaQuery.of(
context)
.size
.width *
0.15,
height: 25.0,
child: RaisedButton(
color: Colors
.red[800],
textColor:
Colors.white,
disabledTextColor:
Colors.white,
disabledColor:
new Color(
0xFFbcc2c4),
onPressed: () {
navigateToCovidDriveThru();
},
child: Center(
child: Center(
child: Center(
child:
Center(
child:
Texts(
TranslationBase.of(context)
.bookNow,
fontWeight:
FontWeight.w700,
color: Colors
.white,
),
),
),
),
),
),
),
],
),
),
],
),
],
),
),
),
),
Expanded(
child: InkWell(
onTap: () => Navigator.push(context,
FadePage(page: LiveCareHome())),
child: Container(
height: 125,
padding: EdgeInsets.all(15),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
color: Colors.white
.withOpacity(0.3),
borderRadius: BorderRadius.all(
Radius.circular(5))),
child: SvgPicture.asset(
projectViewModel.isArabic
? 'assets/images/new-design/livecare_arabic_logo.svg'
: 'assets/images/new-design/liveCare_white_logo.svg',
),
),
),
),
],
),
),
)
],
),
),
Container(
width: double.infinity,
height: projectViewModel.isArabic ? 110 : 80)
],
),
Positioned(
top: 155,
left: MediaQuery.of(context).size.width *
(MediaQuery.of(context).orientation ==
Orientation.landscape
? 0.02
: 0.03),
right: MediaQuery.of(context).size.width *
(MediaQuery.of(context).orientation ==
Orientation.landscape
? 0.02
: 0.03),
child: (!model.isLogin)
? Container(
width: double.infinity,
height: 125,
decoration: BoxDecoration(
color: HexColor('#A59E9E'),
shape: BoxShape.rectangle,
border: Border.all(
color: Colors.transparent, width: 0.5),
borderRadius:
BorderRadius.all(Radius.circular(9)),
image: DecorationImage(
image: ExactAssetImage(
'assets/images/bg_graphic.png'),
fit: BoxFit.cover)),
child: Container(
margin: EdgeInsets.all(5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 2,
),
Texts(
TranslationBase.of(context).myMedicalFile,
color: Colors.black87,
fontWeight: FontWeight.w700,
fontSize: 23,
),
Texts(
TranslationBase.of(context)
.myMedicalFileSubTitle,
color: Colors.black,
fontSize: 16,
),
Align(
alignment: projectViewModel.isArabic
? Alignment.bottomLeft
: Alignment.bottomRight,
child: InkWell(
onTap: () {
widget.goToMyProfile();
},
child: Container(
margin: EdgeInsets.only(
left: 15, right: 15),
width: 90,
height: 30,
decoration: BoxDecoration(
color: HexColor('#D81A2E'),
shape: BoxShape.rectangle,
border: Border.all(
color: Colors.transparent,
width: 0.5),
borderRadius: BorderRadius.all(
Radius.circular(0)),
),
child: Center(
child: Texts(
TranslationBase.of(context)
.viewMore,
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 12,
),
),
),
),
)
],
),
),
)
: Container(
width: double.infinity,
height: projectViewModel.isArabic ? 160 : 130,
decoration: BoxDecoration(
color: HexColor('#A59E9E'),
shape: BoxShape.rectangle,
border: Border.all(
color: Colors.transparent, width: 0.5),
borderRadius:
BorderRadius.all(Radius.circular(9)),
image: DecorationImage(
image: ExactAssetImage(
'assets/images/bg_graphic.png'),
fit: BoxFit.cover),
),
child: Container(
margin: EdgeInsets.all(5),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
if (projectViewModel.user != null &&
model.isLogin)
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 8,
),
model.user.cRSVerificationStatus ==
2
? Row(
children: [
Texts(
model.user
.firstName +
" " +
model.user
.lastName,
color: Colors
.grey[100],
bold: true,
fontSize: 15,
),
Container(
margin: EdgeInsets
.fromLTRB(
8.0,
0.0,
8.0,
0.0),
child: SvgPicture.asset(
"assets/images/new-design/verification_check.svg"),
),
],
)
: model.user.cRSVerificationStatus ==
3
? Row(
children: [
Texts(
model.user
.firstName +
" " +
model.user
.lastName,
color: Colors
.grey[100],
bold: true,
fontSize: 15,
),
Container(
margin: EdgeInsets
.fromLTRB(
8.0,
0.0,
8.0,
0.0),
child: SvgPicture
.asset(
"assets/images/new-design/pending.svg"),
),
],
)
: Row(
children: [
Texts(
model.user
.firstName +
" " +
model.user
.lastName,
color: Colors
.grey[100],
bold: true,
fontSize: 15,
),
],
),
Texts(
'${model.user.patientID}',
color: Colors.white,
fontSize: 14,
),
SizedBox(
height: 5,
),
Texts(
'${DateUtil.getMonthDayYearDateFormatted(model.user.dateofBirthDataTime)} ,${model.user.gender == 1 ? TranslationBase.of(context).male : TranslationBase.of(context).female} ${model.user.age.toString() + "y"}',
color: Colors.grey[100],
fontWeight: FontWeight.normal,
fontSize: 14,
),
],
),
),
InkWell(
onTap: () {
widget.goToMyProfile();
},
child: Container(
margin: EdgeInsets.all(2),
width: 90,
height: 30,
decoration: BoxDecoration(
color: HexColor('#D81A2E'),
shape: BoxShape.rectangle,
border: Border.all(
color: Colors.transparent,
width: 0.5),
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
child: Center(
child: Texts(
TranslationBase.of(context)
.myMedicalFile,
color: Colors.white,
fontSize: 12,
textAlign: TextAlign.center,
),
),
),
)
],
),
Row(
children: <Widget>[
Expanded(
child: Row(
children: <Widget>[
Image.asset(
'assets/images/height_icon.png',
width: 35,
height: 40,
),
Texts(
"${model.heightCm} ${TranslationBase.of(context).cm}",
color: Colors.white,
fontSize: 17,
)
],
),
),
SizedBox(
width: 3,
),
Expanded(
child: Row(
children: <Widget>[
Image.asset(
'assets/images/weight_icon.png',
width: 25,
height: 40,
),
Texts(
'${model.weightKg} ${TranslationBase.of(context).kg}',
color: Colors.white,
fontSize: 17)
],
),
),
SizedBox(
width: 3,
),
Expanded(
child: Row(
children: <Widget>[
Image.asset(
'assets/images/blood_icon.png',
width: 35,
height: 40,
),
Texts('${model.booldType}',
color: Colors.white,
fontSize: 17)
],
),
),
],
)
],
),
),
),
),
],
),
Padding(
padding:
const EdgeInsets.only(bottom: 15, right: 15, left: 15),
child: InkWell(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => PackagesHomePage()));
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color(0xffB8382C),
),
child: Padding(
padding: const EdgeInsets.all(8),
child: Row(
children: [
Texts(
TranslationBase.of(context).offerAndPackages,
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.normal,
),
Spacer(),
Image.asset("assets/images/offer_icon.png"),
],
),
),
),
),
),
if (projectViewModel.havePrivilege(64) ||
projectViewModel.havePrivilege(65) ||
projectViewModel.havePrivilege(67))
Container(
margin: EdgeInsets.only(left: 15, right: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
if (projectViewModel.havePrivilege(64))
DashboardItem(
onTap: (model.user != null && model.user.outSA == 1)
? () {}
: () {
Navigator.push(
context,
FadePage(
page: HomeHealthCarePage(),
),
);
},
child: Center(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: (model.user != null &&
model.user.outSA == 1)
? Container(
width: double.infinity,
height: double.infinity,
color: Colors.grey.withOpacity(0.7),
child: Icon(
Icons.lock_outline,
size: 40,
),
)
: Column(
children: <Widget>[
Image.asset(
'assets/images/home_health_care_icon.png',
width: 50,
height: 50,
),
SizedBox(
height: 10,
),
Texts(
TranslationBase.of(context)
.homeHealthCare,
textAlign: TextAlign.center,
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize:
SizeConfig.textMultiplier *
1.55,
)
],
)),
),
height: MediaQuery.of(context).size.width * 0.4,
imageName: 'home_healthcare_service_bg.png',
opacity: 0.5,
),
if (projectViewModel.havePrivilege(65))
DashboardItem(
onTap: () =>
(model.user != null && model.user.outSA == 1)
? () {}
: getPharmacyToken(model),
child: Center(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: (model.user != null &&
model.user.outSA == 1)
? Container(
width: double.infinity,
height: double.infinity,
color: Colors.grey.withOpacity(0.7),
child: Icon(
Icons.lock_outline,
size: 40,
),
)
: Column(
children: <Widget>[
// if (projectViewModel.user != null && model.isLogin && model.user.outSA == 1)
// Image.asset(
// 'assets/images/lock_icon.png',
// width: 50,
// height: 50,
// ),
Image.asset(
'assets/images/pharmacy_logo.png',
width: 40,
height: 40,
),
SizedBox(
height: 20,
),
Texts(
TranslationBase.of(context)
.onlinePharmacy,
textAlign: TextAlign.center,
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize:
SizeConfig.textMultiplier *
1.55,
)
],
),
),
),
height: MediaQuery.of(context).size.width * 0.4,
imageName: 'al-habib_onlne_pharmacy_bg.png',
),
if (projectViewModel.havePrivilege(67))
DashboardItem(
onTap: (model.user != null && model.user.outSA == 1)
? () {}
: () {
Navigator.push(
context,
FadePage(
page: CMCPage(),
),
);
},
child: Center(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: (model.user != null &&
model.user.outSA == 1)
? Container(
width: double.infinity,
height: double.infinity,
color: Colors.grey.withOpacity(0.7),
child: Icon(
Icons.lock_outline,
size: 40,
),
)
: Column(
children: <Widget>[
Image.asset(
'assets/images/comprehensive_medical_checkup_logo.png',
width: 50,
height: 50,
),
SizedBox(
height: 10,
),
Texts(
TranslationBase.of(context)
.cmcHeading,
textAlign: TextAlign.center,
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize:
SizeConfig.textMultiplier *
1.55,
)
],
)),
),
height: MediaQuery.of(context).size.width * 0.4,
color: HexColor("#747C80"),
imageName: 'emergency_service_image.png',
),
],
),
),
SizedBox(
height: 8,
),
InkWell(
onTap: () =>
Navigator.push(context, FadePage(page: PaymentService())),
child: Container(
margin: EdgeInsets.only(left: 15, right: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width * 0.29,
child: Center(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: <Widget>[
Image.asset(
'assets/images/al-habib_online_payment_service_icon.png',
height: 55,
),
SizedBox(
height: 5,
),
Texts(
TranslationBase.of(context)
.onlinePaymentService,
textAlign: TextAlign.center,
color: Colors.black87,
bold: false,
fontSize: SizeConfig.textMultiplier * 1.7,
)
],
),
),
),
height: MediaQuery.of(context).size.width * 0.4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.0),
color: Colors.white,
),
),
Container(
child: Center(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: <Widget>[
Image.asset(
'assets/images/ereferral_service_icon.png',
width: 50,
height: 55,
),
SizedBox(
height: 10,
),
Texts(
TranslationBase.of(context)
.offersAndPackages,
textAlign: TextAlign.center,
color: Colors.black87,
bold: false,
fontSize: SizeConfig.textMultiplier * 1.7,
)
],
),
),
),
width: MediaQuery.of(context).size.width * 0.29,
height: MediaQuery.of(context).size.width * 0.4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.0),
color: Colors.white,
)),
if (projectViewModel.havePrivilege(60))
Container(
width: MediaQuery.of(context).size.width * 0.29,
child: InkWell(
onTap: () => Navigator.push(
context,
FadePage(
page: ErOptions(
isAppbar: true,
))),
child: Center(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: <Widget>[
Image.asset(
'assets/images/Dr_Schedule_report.png',
width: 50,
height: 50,
),
SizedBox(
height: 10,
),
Texts(
TranslationBase.of(context)
.emergencyServices,
textAlign: TextAlign.center,
color: Colors.black87,
bold: false,
fontSize:
SizeConfig.textMultiplier * 1.7,
)
],
),
),
),
),
height: MediaQuery.of(context).size.width * 0.4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.0),
color: Colors.white,
),
),
],
),
),
),
SizedBox(
height: 5,
),
Container(
margin: EdgeInsets.only(left: 15, right: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
DashboardItem(
child: Container(
width: double.infinity,
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Texts(
TranslationBase.of(context).hMGService,
color: Colors.white,
fontWeight: FontWeight.normal,
),
Texts(
TranslationBase.of(context)
.viewAllHabibMedicalService,
color: Colors.white,
fontWeight: FontWeight.normal,
fontSize: 10,
),
Expanded(
child: Container(),
),
Texts(
TranslationBase.of(context).viewMore,
color: Colors.white,
//fontWeight: FontWeight.normal,
)
],
),
),
height: 100,
imageName: 'contact_us_bg.png',
opacity: 0.5,
color: Colors.grey[700],
width: MediaQuery.of(context).size.width * 0.45,
onTap: () => Navigator.push(
context, FadePage(page: AllHabibMedicalService())),
),
DashboardItem(
onTap: () {
// Navigator.push(
// context, FadePage(page: FeedbackHomePage()));
Navigator.push(
context, FadePage(page: ContactUsPage()));
},
child: Container(
width: double.infinity,
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Texts(
TranslationBase.of(context).contactUs,
color: Colors.white,
fontWeight: FontWeight.normal,
),
Texts(
TranslationBase.of(context).viewAllWaysReachUs,
color: Colors.white,
fontWeight: FontWeight.normal,
fontSize: 10,
),
Expanded(
child: Container(),
),
Texts(
TranslationBase.of(context).viewMore,
color: Colors.white,
fontWeight: FontWeight.normal,
)
],
),
),
height: 100,
imageName: 'contact_us_bg.png',
opacity: 0.5,
color: Colors.grey[700],
width: MediaQuery.of(context).size.width * 0.45,
),
],
),
),
SizedBox(
height: 120,
)
],
),
),
),
),
);
}
getPharmacyToken(DashboardViewModel model) async {
if (!model.isLogin) {
Navigator.push(context, FadePage(page: LandingPagePharmacy()));
} else {
GifLoaderDialogUtils.showMyDialog(context);
await pharmacyModuleViewModel.generatePharmacyToken().then((value) async {
if (pharmacyModuleViewModel.error.isNotEmpty) {
await pharmacyModuleViewModel.createUser().then((value) {
GifLoaderDialogUtils.hideDialog(context);
Navigator.push(context, FadePage(page: LandingPagePharmacy()));
});
} else {
GifLoaderDialogUtils.hideDialog(context);
Navigator.push(context, FadePage(page: LandingPagePharmacy()));
}
});
}
}
navigateToCovidDriveThru() {
Navigator.push(context, FadePage(page: CovidDrivethruLocation()));
}
}
class DashboardItem extends StatelessWidget {
const DashboardItem(
{this.hasBorder = false,
this.imageName,
@required this.child,
this.onTap,
Key key,
this.width,
this.height,
this.color,
this.opacity = 0.4,
this.hasColorFilter = true})
: super(key: key);
final bool hasBorder;
final String imageName;
final Widget child;
final Function onTap;
final double width;
final double height;
final Color color;
final double opacity;
final bool hasColorFilter;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
width: width != null ? width : MediaQuery.of(context).size.width * 0.29,
height: height != null
? height
: MediaQuery.of(context).orientation == Orientation.portrait
? MediaQuery.of(context).size.height * 0.17
: MediaQuery.of(context).size.height * 0.35,
decoration: BoxDecoration(
color: !hasBorder
? color != null
? color
: HexColor('#050705').withOpacity(opacity)
: Colors.white,
borderRadius: BorderRadius.circular(6.0),
border: hasBorder
? Border.all(width: 1.0, color: const Color(0xffcccccc))
: Border.all(width: 0.0, color: Colors.transparent),
image: imageName != null
? DecorationImage(
image: ExactAssetImage('assets/images/$imageName'),
fit: BoxFit.cover,
colorFilter: hasColorFilter
? new ColorFilter.mode(
Colors.black.withOpacity(0.2), BlendMode.dstIn)
: null,
)
: null,
),
child: Center(
child: child,
),
),
);
}
}