Commit 45c024a8 authored by Uditha Prabhasha 's avatar Uditha Prabhasha

Update kidsReport.dart

parent ae6d048c
......@@ -8,309 +8,104 @@ class KidsReportPage extends StatefulWidget {
KidsReportPage({required this.id});
@override
_kidsReportPageState createState() => _kidsReportPageState(id: id);
_KidsReportPageState createState() => _KidsReportPageState(id: id);
}
class _kidsReportPageState extends State<KidsReportPage> {
// value set to false
bool _valu1 = false;
bool _valu2 = false;
bool _valu3 = false;
bool _valu4 = false;
bool _valu5 = false;
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,
};
final _formkey = GlobalKey<FormState>();
final _auth = FirebaseAuth.instance;
String id;
_kidsReportPageState({required this.id});
// App widget tree
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Student Report '), //IconButton
), //AppBar
title: Text('Student Report'),
),
body: SingleChildScrollView(
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(20),
// boxShadow: [
// BoxShadow(
// color: Colors.black,
// offset: const Offset(
// 3.0,
// 3.0,
// ), //Offset
// blurRadius: 10.0,
// spreadRadius: 2.0,
// ), //BoxShadow
// BoxShadow(
// color: Colors.white,
// offset: const Offset(0.0, 0.0),
// blurRadius: 0.0,
// spreadRadius: 0.0,
// ), //BoxShadow
// ],
// ), //BoxDecoration
/** CheckboxListTile Widget **/
child: CheckboxListTile(
title: const Text('Understanding'),
subtitle: const Text(
'Understanding commands, Answer questions, Keeping eye contact, Following rules.'),
// secondary: CircleAvatar(
// backgroundImage: NetworkImage(
// "https://pbs.twimg.com/profile_images/1304985167476523008/QNHrwL2q_400x400.jpg"), //NetworkImage
// radius: 20,
// ),
autofocus: false,
isThreeLine: true,
activeColor: Colors.green,
checkColor: Colors.white,
selected: _valu1,
value: _valu1,
onChanged: (bool? value) {
setState(() {
_valu1 = value ?? false;
});
},
), //CheckboxListTile
),
SizedBox(height: 20),
Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(20),
// boxShadow: [
// BoxShadow(
// color: Colors.black,
// offset: const Offset(
// 3.0,
// 3.0,
// ), //Offset
// blurRadius: 10.0,
// spreadRadius: 2.0,
// ), //BoxShadow
// BoxShadow(
// color: Colors.white,
// offset: const Offset(0.0, 0.0),
// blurRadius: 0.0,
// spreadRadius: 0.0,
// ), //BoxShadow
// ],
// ), //BoxDecoration
/** CheckboxListTile Widget **/
child: CheckboxListTile(
title: const Text('Movements'),
subtitle: const Text('Motor activities, Correct posture.'),
// secondary: CircleAvatar(
// backgroundImage: NetworkImage(
// "https://pbs.twimg.com/profile_images/1304985167476523008/QNHrwL2q_400x400.jpg"), //NetworkImage
// radius: 20,
// ),
autofocus: false,
isThreeLine: true,
activeColor: Colors.green,
checkColor: Colors.white,
selected: _valu2,
value: _valu2,
onChanged: (bool? value) {
setState(() {
_valu2 = value ?? false;
});
child: Form(
key: _formkey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Table(
columnWidths: {
0: FlexColumnWidth(3),
1: FlexColumnWidth(1),
},
), //CheckboxListTile
),
SizedBox(height: 20),
Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(20),
// boxShadow: [
// BoxShadow(
// color: Colors.black,
// offset: const Offset(
// 3.0,
// 3.0,
// ), //Offset
// blurRadius: 10.0,
// spreadRadius: 2.0,
// ), //BoxShadow
// BoxShadow(
// color: Colors.white,
// offset: const Offset(0.0, 0.0),
// blurRadius: 0.0,
// spreadRadius: 0.0,
// ), //BoxShadow
// ],
// ), //BoxDecoration
/** CheckboxListTile Widget **/
child: CheckboxListTile(
title: const Text('Manipulating'),
subtitle: const Text(
'Can build/create new things, Knows how to handle accessories'),
// secondary: CircleAvatar(
// backgroundImage: NetworkImage(
// "https://pbs.twimg.com/profile_images/1304985167476523008/QNHrwL2q_400x400.jpg"), //NetworkImage
// radius: 20,
// ),
autofocus: false,
isThreeLine: true,
activeColor: Colors.green,
checkColor: Colors.white,
selected: _valu3,
value: _valu3,
onChanged: (bool? value) {
setState(() {
_valu3 = value ?? false;
});
},
), //CheckboxListTile
),
SizedBox(height: 20),
Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(20),
// boxShadow: [
// BoxShadow(
// color: Colors.black,
// offset: const Offset(
// 3.0,
// 3.0,
// ), //Offset
// blurRadius: 10.0,
// spreadRadius: 2.0,
// ), //BoxShadow
// BoxShadow(
// color: Colors.white,
// offset: const Offset(0.0, 0.0),
// blurRadius: 0.0,
// spreadRadius: 0.0,
// ), //BoxShadow
// ],
// ), //BoxDecoration
/** CheckboxListTile Widget **/
child: CheckboxListTile(
title: const Text('Socializing'),
subtitle: const Text(
'Play with groups, Help each other, Friendly towards peers.'),
// secondary: CircleAvatar(
// backgroundImage: NetworkImage(
// "https://pbs.twimg.com/profile_images/1304985167476523008/QNHrwL2q_400x400.jpg"), //NetworkImage
// radius: 20,
// ),
autofocus: false,
isThreeLine: true,
activeColor: Colors.green,
checkColor: Colors.white,
selected: _valu4,
value: _valu4,
onChanged: (bool? value) {
setState(() {
_valu4 = value ?? false;
});
},
), //CheckboxListTile
),
// SizedBox(height: 20),
// Container(
// // decoration: BoxDecoration(
// // borderRadius: BorderRadius.circular(20),
// // boxShadow: [
// // BoxShadow(
// // color: Colors.black,
// // offset: const Offset(
// // 3.0,
// // 3.0,
// // ), //Offset
// // blurRadius: 10.0,
// // spreadRadius: 2.0,
// // ), //BoxShadow
// // BoxShadow(
// // color: Colors.white,
// // offset: const Offset(0.0, 0.0),
// // blurRadius: 0.0,
// // spreadRadius: 0.0,
// // ), //BoxShadow
// // ],
// // ), //BoxDecoration
// /** CheckboxListTile Widget **/
// child: CheckboxListTile(
// title: const Text('GeeksforGeeks'),
// subtitle: const Text(
// 'A computer science portal for geeks. Here you will find articles on all the technologies.'),
// // secondary: CircleAvatar(
// // backgroundImage: NetworkImage(
// // "https://pbs.twimg.com/profile_images/1304985167476523008/QNHrwL2q_400x400.jpg"), //NetworkImage
// // radius: 20,
// // ),
// autofocus: false,
// isThreeLine: true,
// activeColor: Colors.green,
// checkColor: Colors.white,
// selected: _valu5,
// value: _valu5,
// onChanged: (bool? value) {
// setState(() {
// _valu5 = value ?? false;
// });
// },
// ), //CheckboxListTile
// ),
// SizedBox(height: 20),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () async {
postDetailsToFirestore(context);
},
style:
TextButton.styleFrom(backgroundColor: Colors.green),
child: Text(
'Save',
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
height: 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),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
if (_formkey.currentState!.validate()) {
postDetailsToFirestore(context);
}
},
child: Text('Save'),
),
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
style: TextButton.styleFrom(
backgroundColor: Colors.grey.shade200),
child: Text(
'Cancel',
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
height: 1,
),
SizedBox(width: 15),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Cancel'),
),
)
],
),
],
), //Container
), //Padding
), //Center
), //SizedBox
],
),
],
),
),
),
),
),
);
}
......@@ -318,16 +113,18 @@ class _kidsReportPageState extends State<KidsReportPage> {
FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance;
var user = _auth.currentUser;
CollectionReference ref = FirebaseFirestore.instance.collection('reports');
CollectionReference ref =
FirebaseFirestore.instance.collection('reports');
ref.doc(id).set({
"q1": _valu1,
'q2': _valu2,
'q3': _valu3,
"q4": _valu4,
'q5': _valu5,
'sId': id,
// Constructing the data to be saved
Map<String, dynamic> data = {};
dropdownMap.forEach((key, value) {
data[key] = value;
});
data['sId'] = id;
await ref.doc(id).set(data);
AwesomeDialog(
context: context,
dialogType: DialogType.success,
......
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