show and hide form based on patient type
parent
79055145c6
commit
37880b2630
@ -0,0 +1,160 @@
|
||||
import 'package:doctor_app_flutter/models/patient_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class DynamicElements extends StatefulWidget {
|
||||
PatientModel _patientSearchFormValues;
|
||||
DynamicElements(this._patientSearchFormValues);
|
||||
@override
|
||||
_DynamicElementsState createState() => _DynamicElementsState();
|
||||
}
|
||||
|
||||
class _DynamicElementsState extends State<DynamicElements> {
|
||||
TextEditingController _toDateController = new TextEditingController();
|
||||
TextEditingController _fromDateController = new TextEditingController();
|
||||
void _presentDatePicker(id) {
|
||||
showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2019),
|
||||
lastDate: DateTime.now(),
|
||||
).then((pickedDate) {
|
||||
if (pickedDate == null) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
print(id);
|
||||
var selectedDate = DateFormat.yMd().format(pickedDate);
|
||||
|
||||
if (id == '_selectedFromDate') {
|
||||
_fromDateController.text = selectedDate;
|
||||
} else {
|
||||
_toDateController.text = selectedDate;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (ctx, constraints) {
|
||||
var smallScreenSize = 660;
|
||||
bool isSmallScreen = constraints.maxWidth <= smallScreenSize;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
'From',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
controller: _fromDateController,
|
||||
decoration: InputDecoration(
|
||||
hintText: '3/11/2020',
|
||||
hintStyle: TextStyle(
|
||||
fontSize:
|
||||
isSmallScreen ? 14 : constraints.maxWidth * 0.024),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
borderSide: BorderSide(color: Hexcolor('#CCCCCC')),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderSide:
|
||||
BorderSide(color: Theme.of(context).primaryColor),
|
||||
)
|
||||
//BorderRadius.all(Radius.circular(20));
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter some text';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onTap: () {
|
||||
_presentDatePicker('_selectedFromDate');
|
||||
},
|
||||
onSaved: (value) {
|
||||
widget._patientSearchFormValues.From = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
'TO',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
controller: _toDateController,
|
||||
decoration: InputDecoration(
|
||||
hintText: '3/11/2020',
|
||||
hintStyle: TextStyle(
|
||||
fontSize:
|
||||
isSmallScreen ? 14 : constraints.maxWidth * 0.024),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
borderSide: BorderSide(color: Hexcolor('#CCCCCC')),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderSide:
|
||||
BorderSide(color: Theme.of(context).primaryColor),
|
||||
)
|
||||
//BorderRadius.all(Radius.circular(20));
|
||||
),
|
||||
onTap: () {
|
||||
_presentDatePicker('_selectedToDate');
|
||||
},
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter some text';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onSaved: (value) {
|
||||
widget._patientSearchFormValues.To = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
border: Border.all(color: Theme.of(context).primaryColor),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Checkbox(
|
||||
value: true,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
onChanged: (bool newValue) {}),
|
||||
Text('Only Arrived Patient',
|
||||
style: TextStyle(
|
||||
fontSize: isSmallScreen
|
||||
? 18
|
||||
: constraints.maxWidth * 0.018)),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue