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.
254 lines
9.6 KiB
Dart
254 lines
9.6 KiB
Dart
import 'package:device_calendar/device_calendar.dart';
|
|
import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart';
|
|
import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart';
|
|
import 'package:diplomaticquarterapp/core/model/childvaccines/create_new_user_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';
|
|
import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart';
|
|
import 'package:diplomaticquarterapp/pages/Blood/new_text_Field.dart';
|
|
import 'package:diplomaticquarterapp/pages/ChildVaccines/add_newchild_page.dart';
|
|
import 'package:diplomaticquarterapp/pages/ChildVaccines/child_page.dart';
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
import 'package:diplomaticquarterapp/pages/medical/active_medications/DayCheckBoxDialog.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
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';
|
|
|
|
enum Gender { Male, Female, NON }
|
|
|
|
class AddNewChildPage extends StatefulWidget {
|
|
String dateAdd;
|
|
|
|
DateTime startDay;
|
|
DateTime endDay;
|
|
|
|
AddNewChildPage() {
|
|
startDay = DateTime.now();
|
|
endDay = DateTime.now();
|
|
}
|
|
|
|
@override
|
|
_AddNewChildPageState createState() => _AddNewChildPageState();
|
|
}
|
|
|
|
class _AddNewChildPageState extends State<AddNewChildPage> {
|
|
int checkedValue;
|
|
|
|
TextEditingController _firstTextController = TextEditingController();
|
|
TextEditingController _secondTextController = TextEditingController();
|
|
Gender gender = Gender.Male;
|
|
CreateNewUser_New newUserChild = CreateNewUser_New();
|
|
|
|
CreateNewBaby newChild = CreateNewBaby();
|
|
|
|
String firstName = "";
|
|
String secondName = "";
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BaseView<AddNewChildViewModel>(
|
|
builder: (_, model, w) => AppScaffold(
|
|
isShowAppBar: true,
|
|
appBarTitle: TranslationBase.of(context).vaccination,
|
|
body: SingleChildScrollView(
|
|
physics: ScrollPhysics(),
|
|
child: Container(
|
|
margin: EdgeInsets.all(12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
height: 25,
|
|
),
|
|
Texts(TranslationBase.of(context).addInstructions),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
NewTextFields(
|
|
hintText: TranslationBase.of(context).firstName,
|
|
controller: _firstTextController,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
firstName = value;
|
|
});
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
NewTextFields(
|
|
hintText: TranslationBase.of(context).lastName,
|
|
controller: _secondTextController,
|
|
onChanged: (value) {
|
|
secondName = value;
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
TranslationBase.of(context).gender + " :",
|
|
textAlign: TextAlign.end,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 15,
|
|
),
|
|
Container(
|
|
height: 60,
|
|
width: double.infinity,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
child: AnimatedContainer(
|
|
duration: Duration(milliseconds: 400),
|
|
height: 60,
|
|
color: Colors.white,
|
|
child: SecondaryButton(
|
|
textColor:
|
|
checkedValue == 1 ? Colors.white : Colors.black,
|
|
color:
|
|
checkedValue == 1 ? Colors.red : Colors.white,
|
|
label: TranslationBase.of(context).male,
|
|
onTap: () {
|
|
setState(() {
|
|
checkedValue = 1;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: AnimatedContainer(
|
|
duration: Duration(milliseconds: 400),
|
|
height: 60,
|
|
color: Colors.white,
|
|
child: SecondaryButton(
|
|
textColor:
|
|
checkedValue == 2 ? Colors.white : Colors.black,
|
|
color:
|
|
checkedValue == 2 ? Colors.red : Colors.white,
|
|
label: TranslationBase.of(context).female,
|
|
onTap: () {
|
|
setState(() {
|
|
checkedValue = 2;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
TranslationBase.of(context).dob + " :",
|
|
textAlign: TextAlign.end,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 8,
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
DatePicker.showDatePicker(
|
|
context,
|
|
showTitleActions: true,
|
|
minTime: DateTime(1, 1, 1),
|
|
maxTime: DateTime.now(),
|
|
onConfirm: (date) {
|
|
setState(() {
|
|
widget.startDay = date;
|
|
});
|
|
},
|
|
currentTime: widget.startDay,
|
|
);
|
|
},
|
|
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: [
|
|
Icon(
|
|
Icons.calendar_today,
|
|
color: Colors.black,
|
|
),
|
|
SizedBox(
|
|
width: 25,
|
|
),
|
|
Expanded(child: Texts(getStartDay())),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 25,
|
|
),
|
|
Container(
|
|
height: 60,
|
|
width: double.infinity,
|
|
child: SecondaryButton(
|
|
textColor: Colors.white,
|
|
color: Colors.grey[800],
|
|
disabled: (checkedValue == null ||
|
|
firstName.isEmpty ||
|
|
secondName.isEmpty),
|
|
label: TranslationBase.of(context).add,
|
|
onTap: () async {
|
|
newChild.babyName = _firstTextController.text +
|
|
" " +
|
|
_secondTextController.text;
|
|
newChild.gender = checkedValue.toString();
|
|
newChild.strDOB = widget.startDay.toIso8601String();
|
|
newChild.tempValue = true;
|
|
newChild.isLogin = true;
|
|
|
|
await model.createNewBabyOrders(newChild: newChild);
|
|
if (model.isAdded) {
|
|
AppToast.showSuccessToast(
|
|
message: TranslationBase.of(context).addedChild);
|
|
Navigator.pop(context, model.isAdded);
|
|
} else {
|
|
AppToast.showSuccessToast(message: model.error);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
// bottomSheet:
|
|
),
|
|
);
|
|
}
|
|
|
|
String getStartDay() {
|
|
return "${widget.startDay.day}-${widget.startDay.month}-${widget.startDay.year}";
|
|
}
|
|
}
|