Commit 7586ce3b authored by Uditha Prabhasha 's avatar Uditha Prabhasha

Update kidsReport.dart

parent 45c024a8
......@@ -15,17 +15,60 @@ class _KidsReportPageState extends State<KidsReportPage> {
String id;
_KidsReportPageState({required this.id});
List<String> dropdownValues = ['1', '2', '3', '4', '5'];
Map<String, String?> dropdownMap = {
'Understanding commands': null,
'Answer questions': null,
'Keeping eye contact.': null,
'Following rules.': null,
'Motor activities': null,
'Correct posture': null,
'Can build/create new things': null,
'Knows how to handle accessories': null,
List<String> dropdownValues = ['Select', '1', '2', '3', '4', '5'];
Map<String, String?> understandingDropdownMap = {
'Understanding commands': 'Select',
'Answer questions': 'Select',
'Keeping eye contact': 'Select',
'Following rules': 'Select',
};
Map<String, String?> movementsDropdownMap = {
'Motor activities': 'Select',
'Correct posture': 'Select',
};
Map<String, String?> manipulatingDropdownMap = {
'Can build/create new things': 'Select',
'Knows how to handle accessories': 'Select',
};
Map<String, String?> socializingDropdownMap = {
'Play with groups': 'Select',
'Help each other': 'Select',
'Friendly towards peers': 'Select',
'Close to teacher': 'Select',
};
Map<String, String?> speechDropdownMap = {
'Communicate well': 'Select',
'Like singing': 'Select',
};
Map<String, String?> recognitionDropdownMap = {
'Can express with pictures and words': 'Select',
'Identify shapes': 'Select',
'Knows Primary colors. s': 'Select',
'Identify basic objects in the environment': 'Select',
};
Map<String, String?> habitsDropdownMap = {
'Organized': 'Select',
'Have good eating habits': 'Select',
'Taking care of own needs': 'Select',
};
Map<String, String?> personalHygieneDropdownMap = {
'Stay clean': 'Select',
'Keep the workplace and environment clean': 'Select',
};
Map<String, String?> personalityDropdownMap = {
'Act according to the situation': 'Select',
'Finish allocated work': 'Select',
'More active': 'Select',
'Less active': 'Select',
};
final _formkey = GlobalKey<FormState>();
......@@ -44,62 +87,70 @@ class _KidsReportPageState extends State<KidsReportPage> {
child: Form(
key: _formkey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Table(
columnWidths: {
0: FlexColumnWidth(3),
1: FlexColumnWidth(1),
},
children: dropdownMap.keys.map((String key) {
return TableRow(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(key),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: DropdownButtonFormField<String>(
value: dropdownMap[key],
items: dropdownValues.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? value) {
setState(() {
dropdownMap[key] = value;
});
},
),
),
],
);
}).toList(),
SizedBox(height: 20),
_buildDropdownSection(
title: 'Understanding',
dropdownMap: understandingDropdownMap,
),
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
if (_formkey.currentState!.validate()) {
postDetailsToFirestore(context);
}
},
child: Text('Save'),
),
SizedBox(width: 15),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Cancel'),
),
],
_buildDropdownSection(
title: 'Movements',
dropdownMap: movementsDropdownMap,
),
SizedBox(height: 20),
_buildDropdownSection(
title: 'Manipulating',
dropdownMap: manipulatingDropdownMap,
),
SizedBox(height: 20),
_buildDropdownSection(
title: 'Socializing',
dropdownMap: socializingDropdownMap,
),
SizedBox(height: 20),
_buildDropdownSection(
title: 'Speech',
dropdownMap: speechDropdownMap,
),
SizedBox(height: 20),
_buildDropdownSection(
title: 'Recognition',
dropdownMap: recognitionDropdownMap,
),
SizedBox(height: 20),
_buildDropdownSection(
title: 'Habits',
dropdownMap: habitsDropdownMap,
),
SizedBox(height: 20),
_buildDropdownSection(
title: 'Personal Hygiene',
dropdownMap: personalHygieneDropdownMap,
),
SizedBox(height: 20),
_buildDropdownSection(
title: 'Personality',
dropdownMap: personalityDropdownMap,
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () async {
if (_formkey.currentState!.validate()) {
postDetailsToFirestore(context);
}
},
child: Text('Save'),
),
SizedBox(height: 10),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Cancel'),
),
SizedBox(height: 20),
],
),
),
......@@ -109,6 +160,71 @@ class _KidsReportPageState extends State<KidsReportPage> {
);
}
Widget _buildDropdownSection({
required String title,
required Map<String, String?> dropdownMap,
}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
title,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 10),
...dropdownMap.keys.map((String key) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
children: [
Expanded(
flex: 3,
child: Text(
key,
style: TextStyle(fontSize: 16),
),
),
Expanded(
flex: 1,
child: Container(
width: 100, // Adjust the width as needed
child: DropdownButton<String>(
value: dropdownMap[key],
icon: Icon(Icons.arrow_drop_down),
iconSize: 24,
elevation: 16,
style: TextStyle(color: Colors.black),
underline: Container(
height: 1,
color: Colors.green,
),
onChanged: (String? value) {
setState(() {
dropdownMap[key] = value;
});
},
items: dropdownValues.map<DropdownMenuItem<String>>(
(String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
},
).toList(),
),
),
),
],
),
);
}).toList(),
],
);
}
postDetailsToFirestore(context) async {
FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance;
var user = _auth.currentUser;
......@@ -118,7 +234,31 @@ class _KidsReportPageState extends State<KidsReportPage> {
// Constructing the data to be saved
Map<String, dynamic> data = {};
dropdownMap.forEach((key, value) {
understandingDropdownMap.forEach((key, value) {
data[key] = value;
});
movementsDropdownMap.forEach((key, value) {
data[key] = value;
});
manipulatingDropdownMap.forEach((key, value) {
data[key] = value;
});
socializingDropdownMap.forEach((key, value) {
data[key] = value;
});
speechDropdownMap.forEach((key, value) {
data[key] = value;
});
recognitionDropdownMap.forEach((key, value) {
data[key] = value;
});
habitsDropdownMap.forEach((key, value) {
data[key] = value;
});
personalHygieneDropdownMap.forEach((key, value) {
data[key] = value;
});
personalityDropdownMap.forEach((key, value) {
data[key] = value;
});
data['sId'] = id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment