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

Update kidsReport.dart

parent 45c024a8
...@@ -15,17 +15,60 @@ class _KidsReportPageState extends State<KidsReportPage> { ...@@ -15,17 +15,60 @@ class _KidsReportPageState extends State<KidsReportPage> {
String id; String id;
_KidsReportPageState({required this.id}); _KidsReportPageState({required this.id});
List<String> dropdownValues = ['1', '2', '3', '4', '5']; List<String> dropdownValues = ['Select', '1', '2', '3', '4', '5'];
Map<String, String?> dropdownMap = { Map<String, String?> understandingDropdownMap = {
'Understanding commands': null, 'Understanding commands': 'Select',
'Answer questions': null, 'Answer questions': 'Select',
'Keeping eye contact.': null, 'Keeping eye contact': 'Select',
'Following rules.': null, 'Following rules': 'Select',
'Motor activities': null, };
'Correct posture': null,
'Can build/create new things': null, Map<String, String?> movementsDropdownMap = {
'Knows how to handle accessories': null, '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>(); final _formkey = GlobalKey<FormState>();
...@@ -44,62 +87,70 @@ class _KidsReportPageState extends State<KidsReportPage> { ...@@ -44,62 +87,70 @@ class _KidsReportPageState extends State<KidsReportPage> {
child: Form( child: Form(
key: _formkey, key: _formkey,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Table( SizedBox(height: 20),
columnWidths: { _buildDropdownSection(
0: FlexColumnWidth(3), title: 'Understanding',
1: FlexColumnWidth(1), dropdownMap: understandingDropdownMap,
},
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), SizedBox(height: 20),
Row( _buildDropdownSection(
mainAxisAlignment: MainAxisAlignment.center, title: 'Movements',
children: [ dropdownMap: movementsDropdownMap,
ElevatedButton( ),
onPressed: () async { SizedBox(height: 20),
if (_formkey.currentState!.validate()) { _buildDropdownSection(
postDetailsToFirestore(context); title: 'Manipulating',
} dropdownMap: manipulatingDropdownMap,
}, ),
child: Text('Save'), SizedBox(height: 20),
), _buildDropdownSection(
SizedBox(width: 15), title: 'Socializing',
ElevatedButton( dropdownMap: socializingDropdownMap,
onPressed: () { ),
Navigator.pop(context); SizedBox(height: 20),
}, _buildDropdownSection(
child: Text('Cancel'), 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> { ...@@ -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 { postDetailsToFirestore(context) async {
FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance; FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance;
var user = _auth.currentUser; var user = _auth.currentUser;
...@@ -118,7 +234,31 @@ class _KidsReportPageState extends State<KidsReportPage> { ...@@ -118,7 +234,31 @@ class _KidsReportPageState extends State<KidsReportPage> {
// Constructing the data to be saved // Constructing the data to be saved
Map<String, dynamic> data = {}; 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[key] = value;
}); });
data['sId'] = id; 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