Merge branch 'hijri_calender' into 'development'

Hijri calender

See merge request Cloud_Solution/doctor_app_flutter!883
merge-requests/884/merge
Elham Ali 4 years ago
commit 101bc9f1b6

@ -0,0 +1,4 @@
enum CalenderType{
Gregorian,
Hijri,
}

@ -63,8 +63,7 @@ class _RegisterConfirmationPatientPageState
TextEditingController middleNameAr;
TextEditingController lastNameAr;
TextEditingController emailAddressController;
TextEditingController langController = TextEditingController(
text: "English");
TextEditingController langController = TextEditingController(text: "English");
int selectedLang = 1;
@override
@ -397,10 +396,13 @@ class _RegisterConfirmationPatientPageState
widget.model.getPatientInfoResponseModel.dateOfBirth);
String wellFormat =
"${dateFormat.day}\/${dateFormat.month}\/${dateFormat.year}";
print(dateFormat.toUtc().toString());
print(
dateFormat.toUtc().toString(),
);
HijriCalendar hijriDate = HijriCalendar.fromDate(
new DateTime(dateFormat.year, dateFormat.month,
dateFormat.day));
new DateTime(
dateFormat.year, dateFormat.month, dateFormat.day),
);
// return ;
GifLoaderDialogUtils.showMyDialog(context);
@ -664,7 +666,6 @@ class _RegisterConfirmationPatientPageState
groupValue: selectedLang,
onChanged: (value) {
setSelectedLang(value);
},
activeColor: Colors.red,
),
@ -682,10 +683,11 @@ class _RegisterConfirmationPatientPageState
);
});
}
setSelectedLang(lang){
setSelectedLang(lang) {
setState(() {
selectedLang = lang;
langController.text = lang==1?"English": "العربيه";
langController.text = lang == 1 ? "English" : "العربيه";
});
Navigator.of(context).pop();
}

@ -20,6 +20,10 @@ import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/country_textfield_custom.dart';
import 'package:flutter/material.dart';
import 'package:hijri/hijri_calendar.dart';
import 'package:hijri_picker/hijri_picker.dart';
import 'package:doctor_app_flutter/core/enum/CalenderType.dart';
import 'package:intl/intl.dart';
class RegisterSearchPatientPage extends StatefulWidget {
final Function changePageViewIndex;
@ -54,8 +58,10 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
TextEditingController(text: "1062938285");
String idError;
DateTime _birthDate;
DateTime _birthDateInGregorian;
String birthdateError;
var birthDateInHijri = new HijriCalendar.now();
CalenderType calenderType = CalenderType.Gregorian;
@override
void initState() {
@ -178,15 +184,44 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
SizedBox(
height: 10,
),
Row(
children: [
Expanded(
child: RadioListTile<CalenderType>(
title: AppText("Gregorian"),
value: CalenderType.Gregorian,
groupValue: calenderType,
onChanged: (CalenderType value) {
setState(() {
calenderType = value;
});
},
),
),
Expanded(
child: RadioListTile<CalenderType>(
title: AppText("Hijri"),
value: CalenderType.Hijri,
groupValue: calenderType,
onChanged: (CalenderType value) {
setState(() {
calenderType = value;
});
},
),
),
],
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: screenSize.height * 0.075,
hintText: "Birthdate",
dropDownText: _birthDate != null
? "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"
: null,
dropDownText: getBirthdate(),
enabled: false,
isTextFieldHasSuffix: true,
validationError: _birthDate == null && isSubmitted
validationError: _birthDateInGregorian == null && isSubmitted
? TranslationBase.of(context).emptyMessage
: null,
suffixIcon: IconButton(
@ -197,12 +232,29 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
onPressed: null,
),
onClick: () {
if (_birthDate == null) {
_birthDate = DateTime.now();
if (_birthDateInGregorian == null) {
_birthDateInGregorian = DateTime.now();
}
_selectDate(context, _birthDate, (picked) {
_selectDate(context, _birthDateInGregorian,
(dynamic selectedDate) {
setState(() {
_birthDate = picked;
if (calenderType == CalenderType.Hijri) {
birthDateInHijri = selectedDate;
_birthDateInGregorian = HijriCalendar().hijriToGregorian(
birthDateInHijri.hYear,
birthDateInHijri.hMonth,
birthDateInHijri.hDay);
print(_birthDateInGregorian);
print(birthDateInHijri);
} else {
_birthDateInGregorian = selectedDate;
birthDateInHijri = HijriCalendar()
.gregorianToHijri(
selectedDate.year, selectedDate.month, selectedDate.day);
print(_birthDateInGregorian);
print(birthDateInHijri);
}
});
});
},
@ -276,13 +328,14 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
patientOutSA: 0,
generalid: GENERAL_ID,
dOB:
"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}");
"${AppDateUtils.convertStringToDateFormat(_birthDateInGregorian.toString(), "yyyy/MM/dd")}");
await widget.model.checkPatientForRegistration(
checkPatientForRegistrationModel);
GetPatientInfoRequestModel getPatientInfoRequestModel =
GetPatientInfoRequestModel(
//TODO Elham* this return the static to dynamic
//patientIdentificationID:"1062938285", _idController.text,
patientIdentificationID: "1062938285",
// _idController.text,
isHijri: 0,
isDentalAllowedBackend: false,
patientOutSA: 0,
@ -319,25 +372,43 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
_phoneController.text.isNotEmpty &&
_idController.text != null &&
_idController.text.isNotEmpty &&
_birthDate != null) {
_birthDateInGregorian != null) {
return true;
}
return false;
}
Future _selectDate(BuildContext context, DateTime dateTime,
Function(DateTime picked) updateDate) async {
Function(dynamic) updateDate) async {
if (calenderType == CalenderType.Hijri) {
HijriCalendar hijriDate = HijriCalendar.fromDate(DateTime.now());
final HijriCalendar pickedH = await showHijriDatePicker(
context: context,
initialDate: birthDateInHijri ?? hijriDate,
lastDate: new HijriCalendar()
..hYear = hijriDate.hYear
..hMonth = hijriDate.hMonth
..hDay = hijriDate.hDay,
firstDate: new HijriCalendar()
..hYear = 1438
..hMonth = 12
..hDay = 25,
initialDatePickerMode: DatePickerMode.day,
);
if (pickedH != null && birthDateInHijri != pickedH) updateDate(pickedH);
} else {
final DateTime picked = await showDatePicker(
context: context,
initialDate: dateTime,
initialDate: dateTime ?? DateTime.now(),
firstDate: DateTime(DateTime.now().year - 150),
lastDate: DateTime(DateTime.now().year + 150),
lastDate: DateTime.now(),
initialEntryMode: DatePickerEntryMode.calendar,
);
if (picked != null && picked != dateTime) {
updateDate(picked);
}
}
}
void openListDialogField(String attributeName, String attributeValueId,
List<dynamic> list, Function(dynamic selectedValue) okFunction) {
@ -359,4 +430,18 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
},
);
}
getBirthdate() {
if (calenderType == CalenderType.Hijri) {
return birthDateInHijri != null
? "$birthDateInHijri"
: null;
}else{
return _birthDateInGregorian != null
? "${AppDateUtils.convertStringToDateFormat(_birthDateInGregorian.toString(), "yyyy/MM/dd")}"
: null;
}
}
}

@ -575,12 +575,19 @@ packages:
source: hosted
version: "1.0.6"
hijri:
dependency: "direct main"
dependency: transitive
description:
name: hijri
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
hijri_picker:
dependency: "direct main"
description:
name: hijri_picker
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
html:
dependency: "direct main"
description:
@ -699,7 +706,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.4"
version: "1.3.0-nullsafety.3"
mime:
dependency: transitive
description:
@ -1033,7 +1040,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.2"
version: "1.10.0-nullsafety.1"
sticky_headers:
dependency: "direct main"
description:
@ -1238,5 +1245,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.10.2 <=2.11.0-213.1.beta"
dart: ">=2.10.2 <2.11.0"
flutter: ">=1.22.2 <2.0.0"

@ -104,7 +104,8 @@ dependencies:
badges: ^1.1.4
# Hijri
hijri: ^2.0.0
# hijri: ^2.0.3
hijri_picker: ^2.0.0

Loading…
Cancel
Save