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/ChildVaccines/add_newchild_page.dart

348 lines
13 KiB
Dart

4 years ago
import 'package:device_calendar/device_calendar.dart';
4 years ago
import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart';
4 years ago
import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/add_new_child_view_model.dart';
4 years ago
import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart';
4 years ago
import 'package:diplomaticquarterapp/pages/Blood/new_text_Field.dart';
4 years ago
import 'package:diplomaticquarterapp/pages/ChildVaccines/add_newchild_page.dart';
4 years ago
import 'package:diplomaticquarterapp/pages/ChildVaccines/child_page.dart';
4 years ago
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
4 years ago
import 'package:diplomaticquarterapp/pages/medical/active_medications/DayCheckBoxDialog.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
4 years ago
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
4 years ago
4 years ago
4 years ago
enum Gender { Male, Female, NON }
enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON }
class AddNewChildPage extends StatefulWidget {
4 years ago
final int frequency;
final int days;
final String itemDescription;
4 years ago
String dateAdd;
4 years ago
List<DateTime> _scheduleList = List();
List<DayOfWeek> daysOfWeek = [
DayOfWeek.Monday,
DayOfWeek.Tuesday,
DayOfWeek.Wednesday,
DayOfWeek.Thursday,
DayOfWeek.Friday,
DayOfWeek.Saturday,
DayOfWeek.Sunday
];
DateTime startDay;
DateTime endDay;
//AddNewChildPage({Key key, this.frequency, this.days, this.itemDescription}) : super(key: key);
AddNewChildPage({Key key, this.frequency, this.days, this.itemDescription}) {
4 years ago
startDay = DateTime.now();
endDay =
DateTime.now(); //endDay = DateTime.now().add(Duration(days: days));
int hour = 24; //(24 / frequency).round();
4 years ago
int durations = 24 ~/ hour;
for (int count = 0; count < durations; count++) {
_scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day, (hour * count)));
}
}
4 years ago
@override
_AddNewChildPageState createState() => _AddNewChildPageState();
}
class _AddNewChildPageState extends State<AddNewChildPage> {
int tappedIndex;
int checkedValue;
@override
void initState() {
super.initState();
tappedIndex = -1;
}
TextEditingController _firstTextController = TextEditingController();
TextEditingController _secondTextController = TextEditingController();
TextEditingController _notesTextController = TextEditingController();
BeneficiaryType beneficiaryType = BeneficiaryType.NON;
Gender gender = Gender.Male;
4 years ago
//ChildVaccinesViewModel addvancedModel = ChildVaccinesViewModel();
List_BabyInformationModel addvancedModel = List_BabyInformationModel();
4 years ago
CreateNewBaby newChild=CreateNewBaby();
List_UserInformationModel informationModel =List_UserInformationModel();
4 years ago
@override
Widget build(BuildContext context) {
4 years ago
return BaseView<AddNewChildViewModel>(
builder: (_,model,w)=> AppScaffold(
isShowAppBar: true,
appBarTitle: "Vaccintion",
body: SingleChildScrollView(
physics: ScrollPhysics(),
child: Container(
margin: EdgeInsets.all(12),
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 50,
4 years ago
),
4 years ago
Texts(
"Add the child's information below to recieve the schedule of vaccinations.", //+model.user.firstName,
textAlign: TextAlign.center,
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: "First Name",
controller: _firstTextController,
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: "Second Name",
controller: _secondTextController,
),
SizedBox(
height: 12,
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
4 years ago
children: [
4 years ago
Text(
"Gender:",
textAlign: TextAlign.end,
4 years ago
),
4 years ago
],
),
Container(
height: MediaQuery.of(context).size.height * 0.12,
width: double.infinity,
padding: EdgeInsets.all(12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: MediaQuery.of(context).size.height * 0.12,
width: 170,
child: SecondaryButton(
textColor:
checkedValue == 1 ? Colors.white : Colors.black,
color: checkedValue == 1 ? Colors.red : Colors.white,
label: "Male",
//
onTap: () {
// bloodDetails.city=_selectedHospital.toString();
setState(() {
checkedValue = 1;
print("checkedValue=" + checkedValue.toString());
});
4 years ago
4 years ago
// bloodDetails.
},
),
4 years ago
),
4 years ago
Container(
height: MediaQuery.of(context).size.height * 0.12,
width: 170,
child: SecondaryButton(
textColor:
checkedValue == 2 ? Colors.white : Colors.black,
color: checkedValue == 2 ? Colors.red : Colors.white,
label: "Female",
//
onTap: () {
setState(() {
checkedValue = 2;
print("checkedValue=" + checkedValue.toString());
});
// bloodDetails.city=_selectedHospital.toString();
4 years ago
4 years ago
// bloodDetails.
},
),
)
],
4 years ago
),
4 years ago
),
//==========
SizedBox(
height: 6,
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Date Of Birth::",
textAlign: TextAlign.end,
),
],
),
InkWell(
onTap: () {
DatePicker.showDatePicker(
context,
4 years ago
showTitleActions: true,
4 years ago
// minTime: DateTime(
// DateTime.now().year, DateTime.now().month - 1, 1),
4 years ago
minTime: DateTime(1, 1, 1),
4 years ago
maxTime: DateTime.now(),
4 years ago
onConfirm: (date) {
4 years ago
setState(() {
4 years ago
widget.startDay = date;
4 years ago
});
},
4 years ago
currentTime: widget.startDay,
4 years ago
// locale: projectViewModel.localeType
);
},
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(//getStartDay()
// DateUtil.yearMonthDay(DateTime.now())
getStartDay()
),
Icon(
Icons.calendar_today,
color: Colors.black,
)
],
),
4 years ago
),
),
4 years ago
SizedBox(
height: 12,
),
//=========
],
),
4 years ago
),
),
4 years ago
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: "Add",
//
onTap: () {
4 years ago
4 years ago
newChild.babyName =
_firstTextController.text + " " + _secondTextController.text;
newChild.gender = checkedValue.toString();
newChild.strDOB=getStartDay() ;
4 years ago
newChild.alertBy=addvancedModel.alertBy;
4 years ago
newChild.createdBy=informationModel.createdBy ;
newChild.editedBy=informationModel.createdBy;
newChild.tempValue=true;
4 years ago
// newChild.userID=46013;//informationModel.userID;
4 years ago
newChild.isLogin=true;
4 years ago
//newChild.tokenID='qMgbP94U23RkXtWWT0Sw==';
//'ZBGoQFUG50eQJd6Y7u1ykA==';
4 years ago
model.getNewBabyOrders(newChild: newChild);
4 years ago
4 years ago
//DateTime.now();//DateUtil.convertStringToDate(getStartDay());
// addvancedModel.alertBy = 2;
// addvancedModel.alertBy = addvancedModel.babyID;
// addvancedModel.genderDescription =
// checkedValue == 1 ? "Male" : "Female";
// addvancedModel.patientID = addvancedModel.patientID;
// addvancedModel.userID = addvancedModel.userID;
// // advanceModel.fileNumber = _fileTextController.text;
// // advanceModel.hospitalsModel = _selectedHospital;
// // advanceModel.note = _notesTextController.text;
// // advanceModel.email = email ?? model.user.emailAddress;
// // advanceModel.amount = amount;
// // bloodDetails.city=_selectedHospital.toString();
AppToast.showSuccessToast(message: "Record Added");
//============
Navigator.push(
context,
FadePage(
page: ChildPage(),
//ChildPage(babyInformationModelList:model.BabyInformationModelList)
// HospitalsPage(
// findusHospitalModelList: model.FindusHospitalModelList,
// )
),
);
//==============
// bloodDetails.
},
),
),
4 years ago
),
);
}
4 years ago
4 years ago
String getStartDay() {
return "${DateUtil.getMonth(widget.startDay.month)} ${widget.startDay.day}, ${widget.startDay.year}";
}
String getEndDay() {
return "${DateUtil.getMonth(widget.endDay.month)} ${widget.endDay.day}, ${widget.endDay.year}";
}
String getDateTime(DateTime dateTime) {
return '${dateTime.hour}:${dateTime.minute}';
}
String getDays() {
String days = "";
widget.daysOfWeek.forEach((element) {
days += "${DateUtil.getDay(element)},";
});
return days;
}
void confirmSelectDayDialog() {
showDialog(
context: context,
child: DayCheckBoxDialog(
title: 'Select Day',
selectedDaysOfWeek: widget.daysOfWeek,
onValueSelected: (value) {
setState(() {
widget.daysOfWeek = value;
});
},
),
);
}
4 years ago
}