@ -1,14 +1,15 @@
import ' package:diplomaticquarterapp/config/shared_pref_kay.dart ' ;
import ' package:diplomaticquarterapp/core/enum/viewstate.dart ' ;
import ' package:diplomaticquarterapp/core/model/blooddonation/blood_groub_details.dart ' ;
import ' package:diplomaticquarterapp/core/model/blooddonation/get_all_cities.dart ' ;
/ / import ' package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart ' ;
import ' package:diplomaticquarterapp/core/model/my_balance/AdvanceModel.dart ' ;
import ' package:diplomaticquarterapp/core/model/my_balance/patient_info.dart ' ;
import ' package:diplomaticquarterapp/core/service/blood/blood_details_servies.dart ' ;
import ' package:diplomaticquarterapp/core/viewModels/blooddonation/blood_details_view_model.dart ' ;
import ' package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart ' ;
import ' package:diplomaticquarterapp/core/viewModels/project_view_model.dart ' ;
import ' package:diplomaticquarterapp/models/Authentication/authenticated_user.dart ' ;
import ' package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart ' ;
import ' package:diplomaticquarterapp/pages/Blood/user_agreement_page.dart ' ;
@ -27,6 +28,7 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import ' package:flutter/cupertino.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:giffy_dialog/giffy_dialog.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:smart_progress_bar/smart_progress_bar.dart ' ;
/ / import ' ../../../core/model/my_balance/AdvanceModel.dart ' ;
@ -39,8 +41,8 @@ import 'dialogs/SelectPatientInfoDialog.dart';
import ' new_text_Field.dart ' ;
enum BeneficiaryType { MyAccount , MyFamilyFiles , OtherAccount , NON }
enum Gender { Male , Female , NON }
enum Blood { Oplus , Ominus , Aplus , Aminus , Bplus , Bminus , ABplus , ABminus , NON }
enum Gender { Male , Female , NON }
enum Blood { Oplus , Ominus , Aplus , Aminus , Bplus , Bminus , ABplus , ABminus , NON }
class BloodDonationPage extends StatefulWidget {
@ override
@ -51,10 +53,11 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
TextEditingController _fileTextController = TextEditingController ( ) ;
TextEditingController _notesTextController = TextEditingController ( ) ;
BeneficiaryType beneficiaryType = BeneficiaryType . NON ;
Gender gender = Gender . Male ; / / Gender . NON ;
Blood blood = Blood . Aminus ; / / Blood . NON ;
Gender gender = Gender . Male ; / / Gender . NON ;
Blood blood = Blood . Aminus ; / / Blood . NON ;
/ / HospitalsModel _selectedHospital ;
CitiesModel _selectedHospital ;
CitiesModel _selectedHospital =
CitiesModel ( description: " Riyadh " , descriptionN: " الرياض " , iD: 1 ) ;
String amount = " " ;
String email ;
@ -62,22 +65,27 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
AuthenticatedUser authenticatedUser ;
GetAllSharedRecordsByStatusList selectedPatientFamily ;
AdvanceModel advanceModel = AdvanceModel ( ) ;
List_BloodGroupDetailsModel bloodDetails = List_BloodGroupDetailsModel ( ) ;
List_BloodGroupDetailsModel bloodDetails = List_BloodGroupDetailsModel ( ) ;
AppSharedPreferences sharedPref = AppSharedPreferences ( ) ;
AuthenticatedUser authUser ;
var checkedValue = false ;
var checkedValue = false ;
@ override
void initState ( ) {
super . initState ( ) ;
getAuthUser ( ) ;
}
@ override
Widget build ( BuildContext context ) {
ProjectViewModel projectProvider = Provider . of ( context ) ;
return BaseView < MyBalanceViewModel > (
onModelReady: ( model ) = > model . getCities ( ) , / / model . getHospitals ( ) ,
onModelReady: ( model ) = > model . getCities ( ) , / / model . getHospitals ( ) ,
builder: ( _ , model , w ) = > AppScaffold (
isShowAppBar: true ,
appBarTitle: " Blood Donation " , / / TranslationBase . of ( context ) . advancePayment ,
baseViewModel: model ,
appBarTitle: TranslationBase . of ( context ) . bloodD ,
body: SingleChildScrollView (
physics: ScrollPhysics ( ) ,
child: Container (
@ -86,15 +94,16 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Texts (
/ / TranslationBase . of ( context ) . advancePaymentLabel ,
" Enter the required information, In order to register for Blood Donation Service " , / / + model . user . firstName ,
TranslationBase . of ( context ) . bloodDEnterDesc ,
textAlign: TextAlign . center ,
) ,
SizedBox (
height: 12 ,
) ,
InkWell (
onTap: ( ) = > confirmSelectHospitalDialog ( model . CitiesModelList ) , / / model . hospitals
onTap: ( ) = >
confirmSelectHospitalDialog ( model . CitiesModelList ) ,
/ / model . hospitals
child: Container (
padding: EdgeInsets . all ( 12 ) ,
width: double . infinity ,
@ -105,7 +114,7 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Texts ( getHospitalName ( ) ) ,
Texts ( getHospitalName ( projectProvider ) ) ,
Icon ( Icons . arrow_drop_down )
] ,
) ,
@ -116,7 +125,8 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
) ,
InkWell (
/ / = = = = = = Gender = = = = = = = =
onTap: ( ) = > confirmSelectGenderDialog ( ) , / / confirmSelectBeneficiaryDialog ( model ) ,
onTap: ( ) = > confirmSelectGenderDialog ( ) ,
/ / confirmSelectBeneficiaryDialog ( model ) ,
child: Container (
padding: EdgeInsets . all ( 12 ) ,
width: double . infinity ,
@ -128,49 +138,19 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
/ / Texts ( getBeneficiaryType ( ) ) ,
Texts ( getGender ( ) ) ,
Texts ( getGender ( context ) ) ,
Icon ( Icons . arrow_drop_down )
] ,
) ,
) ,
) ,
/ / if ( beneficiaryType = = BeneficiaryType . MyFamilyFiles )
/ / SizedBox (
/ / height: 12 ,
/ / ) ,
/ / if ( beneficiaryType = = BeneficiaryType . MyFamilyFiles )
/ / InkWell (
/ / onTap: ( ) {
/ / model . getFamilyFiles ( ) . then ( ( value ) {
/ / confirmSelectFamilyDialog ( model
/ / . getAllSharedRecordsByStatusResponse
/ / . getAllSharedRecordsByStatusList ) ;
/ / } ) . showProgressBar (
/ / text: " Loading " ,
/ / backgroundColor: Colors . blue . withOpacity ( 0.6 ) ) ;
/ / } ,
/ / child: Container (
/ / padding: EdgeInsets . all ( 12 ) ,
/ / width: double . infinity ,
/ / height: 65 ,
/ / decoration: BoxDecoration (
/ / borderRadius: BorderRadius . circular ( 12 ) ,
/ / color: Colors . white ) ,
/ / child: Row (
/ / mainAxisAlignment: MainAxisAlignment . spaceBetween ,
/ / children: [
/ / Texts ( getFamilyMembersName ( ) ) ,
/ / Icon ( Icons . arrow_drop_down )
/ / ] ,
/ / ) ,
/ / ) ,
/ / ) ,
SizedBox (
height: 12 ,
) ,
InkWell (
/ / = = = = = = Gender = = = = = = = =
onTap: ( ) = > confirmSelectBloodDialog ( ) , / / confirmSelectBeneficiaryDialog ( model ) ,
onTap: ( ) = > confirmSelectBloodDialog ( ) ,
/ / confirmSelectBeneficiaryDialog ( model ) ,
child: Container (
padding: EdgeInsets . all ( 12 ) ,
width: double . infinity ,
@ -188,44 +168,14 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
) ,
) ,
) ,
/ / if ( beneficiaryType = = BeneficiaryType . MyFamilyFiles )
/ / SizedBox (
/ / height: 12 ,
/ / ) ,
/ / if ( beneficiaryType = = BeneficiaryType . MyFamilyFiles )
/ / InkWell (
/ / onTap: ( ) {
/ / model . getFamilyFiles ( ) . then ( ( value ) {
/ / confirmSelectFamilyDialog ( model
/ / . getAllSharedRecordsByStatusResponse
/ / . getAllSharedRecordsByStatusList ) ;
/ / } ) . showProgressBar (
/ / text: " Loading " ,
/ / backgroundColor: Colors . blue . withOpacity ( 0.6 ) ) ;
/ / } ,
/ / child: Container (
/ / padding: EdgeInsets . all ( 12 ) ,
/ / width: double . infinity ,
/ / height: 65 ,
/ / decoration: BoxDecoration (
/ / borderRadius: BorderRadius . circular ( 12 ) ,
/ / color: Colors . white ) ,
/ / child: Row (
/ / mainAxisAlignment: MainAxisAlignment . spaceBetween ,
/ / children: [
/ / Texts ( getFamilyMembersName ( ) ) ,
/ / Icon ( Icons . arrow_drop_down )
/ / ] ,
/ / ) ,
/ / ) ,
/ / ) ,
SizedBox (
height: 12 ,
) ,
Row (
children: [
Container (
child: Text ( " To view the terms and conditions " ) ,
child: Text (
TranslationBase . of ( context ) . viewTermsConditions ) ,
) ,
SizedBox (
width: MediaQuery . of ( context ) . size . height * 0.10 ,
@ -233,10 +183,14 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
InkWell (
onTap: ( ) {
Navigator . of ( context ) . push ( MaterialPageRoute (
builder: ( BuildContext context ) = > UserAgreementPage ( ) ) ) ;
builder: ( BuildContext context ) = >
UserAgreementPage ( ) ) ) ;
} ,
child: Container (
child: Texts ( " Click here " , color: Colors . blue , ) ,
child: Texts (
TranslationBase . of ( context ) . clickHere ,
color: Colors . blue ,
) ,
) ,
)
] ,
@ -247,25 +201,31 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
Row (
children: [
Checkbox (
onChanged: ( bool value ) {
onChanged: ( bool value ) {
setState ( ( ) {
checkedValue = value ;
} ) ;
} ,
/ / tristate: checkedValue = = true , / / i = = 1 ,
/ / tristate: checkedValue = = true , / / i = = 1 ,
value: checkedValue ,
activeColor: Colors . red , / / Color ( 0xFF6200EE ) ,
activeColor: Color ( 0xFFc5272d ) , / / Color ( 0xFF6200EE ) ,
) ,
SizedBox (
height: 10 ,
) ,
Row (
children: [ ] ,
) ,
SizedBox ( height: 10 , ) ,
Row ( children: [
] , ) ,
SizedBox (
width: 10 ,
) ,
Text (
' I agree to the terms and conditions ' ,
style: Theme . of ( context ) . textTheme . subtitle1 . copyWith ( color: checkedValue ? Colors . red : Colors . black ) ,
TranslationBase . of ( context )
. iAgreeToTheTermsAndConditions ,
style: Theme . of ( context ) . textTheme . subtitle1 . copyWith (
color: checkedValue
? Color ( 0xFFc5272d )
: Colors . black ) ,
) ,
] ,
) ,
@ -355,29 +315,25 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
onTap: ( ) {
showDialog (
context: context ,
builder: ( _ ) = >
AssetGiffyDialog (
builder: ( _ ) = > AssetGiffyDialog (
title: Text (
" " ,
style: TextStyle (
fontSize: 22.0 ,
fontWeight:
FontWeight
. w600 ) ,
fontWeight: FontWeight . w600 ) ,
) ,
image: Image . asset (
' assets/images/BloodChrt_EN.png ' ) ,
buttonCancelText:
Text ( ' cancel ' ) ,
buttonCancelColor:
Colors . grey ,
buttonCancelText: Text (
TranslationBase . of ( context ) . cancel ) ,
buttonCancelColor: Colors . grey ,
onlyCancelButton: true ,
) ) ;
} ,
child: Container (
width: 250 ,
height: 200 ,
child: Image . asset (
child: Image . asset (
' assets/images/BloodChrt_EN.png ' ) ) ,
) ,
) ,
@ -395,25 +351,37 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
bottomSheet: Container (
height: MediaQuery . of ( context ) . size . height * 0.12 ,
width: double . infinity ,
padding: EdgeInsets . all ( 12 ) ,
child: SecondaryButton (
textColor: Colors . white ,
color: checkedValue = = false ? Colors . white24: Color . fromRGBO ( 63 , 72 , 74 , 1 , ) ,
label: " Save " ,
/ /
onTap: ( ) {
bloodDetails . city = _selectedHospital . toString ( ) ;
/ / bloodDetails .
color: checkedValue = = false
? Color ( 0xFFa0a4a6 )
: Color . fromRGBO (
63 ,
72 ,
74 ,
1 ,
) ,
label: TranslationBase . of ( context ) . save ,
onTap: ( ) async {
bloodDetails . city = projectProvider . isArabic
? _selectedHospital . descriptionN
: _selectedHospital . description ;
bloodDetails . cityCode = _selectedHospital . iD . toString ( ) ;
bloodDetails . gender = gender = = Gender . Male ? 1 : 2 ;
await model . updateBloodGroup ( bloodDetails ) ;
if ( model . state = = ViewState . Idle ) {
AppToast . showSuccessToast (
message: model . updatedRegisterBloodMessage ) ;
} else {
AppToast . showErrorToast ( message: model . error ) ;
}
} ,
) ,
) ) ,
) ;
}
/ / = = = = = = = = = = = = = =
void confirmSelectBeneficiaryDialog ( MyBalanceViewModel model ) {
showDialog (
@ -435,94 +403,85 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
) ,
) ;
}
void confirmSelectBloodDialog ( ) {
void confirmSelectBloodDialog ( ) {
showDialog (
context: context ,
child: SelectBloodDialog ( bloodType: blood ,
child: SelectBloodDialog (
bloodType: blood ,
onValueSelected: ( value ) {
setState ( ( ) {
if ( value = = Blood . Oplus ) {
bloodDetails . bloodGroup = " O+ " ;
bloodDetails . bloodGroup = " O+ " ;
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
} else
if ( value = = Blood . Ominus ) {
} else if ( value = = Blood . Ominus ) {
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
bloodDetails . bloodGroup = " O- " ;
bloodDetails . bloodGroup = " O- " ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
} else
if ( value = = Blood . ABplus ) {
bloodDetails . bloodGroup = " AB+ " ;
} else if ( value = = Blood . ABplus ) {
bloodDetails . bloodGroup = " AB+ " ;
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
} else
if ( value = = Blood . ABminus ) {
bloodDetails . bloodGroup = " AB- " ;
} else if ( value = = Blood . ABminus ) {
bloodDetails . bloodGroup = " AB- " ;
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
} else
if ( value = = Blood . Aplus ) {
bloodDetails . bloodGroup = " A+ " ;
} else if ( value = = Blood . Aplus ) {
bloodDetails . bloodGroup = " A+ " ;
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
} else
if ( value = = Blood . Aminus ) {
bloodDetails . bloodGroup = " A- " ;
} else if ( value = = Blood . Aminus ) {
bloodDetails . bloodGroup = " A- " ;
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
} else
if ( value = = Blood . Bplus ) {
bloodDetails . bloodGroup = " B+ " ;
} else if ( value = = Blood . Bplus ) {
bloodDetails . bloodGroup = " B+ " ;
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
} else
if ( value = = Blood . Bminus ) {
bloodDetails . bloodGroup = " B- " ;
} else if ( value = = Blood . Bminus ) {
bloodDetails . bloodGroup = " B- " ;
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
}
else
} else
_fileTextController . text = " " ;
/ / beneficiaryType = value ;
blood = value ;
}
) ;
blood = value ;
} ) ;
} ,
) ,
) ;
}
void confirmSelectGenderDialog ( ) {
void confirmSelectGenderDialog ( ) {
showDialog (
context: context ,
child: SelectGenderDialog ( beneficiaryType: gender ,
child: SelectGenderDialog (
beneficiaryType: gender ,
onValueSelected: ( value ) {
setState ( ( ) {
if ( value = = Gender . Male ) {
/ / _fileTextController . text = model . user . patientID . toString ( ) ;
bloodDetails . patientType = 1 ;
bloodDetails . patientType = 1 ;
/ / advanceModel . depositorName =
/ / model . user . firstName + " " + model . user . lastName ;
} else
/ / _fileTextController . text = " " ;
{ bloodDetails . gender = 2 ; }
/ / _fileTextController . text = " " ;
{
bloodDetails . gender = 2 ;
}
/ / beneficiaryType = value ;
gender = value ;
/ / beneficiaryType = value ;
gender = value ;
} ) ;
} ,
) ,
@ -591,23 +550,25 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
return TranslationBase . of ( context ) . otherAccount ;
break ;
case BeneficiaryType . NON:
return " Select Gender " ; / / TranslationBase . of ( context ) . selectBeneficiary ;
return TranslationBase . of ( context ) . selectBeneficiary ;
}
return " Select Gender " ; / / TranslationBase . of ( context ) . selectBeneficiary ;
return TranslationBase . of ( context ) . selectBeneficiary ;
}
String getGender ( ) {
String getGender ( BuildContext context ) {
switch ( gender ) {
case Gender . Male:
return " Male " ;
return TranslationBase . of ( context ) . male ;
case Gender . Female:
return " Female " ;
return TranslationBase . of ( context ) . female ;
break ;
case Gender . NON:
return " Select Gender " ; / / TranslationBase . of ( context ) . select Beneficiary ;
return TranslationBase . of ( context ) . select Gender ;
}
return " Select Gender " ; / / TranslationBase . of ( context ) . select Beneficiary ;
return TranslationBase . of ( context ) . select Gender ;
}
String getBlood ( ) {
switch ( blood ) {
case Blood . Oplus:
@ -639,18 +600,19 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
break ;
case Blood . NON:
return " Select Blood Type " ; / / TranslationBase . of ( context ) . selectBeneficiary ;
return " Select Blood Type " ; / / TranslationBase . of ( context ) . selectBeneficiary ;
}
return " Select Blood Type " ; / / TranslationBase . of ( context ) . selectBeneficiary ;
return " Select Blood Type " ; / / TranslationBase . of ( context ) . selectBeneficiary ;
}
String getHospitalName ( ) {
String getHospitalName ( ProjectViewModel projectProvider ) {
if ( _selectedHospital ! = null )
return _selectedHospital . description ;
return projectProvider . isArabic
? _selectedHospital . descriptionN
: _selectedHospital . description ;
else
return
" Riyadh " ;
/ / return List_BloodGroupDetailsModel . fromJson ( 0 ) . city . toString ( ) ; / / " Select City " ; / / TranslationBase . of ( context ) . selectHospital ;
return projectProvider . isArabic ? " الرياض " : " Riyadh " ;
/ / return List_BloodGroupDetailsModel . fromJson ( 0 ) . city . toString ( ) ; / / " Select City " ; / / TranslationBase . of ( context ) . selectHospital ;
}
String getPatientName ( ) {
@ -677,8 +639,6 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
return TranslationBase . of ( context ) . selectFamilyPatientName ;
}
/ / = = = = = = = = = = = = = = = =
/ / = = = = = = = = = = = = = = = =
}