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

Update kidsReport.dart

parent ae6d048c
...@@ -8,309 +8,104 @@ class KidsReportPage extends StatefulWidget { ...@@ -8,309 +8,104 @@ class KidsReportPage extends StatefulWidget {
KidsReportPage({required this.id}); KidsReportPage({required this.id});
@override @override
_kidsReportPageState createState() => _kidsReportPageState(id: id); _KidsReportPageState createState() => _KidsReportPageState(id: id);
} }
class _kidsReportPageState extends State<KidsReportPage> { class _KidsReportPageState extends State<KidsReportPage> {
// value set to false String id;
bool _valu1 = false; _KidsReportPageState({required this.id});
bool _valu2 = false;
bool _valu3 = false; List<String> dropdownValues = ['1', '2', '3', '4', '5'];
bool _valu4 = false;
bool _valu5 = false; 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 _formkey = GlobalKey<FormState>();
final _auth = FirebaseAuth.instance; final _auth = FirebaseAuth.instance;
String id;
_kidsReportPageState({required this.id});
// App widget tree
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('Student Report '), //IconButton title: Text('Student Report'),
), //AppBar ),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Center( child: Center(
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Form(
key: _formkey,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Table(
// decoration: BoxDecoration( columnWidths: {
// borderRadius: BorderRadius.circular(20), 0: FlexColumnWidth(3),
// boxShadow: [ 1: FlexColumnWidth(1),
// 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 children: dropdownMap.keys.map((String key) {
return TableRow(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(key),
), ),
SizedBox(height: 20), Padding(
Container( padding: const EdgeInsets.all(8.0),
// decoration: BoxDecoration( child: DropdownButtonFormField<String>(
// borderRadius: BorderRadius.circular(20), value: dropdownMap[key],
// boxShadow: [ items: dropdownValues.map((String value) {
// BoxShadow( return DropdownMenuItem<String>(
// color: Colors.black, value: value,
// offset: const Offset( child: Text(value),
// 3.0, );
// 3.0, }).toList(),
// ), //Offset onChanged: (String? value) {
// 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(() { setState(() {
_valu2 = value ?? false; dropdownMap[key] = value;
}); });
}, },
), //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( }).toList(),
// 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), 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( Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
TextButton( ElevatedButton(
onPressed: () async { onPressed: () async {
if (_formkey.currentState!.validate()) {
postDetailsToFirestore(context); postDetailsToFirestore(context);
}
}, },
style: child: Text('Save'),
TextButton.styleFrom(backgroundColor: Colors.green),
child: Text(
'Save',
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
height: 1,
), ),
), SizedBox(width: 15),
), ElevatedButton(
TextButton(
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
style: TextButton.styleFrom( child: Text('Cancel'),
backgroundColor: Colors.grey.shade200),
child: Text(
'Cancel',
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
height: 1,
),
), ),
)
], ],
), ),
], ],
), //Container ),
), //Padding ),
), //Center ),
), //SizedBox ),
),
); );
} }
...@@ -318,16 +113,18 @@ class _kidsReportPageState extends State<KidsReportPage> { ...@@ -318,16 +113,18 @@ class _kidsReportPageState extends State<KidsReportPage> {
FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance; FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance;
var user = _auth.currentUser; var user = _auth.currentUser;
CollectionReference ref = FirebaseFirestore.instance.collection('reports'); CollectionReference ref =
FirebaseFirestore.instance.collection('reports');
ref.doc(id).set({ // Constructing the data to be saved
"q1": _valu1, Map<String, dynamic> data = {};
'q2': _valu2, dropdownMap.forEach((key, value) {
'q3': _valu3, data[key] = value;
"q4": _valu4,
'q5': _valu5,
'sId': id,
}); });
data['sId'] = id;
await ref.doc(id).set(data);
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dialogType: DialogType.success, 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