child Vaccines
parent
e14d619edd
commit
4009aed000
@ -0,0 +1,235 @@
|
||||
import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/ChildVaccines/add_newchild_page.dart';
|
||||
import 'package:diplomaticquarterapp/pages/base/base_view.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';
|
||||
import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
||||
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||
|
||||
import 'new_text_Field.dart';
|
||||
|
||||
enum Gender { Male, Female, NON }
|
||||
enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON }
|
||||
|
||||
class AddNewChildPage extends StatefulWidget {
|
||||
@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;
|
||||
ChildVaccinesViewModel AddvancedModel = ChildVaccinesViewModel();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return AppScaffold(
|
||||
isShowAppBar: true,
|
||||
appBarTitle: "Vaccintion",
|
||||
body: SingleChildScrollView(
|
||||
physics: ScrollPhysics(),
|
||||
child: Container(
|
||||
margin: EdgeInsets.all(12),
|
||||
child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
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,
|
||||
children: [
|
||||
Text(
|
||||
"Gender:",
|
||||
textAlign: TextAlign.end,
|
||||
|
||||
),
|
||||
],),
|
||||
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());
|
||||
});
|
||||
|
||||
// bloodDetails.
|
||||
},
|
||||
),
|
||||
),
|
||||
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();
|
||||
|
||||
// bloodDetails.
|
||||
},
|
||||
),
|
||||
)
|
||||
],) ,
|
||||
),
|
||||
//==========
|
||||
SizedBox(
|
||||
height: 6,
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Date Of Birth::",
|
||||
textAlign: TextAlign.end,
|
||||
|
||||
),
|
||||
],),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
DatePicker.showDatePicker(context,
|
||||
showTitleActions: true,
|
||||
minTime: DateTime(
|
||||
DateTime.now().year, DateTime.now().month - 1, 1),
|
||||
maxTime: DateTime.now(), onConfirm: (date) {
|
||||
setState(() {
|
||||
// widget.startDay = date;
|
||||
});
|
||||
},
|
||||
// currentTime: widget.startDay,
|
||||
// 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( DateUtil.yearMonthDay(DateTime.now())
|
||||
//getStartDay()
|
||||
),
|
||||
Icon(
|
||||
Icons.calendar_today,
|
||||
color: Colors.black,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
//=========
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
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: () {
|
||||
// bloodDetails.city=_selectedHospital.toString();
|
||||
|
||||
// bloodDetails.
|
||||
},
|
||||
),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,239 @@
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class NumberTextInputFormatter extends TextInputFormatter {
|
||||
@override
|
||||
TextEditingValue formatEditUpdate(
|
||||
TextEditingValue oldValue, TextEditingValue newValue) {
|
||||
final int newTextLength = newValue.text.length;
|
||||
int selectionIndex = newValue.selection.end;
|
||||
int usedSubstringIndex = 0;
|
||||
final StringBuffer newText = StringBuffer();
|
||||
if (newTextLength >= 1) {
|
||||
newText.write('(');
|
||||
if (newValue.selection.end >= 1) selectionIndex++;
|
||||
}
|
||||
if (newTextLength >= 4) {
|
||||
newText.write(newValue.text.substring(0, usedSubstringIndex = 3) + ') ');
|
||||
if (newValue.selection.end >= 3) selectionIndex += 2;
|
||||
}
|
||||
if (newTextLength >= 7) {
|
||||
newText.write(newValue.text.substring(3, usedSubstringIndex = 6) + '-');
|
||||
if (newValue.selection.end >= 6) selectionIndex++;
|
||||
}
|
||||
if (newTextLength >= 11) {
|
||||
newText.write(newValue.text.substring(6, usedSubstringIndex = 10) + ' ');
|
||||
if (newValue.selection.end >= 10) selectionIndex++;
|
||||
}
|
||||
// Dump the rest.
|
||||
if (newTextLength >= usedSubstringIndex)
|
||||
newText.write(newValue.text.substring(usedSubstringIndex));
|
||||
return TextEditingValue(
|
||||
text: newText.toString(),
|
||||
selection: TextSelection.collapsed(offset: selectionIndex),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final _mobileFormatter = NumberTextInputFormatter();
|
||||
|
||||
class NewTextFields extends StatefulWidget {
|
||||
NewTextFields(
|
||||
{Key key,
|
||||
this.type,
|
||||
this.hintText,
|
||||
this.suffixIcon,
|
||||
this.autoFocus,
|
||||
this.onChanged,
|
||||
this.initialValue,
|
||||
this.minLines,
|
||||
this.maxLines,
|
||||
this.inputFormatters,
|
||||
this.padding,
|
||||
this.focus = false,
|
||||
this.maxLengthEnforced = true,
|
||||
this.suffixIconColor,
|
||||
this.inputAction,
|
||||
this.onSubmit,
|
||||
this.keepPadding = true,
|
||||
this.textCapitalization = TextCapitalization.none,
|
||||
this.controller,
|
||||
this.keyboardType,
|
||||
this.validator,
|
||||
this.borderOnlyError = false,
|
||||
this.onSaved,
|
||||
this.onSuffixTap,
|
||||
this.readOnly: false,
|
||||
this.maxLength,
|
||||
this.prefixIcon,
|
||||
this.bare = false,
|
||||
this.onTap,
|
||||
this.fontSize = 16.0,
|
||||
this.fontWeight = FontWeight.w700,
|
||||
this.autoValidate = false,
|
||||
this.hintColor,this.isEnabled=true})
|
||||
: super(key: key);
|
||||
|
||||
final String hintText;
|
||||
|
||||
// final String initialValue;
|
||||
final String type;
|
||||
final bool autoFocus;
|
||||
final IconData suffixIcon;
|
||||
final Color suffixIconColor;
|
||||
final Icon prefixIcon;
|
||||
final VoidCallback onTap;
|
||||
final TextEditingController controller;
|
||||
final TextInputType keyboardType;
|
||||
final FormFieldValidator validator;
|
||||
final Function onSaved;
|
||||
final Function onSuffixTap;
|
||||
final Function onChanged;
|
||||
final Function onSubmit;
|
||||
final bool readOnly;
|
||||
final int maxLength;
|
||||
final int minLines;
|
||||
final int maxLines;
|
||||
final bool maxLengthEnforced;
|
||||
final bool bare;
|
||||
final bool isEnabled;
|
||||
final TextInputAction inputAction;
|
||||
final double fontSize;
|
||||
final FontWeight fontWeight;
|
||||
final bool keepPadding;
|
||||
final TextCapitalization textCapitalization;
|
||||
final List<TextInputFormatter> inputFormatters;
|
||||
final bool autoValidate;
|
||||
final EdgeInsets padding;
|
||||
final bool focus;
|
||||
final bool borderOnlyError;
|
||||
final Color hintColor;
|
||||
final String initialValue;
|
||||
@override
|
||||
_NewTextFieldsState createState() => _NewTextFieldsState();
|
||||
}
|
||||
|
||||
class _NewTextFieldsState extends State<NewTextFields> {
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
bool focus = false;
|
||||
bool view = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusNode.addListener(() {
|
||||
setState(() {
|
||||
focus = _focusNode.hasFocus;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(NewTextFields oldWidget) {
|
||||
if (widget.focus) _focusNode.requestFocus();
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
bool _determineReadOnly() {
|
||||
if (widget.readOnly != null && widget.readOnly) {
|
||||
_focusNode.unfocus();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedContainer(
|
||||
duration: Duration(milliseconds: 300),
|
||||
decoration:BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.white),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 8),
|
||||
|
||||
child: TextFormField(
|
||||
enabled: widget.isEnabled,
|
||||
initialValue: widget.initialValue,
|
||||
keyboardAppearance: Theme.of(context).brightness,
|
||||
scrollPhysics: BouncingScrollPhysics(),
|
||||
autovalidate: widget.autoValidate,
|
||||
textCapitalization: widget.textCapitalization,
|
||||
onFieldSubmitted: widget.inputAction == TextInputAction.next
|
||||
? (widget.onSubmit != null
|
||||
? widget.onSubmit
|
||||
: (val) {
|
||||
_focusNode.nextFocus();
|
||||
})
|
||||
: widget.onSubmit,
|
||||
textInputAction: widget.inputAction,
|
||||
minLines: widget.minLines ?? 1,
|
||||
maxLines: widget.maxLines ?? 1,
|
||||
maxLengthEnforced: widget.maxLengthEnforced,
|
||||
onChanged: widget.onChanged,
|
||||
focusNode: _focusNode,
|
||||
maxLength: widget.maxLength ?? null,
|
||||
controller: widget.controller,
|
||||
keyboardType: widget.keyboardType,
|
||||
readOnly: _determineReadOnly(),
|
||||
obscureText: widget.type == "password" && !view ? true : false,
|
||||
autofocus: widget.autoFocus ?? false,
|
||||
validator: widget.validator,
|
||||
onSaved: widget.onSaved,
|
||||
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.body2
|
||||
.copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight),
|
||||
inputFormatters: widget.keyboardType == TextInputType.phone
|
||||
? <TextInputFormatter>[
|
||||
WhitelistingTextInputFormatter.digitsOnly,
|
||||
_mobileFormatter,
|
||||
]
|
||||
: widget.inputFormatters,
|
||||
decoration: InputDecoration(
|
||||
labelText: widget.hintText,
|
||||
labelStyle: TextStyle(color: Colors.black),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context)
|
||||
.errorColor
|
||||
.withOpacity(0.5),
|
||||
width: 1.0),
|
||||
borderRadius: BorderRadius.circular(12.0)),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context)
|
||||
.errorColor
|
||||
.withOpacity(0.5),
|
||||
width: 1.0),
|
||||
borderRadius: BorderRadius.circular(8.0)),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.white, width: 1.0),
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
disabledBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.white, width: 1.0),
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.white, width: 1.0),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue