Commit 47ccb2f3 authored by Uditha Prabhasha 's avatar Uditha Prabhasha

update prabasha

parent 3a228a79
No preview for this file type
......@@ -195,9 +195,9 @@
},
{
"name": "image_picker",
"rootUri": "file:///Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker-1.0.7",
"rootUri": "file:///Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker-0.8.9",
"packageUri": "lib/",
"languageVersion": "3.0"
"languageVersion": "2.18"
},
{
"name": "image_picker_android",
......@@ -362,7 +362,7 @@
"languageVersion": "3.0"
}
],
"generated": "2024-01-15T19:08:05.177861Z",
"generated": "2024-02-07T12:20:09.439018Z",
"generator": "pub",
"generatorVersion": "3.0.1"
}
......@@ -131,9 +131,9 @@ http_parser
file:///Users/avishkanew/.pub-cache/hosted/pub.dev/http_parser-4.0.2/
file:///Users/avishkanew/.pub-cache/hosted/pub.dev/http_parser-4.0.2/lib/
image_picker
3.0
file:///Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker-1.0.7/
file:///Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker-1.0.7/lib/
2.18
file:///Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker-0.8.9/
file:///Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker-0.8.9/lib/
image_picker_android
3.0
file:///Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_android-0.8.9+3/
......@@ -236,6 +236,6 @@ file:///Users/avishkanew/.pub-cache/hosted/pub.dev/vector_math-2.1.4/
file:///Users/avishkanew/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/
jema_app
3.0
file:///Users/avishkanew/Desktop/Jema%20Kids%20App/monitoring-and-recommendations-for-early-childhood-development/
file:///Users/avishkanew/Desktop/Jema%20Kids%20App/monitoring-and-recommendations-for-early-childhood-development/lib/
file:///Users/avishkanew/Desktop/Avishk678/monitoring-and-recommendations-for-early-childhood-development/
file:///Users/avishkanew/Desktop/Avishk678/monitoring-and-recommendations-for-early-childhood-development/lib/
2
......@@ -9,7 +9,7 @@ firebase_auth_web=/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth_web-
firebase_core=/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/
firebase_core_web=/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core_web-2.10.0/
flutter_plugin_android_lifecycle=/Users/avishkanew/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.17/
image_picker=/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker-1.0.7/
image_picker=/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker-0.8.9/
image_picker_android=/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_android-0.8.9+3/
image_picker_for_web=/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_for_web-2.2.0/
image_picker_ios=/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.9/
......
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore-4.13.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth-4.15.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/","native_build":true,"dependencies":[]},{"name":"image_picker_ios","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.9/","native_build":true,"dependencies":[]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore-4.13.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth-4.15.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/","native_build":true,"dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.17/","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_android-0.8.9+3/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore-4.13.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"file_selector_macos","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/file_selector_macos-0.9.3+3/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth-4.15.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/","native_build":true,"dependencies":[]},{"name":"image_picker_macos","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_macos-0.2.1+1/","native_build":false,"dependencies":["file_selector_macos"]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","native_build":true,"dependencies":[]}],"linux":[{"name":"file_selector_linux","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.2+1/","native_build":true,"dependencies":[]},{"name":"image_picker_linux","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.1+1/","native_build":false,"dependencies":["file_selector_linux"]}],"windows":[{"name":"cloud_firestore","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore-4.13.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"file_selector_windows","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/file_selector_windows-0.9.3+1/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth-4.15.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/","native_build":true,"dependencies":[]},{"name":"image_picker_windows","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_windows-0.2.1+1/","native_build":false,"dependencies":["file_selector_windows"]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","native_build":true,"dependencies":[]}],"web":[{"name":"cloud_firestore_web","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore_web-3.8.10/","dependencies":["firebase_core_web"]},{"name":"firebase_auth_web","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth_web-5.8.12/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core_web-2.10.0/","dependencies":[]},{"name":"image_picker_for_web","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_for_web-2.2.0/","dependencies":[]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"file_selector_linux","dependencies":[]},{"name":"file_selector_macos","dependencies":[]},{"name":"file_selector_windows","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios","image_picker_linux","image_picker_macos","image_picker_windows"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]},{"name":"image_picker_linux","dependencies":["file_selector_linux"]},{"name":"image_picker_macos","dependencies":["file_selector_macos"]},{"name":"image_picker_windows","dependencies":["file_selector_windows"]},{"name":"rive_common","dependencies":[]}],"date_created":"2024-01-16 00:38:05.238148","version":"3.10.1"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore-4.13.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth-4.15.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/","native_build":true,"dependencies":[]},{"name":"image_picker_ios","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.9/","native_build":true,"dependencies":[]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore-4.13.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth-4.15.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/","native_build":true,"dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.17/","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_android-0.8.9+3/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore-4.13.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"file_selector_macos","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/file_selector_macos-0.9.3+3/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth-4.15.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/","native_build":true,"dependencies":[]},{"name":"image_picker_macos","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_macos-0.2.1+1/","native_build":false,"dependencies":["file_selector_macos"]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","native_build":true,"dependencies":[]}],"linux":[{"name":"file_selector_linux","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.2+1/","native_build":true,"dependencies":[]},{"name":"image_picker_linux","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.1+1/","native_build":false,"dependencies":["file_selector_linux"]}],"windows":[{"name":"cloud_firestore","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore-4.13.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"file_selector_windows","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/file_selector_windows-0.9.3+1/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth-4.15.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core-2.24.2/","native_build":true,"dependencies":[]},{"name":"image_picker_windows","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_windows-0.2.1+1/","native_build":false,"dependencies":["file_selector_windows"]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","native_build":true,"dependencies":[]}],"web":[{"name":"cloud_firestore_web","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/cloud_firestore_web-3.8.10/","dependencies":["firebase_core_web"]},{"name":"firebase_auth_web","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_auth_web-5.8.12/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/firebase_core_web-2.10.0/","dependencies":[]},{"name":"image_picker_for_web","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/image_picker_for_web-2.2.0/","dependencies":[]},{"name":"rive_common","path":"/Users/avishkanew/.pub-cache/hosted/pub.dev/rive_common-0.2.7/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"file_selector_linux","dependencies":[]},{"name":"file_selector_macos","dependencies":[]},{"name":"file_selector_windows","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios","image_picker_linux","image_picker_macos","image_picker_windows"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]},{"name":"image_picker_linux","dependencies":["file_selector_linux"]},{"name":"image_picker_macos","dependencies":["file_selector_macos"]},{"name":"image_picker_windows","dependencies":["file_selector_windows"]},{"name":"rive_common","dependencies":[]}],"date_created":"2024-02-07 16:20:09.507","version":"3.10.1"}
\ No newline at end of file
......@@ -4,19 +4,41 @@ import 'package:flutter/material.dart';
import 'package:jema_app/teacherchat.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:jema_app/teacherhome.dart';
import 'package:pie_chart/pie_chart.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Attendance extends StatelessWidget {
import 'ChatScreen.dart';
import 'TeacherProfile.dart';
class Attendance extends StatefulWidget {
@override
_AttendanceState createState() => _AttendanceState();
}
class _AttendanceState extends State<Attendance> {
late User? user;
late final Stream<QuerySnapshot> _usersStream;
Attendance() {
int absCount = 0;
int preCount = 0;
@override
void initState() {
super.initState();
user = FirebaseAuth.instance.currentUser;
initializeStreams();
getAllStudentCountPresentAbs();
}
Map<String, double> dataMap = {
"Present": 0,
"Absent": 0,
};
void initializeStreams() {
_usersStream = FirebaseFirestore.instance
.collection('classroom')
.where('userId', isEqualTo: user?.uid)
.collection('students')
.where('user', isEqualTo: user?.uid)
.snapshots();
}
......@@ -131,13 +153,22 @@ class Attendance extends StatelessWidget {
const SizedBox(width: 2),
SizedBox(
width: 30,
child: TextField(
decoration: InputDecoration(
labelText: '06',
border: OutlineInputBorder(),
),
),
),
child: FutureBuilder<String>(
future: getMaleStudentCount(
'Male', 0),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
// Future is still loading, show a loading indicator
return CircularProgressIndicator();
} else if (snapshot.hasError) {
// Error occurred while fetching data
return Text('0');
} else {
return Text(' ' +
snapshot.data.toString());
}
})),
],
),
),
......@@ -177,12 +208,22 @@ class Attendance extends StatelessWidget {
const SizedBox(width: 2),
SizedBox(
width: 30,
child: TextField(
decoration: InputDecoration(
labelText: '06',
border: OutlineInputBorder(),
),
),
child: FutureBuilder<String>(
future: getMaleStudentCount(
'Female', 0),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
// Future is still loading, show a loading indicator
return CircularProgressIndicator();
} else if (snapshot.hasError) {
// Error occurred while fetching data
return Text('0');
} else {
return Text(' ' +
snapshot.data.toString());
}
}),
),
],
),
......@@ -224,8 +265,20 @@ class Attendance extends StatelessWidget {
),
),
const SizedBox(width: 3),
Text(
'12',
FutureBuilder<String>(
future: getAllStudentCount(0),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
// Future is still loading, show a loading indicator
return CircularProgressIndicator();
} else if (snapshot.hasError) {
// Error occurred while fetching data
return Text('0');
} else {
return Text(
snapshot.data.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 16,
......@@ -233,7 +286,10 @@ class Attendance extends StatelessWidget {
fontWeight: FontWeight.w600,
height: 0.06,
),
),
);
}
},
)
],
),
),
......@@ -308,13 +364,22 @@ class Attendance extends StatelessWidget {
const SizedBox(width: 2),
SizedBox(
width: 30,
child: TextField(
decoration: InputDecoration(
labelText: '06',
border: OutlineInputBorder(),
),
),
),
child: FutureBuilder<String>(
future: getMaleStudentCount(
'Male', 1),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
// Future is still loading, show a loading indicator
return CircularProgressIndicator();
} else if (snapshot.hasError) {
// Error occurred while fetching data
return Text('0');
} else {
return Text(' ' +
snapshot.data.toString());
}
})),
],
),
),
......@@ -354,13 +419,22 @@ class Attendance extends StatelessWidget {
const SizedBox(width: 2),
SizedBox(
width: 30,
child: TextField(
decoration: InputDecoration(
labelText: '06',
border: OutlineInputBorder(),
),
),
),
child: FutureBuilder<String>(
future: getMaleStudentCount(
'Female', 1),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
// Future is still loading, show a loading indicator
return CircularProgressIndicator();
} else if (snapshot.hasError) {
// Error occurred while fetching data
return Text('0');
} else {
return Text(' ' +
snapshot.data.toString());
}
})),
],
),
),
......@@ -401,8 +475,22 @@ class Attendance extends StatelessWidget {
),
),
const SizedBox(width: 3),
Text(
'12',
FutureBuilder<String>(
future: getAllStudentCount(1),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
// Future is still loading, show a loading indicator
return CircularProgressIndicator();
} else if (snapshot.hasError) {
// Error occurred while fetching data
return Text('0');
} else {
// Data loaded successfully, display it
return Text(
snapshot.data.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 16,
......@@ -410,6 +498,9 @@ class Attendance extends StatelessWidget {
fontWeight: FontWeight.w600,
height: 0.06,
),
);
}
},
),
],
),
......@@ -516,282 +607,41 @@ class Attendance extends StatelessWidget {
),
Center(
child: Container(
width: 150,
height: 150,
width: 300,
height: 250,
child: Stack(
children: [
Positioned(
left: 0,
top: 150,
child: Transform(
transform: Matrix4.identity()
..translate(0.0, 0.0)
..rotateZ(-1.4),
child: Container(
width: 150,
height: 150,
decoration: ShapeDecoration(
color: Color.fromARGB(
255, 34, 177, 16),
shape: OvalBorder(),
),
),
),
),
Positioned(
left: 0,
top: 150,
child: Transform(
transform: Matrix4.identity()
..translate(0.0, 0.0)
..rotateZ(-1.5),
child: Container(
width: 150,
height: 150,
decoration: ShapeDecoration(
color: Color.fromARGB(
255, 180, 124, 13),
shape: OvalBorder(),
),
),
),
),
Positioned(
left: 0,
top: 150,
child: Transform(
transform: Matrix4.identity()
..translate(0.0, 0.0)
..rotateZ(-1.7),
child: Container(
width: 150,
height: 150,
decoration: ShapeDecoration(
color: Color.fromARGB(
255, 38, 138, 232),
shape: OvalBorder(),
),
),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(
10, 30, 0, 0),
child: Container(
width: 323,
height: 75,
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(12),
),
shadows: [
BoxShadow(
color: Color(0x1E7090B0),
blurRadius: 40,
offset: Offset(0, 18),
spreadRadius: 0,
)
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
height: 37,
child: Column(
mainAxisSize:
MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets
.fromLTRB(
0, 20, 0, 0),
child: Container(
width: double.infinity,
height: 10,
child: Row(
mainAxisSize:
MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment
.start,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Container(
width: 8,
height: 8,
decoration:
ShapeDecoration(
color: Color(
0xFF53ACFF),
shape:
OvalBorder(),
),
),
const SizedBox(
width: 5),
SizedBox(
width: 55,
height: 10,
child: Text(
'Present',
style:
TextStyle(
color: Color(
0xFF21205B),
fontSize: 14,
fontFamily:
'Poppins',
fontWeight:
FontWeight
.w500,
height: 0.07,
letterSpacing:
-0.28,
),
),
),
const SizedBox(
height: 1),
Text(
'75%',
style: TextStyle(
color: Color(
0xFF2B3674),
fontSize: 18,
fontFamily:
'Poppins',
fontWeight:
FontWeight
.w600,
height: 0.06,
letterSpacing:
-0.36,
),
),
],
),
),
),
],
),
),
Container(
height: 37,
child: Column(
mainAxisSize:
MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Container(
width: double.infinity,
height: 10,
child: Row(
mainAxisSize:
MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Container(
width: 8,
height: 8,
decoration:
ShapeDecoration(
color: Color(
0xFF6AD2FF),
shape:
OvalBorder(),
),
),
const SizedBox(
width: 5),
SizedBox(
width: 51,
height: 10,
child: Text(
'Absent',
style: TextStyle(
color: Color(
0xFF21205B),
fontSize: 14,
fontFamily:
'Poppins',
fontWeight:
FontWeight
.w500,
height: 0.07,
letterSpacing:
-0.28,
),
),
),
const SizedBox(
height: 2),
SizedBox(
width: 37,
height: 16,
child: Text(
'25%',
style: TextStyle(
color: Color(
0xFF2B3674),
fontSize: 18,
fontFamily:
'Poppins',
PieChart(
dataMap: dataMap,
chartType: ChartType.disc,
chartRadius:
MediaQuery.of(context)
.size
.width /
2.2,
colorList: [
Color.fromARGB(
255, 83, 172, 255),
Color.fromARGB(
255, 106, 210, 255),
],
legendOptions: LegendOptions(
showLegendsInRow: true,
legendPosition:
LegendPosition.bottom,
showLegends: true,
legendTextStyle: TextStyle(
fontWeight:
FontWeight
.w600,
height: 0.06,
letterSpacing:
-0.36,
),
),
),
],
),
),
],
),
),
Transform(
transform: Matrix4.identity()
..translate(0.0, 0.0)
..rotateZ(-1.57),
child: Container(
width: 47,
decoration: ShapeDecoration(
shape:
RoundedRectangleBorder(
side: BorderSide(
width: 1,
strokeAlign: BorderSide
.strokeAlignCenter,
color:
Color(0xFFF4F7FE),
),
),
FontWeight.bold),
),
chartValuesOptions:
ChartValuesOptions(
showChartValueBackground:
true,
showChartValues: true,
showChartValuesInPercentage:
true,
showChartValuesOutside: false,
),
),
],
......@@ -827,12 +677,28 @@ class Attendance extends StatelessWidget {
),
],
selectedItemColor: Colors.blue,
onTap: (index) {
onTap: (index) async {
final prefs = await SharedPreferences.getInstance();
String rool = prefs.get('rool').toString();
// Handle bottom navigation item tap
if (index == 0) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherHomePage()),
);
}
if (index == 1) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherChatPage()),
MaterialPageRoute(builder: (context) => ChatScreen()),
);
}
if (index == 2) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherProfilePage(uid: user?.uid)),
);
}
},
......@@ -840,4 +706,70 @@ class Attendance extends StatelessWidget {
),
);
}
Stream<QuerySnapshot> getStudentsStream(String genderFilter, int isCheck) {
return FirebaseFirestore.instance
.collection('students')
.where('user', isEqualTo: user?.uid)
.where('Sex', isEqualTo: genderFilter)
.where('isCheck', isEqualTo: isCheck)
.snapshots();
}
Future<String> getMaleStudentCount(String sex, int isCheck) async {
try {
QuerySnapshot snapshot = await getStudentsStream(sex, isCheck).first;
return snapshot.size.toString();
} catch (e) {
print('Error getting male student count: $e');
return '0';
}
}
Stream<QuerySnapshot> getAllStudentsStream(int isCheck) {
return FirebaseFirestore.instance
.collection('students')
.where('user', isEqualTo: user?.uid)
.where('isCheck', isEqualTo: isCheck)
.snapshots();
}
Future<String> getAllStudentCount(int isCheck) async {
try {
QuerySnapshot snapshot = await getAllStudentsStream(isCheck).first;
print('size' + snapshot.size.toString());
return snapshot.size.toString();
} catch (e) {
print('Error getting male student count: $e');
return '0';
}
}
Stream<QuerySnapshot> getAllStudentsStreams() {
return FirebaseFirestore.instance
.collection('students')
.where('user', isEqualTo: user?.uid)
.snapshots();
}
Future<void> getAllStudentCountPresentAbs() async {
try {
QuerySnapshot snapshot2 = await getAllStudentsStreams().first;
QuerySnapshot snapshot = await getAllStudentsStream(0).first;
QuerySnapshot snapshotAbs = await getAllStudentsStream(1).first;
preCount = snapshot.size;
absCount = snapshotAbs.size;
var pre = (snapshot.size / snapshot2.size) * 100;
var abs = (snapshotAbs.size / snapshot2.size) * 100;
setState(() {
dataMap["Present"] = pre.round().toDouble();
dataMap["Absent"] = abs.round().toDouble();
});
print("ss" + preCount.round().toString());
} catch (e) {
print('Error getting male student count: $e');
}
}
}
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
class ChatScreen extends StatefulWidget {
@override
_ChatScreenState createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
final TextEditingController _textController = TextEditingController();
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
final FirebaseAuth _auth = FirebaseAuth.instance;
late User? _user;
File? _imageFile;
String? _voiceFilePath;
@override
void initState() {
super.initState();
_user = _auth.currentUser;
}
void _sendMessage() async {
try {
if (_textController.text.isNotEmpty ||
_imageFile != null ||
_voiceFilePath != null) {
String message = _textController.text.trim();
_textController.clear();
String imageUrl = '';
String voiceUrl = '';
if (_imageFile != null) {
imageUrl = await _uploadFile(_imageFile!);
}
if (_voiceFilePath != null) {
voiceUrl = await _uploadFile(File(_voiceFilePath!));
}
await _firestore.collection('messages').add({
'text': message,
'createdAt': Timestamp.now(),
'user': _user!.uid,
'imageUrl': imageUrl,
'voiceUrl': voiceUrl,
});
_imageFile = null;
_voiceFilePath = null;
}
} catch (e, stackTrace) {
print('Error sending message: $e');
print('Stack trace: $stackTrace');
// Handle the error gracefully, e.g., show a snackbar or display an error message
}
}
Future<String> _uploadFile(File file) async {
Reference storageReference = FirebaseStorage.instance
.ref()
.child('uploads/${DateTime.now().millisecondsSinceEpoch}');
UploadTask uploadTask = storageReference.putFile(file);
await uploadTask.whenComplete(() => null);
return await storageReference.getDownloadURL();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Chat'),
),
body: Column(
children: <Widget>[
Expanded(
child: StreamBuilder(
stream: _firestore
.collection('messages')
.orderBy('createdAt', descending: true)
.snapshots(),
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
}
return ListView.builder(
reverse: true,
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
var message = snapshot.data!.docs[index];
bool isCurrentUser = message['user'] == _user!.uid;
// Perform null check before accessing properties using []
String? text = (message.data()
as Map<String, dynamic>)['text'] as String?;
String? imageUrl = (message.data()
as Map<String, dynamic>)['imageUrl'] as String?;
String? voiceUrl = (message.data()
as Map<String, dynamic>)['voiceUrl'] as String?;
return MessageBubble(
message: text ?? '',
imageUrl: imageUrl,
voiceUrl: voiceUrl,
isCurrentUser: isCurrentUser,
);
},
);
},
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
IconButton(
icon: Icon(Icons.photo),
onPressed: () async {
XFile? image = await ImagePicker()
.pickImage(source: ImageSource.gallery);
if (image != null) {
setState(() {
_imageFile = File(image.path);
});
}
},
),
Expanded(
child: TextField(
controller: _textController,
decoration: InputDecoration(
labelText: 'Send a message...',
),
),
),
IconButton(
icon: Icon(Icons.send),
onPressed: _sendMessage,
),
],
),
),
],
),
);
}
}
class MessageBubble extends StatelessWidget {
final String message;
final String? imageUrl;
final String? voiceUrl;
final bool isCurrentUser;
const MessageBubble({
Key? key,
required this.message,
required this.isCurrentUser,
this.imageUrl,
this.voiceUrl,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
child: Align(
alignment: isCurrentUser ? Alignment.centerRight : Alignment.centerLeft,
child: Container(
decoration: BoxDecoration(
color: isCurrentUser ? Colors.blue : Colors.green,
borderRadius: BorderRadius.circular(12.0),
),
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (imageUrl != null &&
Uri.parse(imageUrl!)
.isAbsolute) // Check if imageUrl is not null and a valid network URL
Image.network(
imageUrl!,
width: 200,
),
if (message.isNotEmpty) Text(message),
],
),
),
),
);
}
}
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/ChatScreen.dart';
import 'package:jema_app/teacherchat.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:jema_app/teacherhome.dart';
import 'TeacherProfile.dart';
......@@ -17,8 +19,8 @@ class CheckKidsPage extends StatelessWidget {
void initializeStreams() {
_usersStream = FirebaseFirestore.instance
.collection('classroom')
.where('userId', isEqualTo: user?.uid)
.collection('students')
.where('user', isEqualTo: user?.uid)
.snapshots();
}
......@@ -106,22 +108,20 @@ class CheckKidsPage extends StatelessWidget {
itemCount: itemCount,
itemBuilder: (context, index) {
var document = snapshot.data!.docs[index];
var className = document['className'];
var className = document['Firstname'];
var image = document['image'];
var isCheck = document['isCheck'];
return Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 0, 0),
child: InkWell(
onTap: () {
print(document);
if (isCheck == 1) {
updateStudentAge(document.id, 0);
} else {
// Handle view class button press
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ClassroomViewPage(
documents: className,
),
),
);
updateStudentAge(document.id, 1);
}
},
child: SingleChildScrollView(
child: Column(
......@@ -140,8 +140,9 @@ class CheckKidsPage extends StatelessWidget {
height: 74.24,
decoration: ShapeDecoration(
image: DecorationImage(
image: AssetImage(
"lib/assets/Ellipse 8.png"),
image: NetworkImage(
image,
),
fit: BoxFit.fill,
),
shape: OvalBorder(),
......@@ -155,7 +156,11 @@ class CheckKidsPage extends StatelessWidget {
width: 74.24,
height: 74.24,
decoration: ShapeDecoration(
color: Color(0x4CB8B4B4),
color: isCheck == 1
? Color.fromARGB(
72, 219, 219, 219)
: Color.fromARGB(
71, 218, 49, 11),
shape: OvalBorder(),
),
),
......@@ -167,7 +172,11 @@ class CheckKidsPage extends StatelessWidget {
width: 59.40,
padding: const EdgeInsets.all(4.95),
decoration: ShapeDecoration(
color: Color(0xDD7D8088),
color: isCheck == 1
? Color.fromARGB(
160, 28, 136, 224)
: Color.fromARGB(
71, 218, 49, 11),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(4.95),
......@@ -229,20 +238,26 @@ class CheckKidsPage extends StatelessWidget {
onTap: (index) {
switch (index) {
case 0:
// Navigate to Home
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherHomePage()),
);
break;
case 1:
// Navigate to Chat
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherChatPage()),
MaterialPageRoute(builder: (context) => ChatScreen()),
);
break;
case 2:
// Navigate to Profile
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherProfilePage()),
MaterialPageRoute(
builder: (context) => TeacherProfilePage(
uid: user?.uid,
)),
);
break;
}
......@@ -251,4 +266,19 @@ class CheckKidsPage extends StatelessWidget {
),
);
}
void updateStudentAge(String documentId, int check) async {
try {
await FirebaseFirestore.instance
.collection('students')
.doc(documentId)
.update({
'isCheck': check,
// Add more fields to update if needed
});
print('Document updated successfully!');
} catch (e) {
print('Error updating document: $e');
}
}
}
import 'dart:io';
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cross_file/src/types/interface.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/ChatScreen.dart';
import 'package:jema_app/teacherchat.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:jema_app/teacherhome.dart';
import 'TeacherProfile.dart';
class ChildrenActiPhone extends StatelessWidget {
late User? user;
String image;
late final Stream<QuerySnapshot> _usersStream;
ChildrenActiPhone({required this.image}) {
user = FirebaseAuth.instance.currentUser;
initializeStreams();
}
void initializeStreams() {
_usersStream = FirebaseFirestore.instance
.collection('students')
.where('user', isEqualTo: user?.uid)
.snapshots();
}
@override
Widget build(BuildContext context) {
final pickedFile = File(image);
return WillPopScope(
onWillPop: () async {
// Disable the back button press
return false;
},
child: Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.of(context).pop();
},
),
actions: [
Text(
'Photo ',
style: TextStyle(
color: Color(0xFF554994),
fontSize: 24,
fontFamily: 'Poppins',
fontWeight: FontWeight.w700,
height: 0.04,
letterSpacing: -0.96,
),
)
],
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
height: 400,
child:
Image(image: FileImage(pickedFile), fit: BoxFit.cover)),
), //)
SizedBox(height: 30),
Text(
'Select Kids ',
style: TextStyle(
color: Color(0xFF21205B),
fontSize: 16,
fontFamily: 'Poppins',
fontWeight: FontWeight.w500,
height: 0.06,
),
),
SizedBox(height: 10),
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: _usersStream,
builder: (context, snapshot) {
print("--------------------------------------");
print(snapshot.data!.docs.length);
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
}
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
var itemCount = snapshot.data!.docs.length;
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
4, // Adjust this value to control the number of items per row
crossAxisSpacing:
8.0, // Adjust spacing between items horizontally
mainAxisSpacing:
8.0, // Adjust spacing between items vertically
),
itemCount: itemCount,
itemBuilder: (context, index) {
var document = snapshot.data!.docs[index];
var className = document['Firstname'];
var image = document['image'];
var isCheck = document['isCheck'];
return Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 0, 0),
child: InkWell(
onTap: () {
print(document);
if (isCheck == 1) {
updateStudentAge(document.id, 0);
} else {
// Handle view class button press
updateStudentAge(document.id, 1);
}
},
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: 74.24,
height: 74.24,
child: Stack(
children: [
Positioned(
left: 0,
top: 0,
child: Container(
width: 74.24,
height: 74.24,
decoration: ShapeDecoration(
image: DecorationImage(
image: NetworkImage(
image,
),
fit: BoxFit.fill,
),
shape: OvalBorder(),
),
),
),
Positioned(
left: 0,
top: 0,
child: Container(
width: 74.24,
height: 74.24,
decoration: ShapeDecoration(
color: isCheck == 1
? Color.fromARGB(
72, 219, 219, 219)
: Color.fromARGB(
71, 218, 49, 11),
shape: OvalBorder(),
),
),
),
Positioned(
left: 7.42,
top: 51.97,
child: Container(
width: 59.40,
padding: const EdgeInsets.all(4.95),
decoration: ShapeDecoration(
color: isCheck == 1
? Color.fromARGB(
160, 28, 136, 224)
: Color.fromARGB(
71, 218, 49, 11),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(4.95),
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Text(
className,
style: TextStyle(
color: Colors.white,
fontSize: 12.37,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
height: 0.08,
),
),
],
),
),
),
],
),
)
],
),
),
),
);
},
);
},
),
),
Center(
child: Container(
decoration: BoxDecoration(
border: Border.all(
color:
Colors.grey), // You can customize the color and width
borderRadius: BorderRadius.circular(
8), // You can customize the border radius
),
child: TextButton(
onPressed: () => {_showTimePicker(context)},
child: Text(
'Add Activity',
style: TextStyle(
color: Color(0xFF554994),
fontSize: 16,
fontFamily: 'Poppins',
fontWeight: FontWeight.w500,
height: 0.06,
),
),
),
))
],
),
),
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.chat),
label: 'Chat',
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'Profile',
),
],
selectedItemColor: Colors.blue,
onTap: (index) {
switch (index) {
case 0:
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherHomePage()),
);
break;
case 1:
// Navigate to Chat
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ChatScreen()),
);
break;
case 2:
// Navigate to Profile
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherProfilePage(
uid: user?.uid,
)),
);
break;
}
},
),
),
);
}
void updateStudentAge(String documentId, int check) async {
try {
await FirebaseFirestore.instance
.collection('students')
.doc(documentId)
.update({
'isCheck': check,
// Add more fields to update if needed
});
print('Document updated successfully!');
} catch (e) {
print('Error updating document: $e');
}
}
Future<void> _showTimePicker(BuildContext context) async {
final TimeOfDay? pickedTime = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
if (pickedTime != null) {
_uploadImage(File(image), context).then((imageUrl) {
_saveActivity(imageUrl, context);
});
print('Selected Time: ${pickedTime.format(context)}');
}
}
Future<String> _uploadImage(File imageFile, context) async {
try {
Reference storageReference = FirebaseStorage.instance
.ref()
.child('activity_images/${DateTime.now().millisecondsSinceEpoch}');
UploadTask uploadTask = storageReference.putFile(imageFile);
await uploadTask.whenComplete(() => null);
String imageUrl = await storageReference.getDownloadURL();
return imageUrl;
} catch (e) {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
title: 'Error',
desc: 'An error occurred while uploading your image!',
btnOkOnPress: () {
Navigator.pop(context);
},
)..show();
return '';
}
}
Future<void> _saveActivity(String imageUrl, context) async {
try {
await FirebaseFirestore.instance.collection('activities').add({
'imageUrl': imageUrl,
'timestamp': Timestamp.now(),
'user': user!.uid,
// Add more fields as needed
});
AwesomeDialog(
context: context,
dialogType: DialogType.success,
animType: AnimType.rightSlide,
title: 'Activity Saved',
desc: 'Your activity has been saved successfully!',
btnOkOnPress: () {
Navigator.pop(context);
},
)..show();
} catch (e) {
print('Error saving activity: $e');
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
title: 'Error',
desc: 'An error occurred while saving your activity!',
btnOkOnPress: () {
Navigator.pop(context);
},
)..show();
}
}
}
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:jema_app/Attendance.dart';
import 'package:jema_app/ChildrenVideo.dart';
import 'package:jema_app/ReportKids.dart';
import 'CheckKids.dart';
import 'ChildrenActiPhone.dart';
import 'ChildrenHomePage.dart';
import 'addstudent.dart';
class ChildrenActivity extends StatelessWidget {
late Future<List<DocumentSnapshot>> students = getStudentData();
final TextEditingController _searchController = TextEditingController();
late StreamController<String> _searchTermController;
late User? user;
ChildrenActivity({super.key}) {
user = FirebaseAuth.instance.currentUser;
}
Future<List<DocumentSnapshot>> getStudentData() async {
QuerySnapshot querySnapshot =
await FirebaseFirestore.instance.collection('students').get();
return querySnapshot.docs;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
actions: [
Text(
'Activities ',
style: TextStyle(
color: Color(0xFF554994),
fontSize: 24,
fontFamily: 'Poppins',
fontWeight: FontWeight.w700,
height: 0.04,
letterSpacing: -0.96,
),
)
],
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 40, 20, 20),
child: Container(
width: 293,
height: 44,
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
shadows: [
BoxShadow(
color: Color(0x3F000000),
blurRadius: 4,
offset: Offset(0, 1),
spreadRadius: 0,
),
],
),
child: TextField(
controller: _searchController,
onChanged: (value) {
_searchTermController.add(value);
},
decoration: InputDecoration(
hintText: 'Search',
border: InputBorder.none,
icon: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.search),
),
suffixIcon: Icon(Icons.mic),
contentPadding: EdgeInsets.all(8),
),
),
),
),
SizedBox(height: 10),
GridView.count(
crossAxisCount: 2,
childAspectRatio: (1 / 0.6),
shrinkWrap: true,
children: [
GestureDetector(
onTap: () {
openCamera(context);
},
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
width: 170,
height: 85,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'lib/assets/ac1.png'), // Replace 'path/to/your/image.jpg' with your image path
fit: BoxFit
.cover, // Adjust this according to your needs
)),
),
),
),
GestureDetector(
onTap: () {
openVideoRecorder(context);
},
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
width: 170,
height: 85,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'lib/assets/ac2.png'), // Replace 'path/to/your/image.jpg' with your image path
fit: BoxFit
.cover, // Adjust this according to your needs
)),
),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => ChildrenActivity(),
));
},
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
width: 170,
height: 85,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'lib/assets/ac3.png'), // Replace 'path/to/your/image.jpg' with your image path
fit: BoxFit
.cover, // Adjust this according to your needs
)),
),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => CheckKidsPage(),
));
},
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
width: 170,
height: 85,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'lib/assets/ac4.png'), // Replace 'path/to/your/image.jpg' with your image path
fit: BoxFit
.cover, // Adjust this according to your needs
)),
),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => ReportKidsPage(),
));
},
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
width: 170,
height: 85,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'lib/assets/ac5.png'), // Replace 'path/to/your/image.jpg' with your image path
fit: BoxFit
.cover, // Adjust this according to your needs
)),
),
),
),
]),
],
),
),
),
);
}
void openCamera(context) async {
final picker = ImagePicker();
final pickedFile = await picker.pickImage(source: ImageSource.camera);
if (pickedFile != null) {
String imagePath = pickedFile.path;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChildrenActiPhone(image: imagePath)),
);
// Use the picked file, for example, display it in an Image widget
// Image.file(File(pickedFile.path))
print('Image selected: ${pickedFile.path}');
} else {
print('No image selected');
}
}
void openVideoRecorder(context) async {
final picker = ImagePicker();
final pickedFile = await picker.pickVideo(source: ImageSource.camera);
if (pickedFile != null) {
String imagePath = pickedFile.path;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChildrenVideo(video: imagePath)),
);
// Use the picked file, for example, display it in a Video widget
// Video.file(File(pickedFile.path))
print('Video selected: ${pickedFile.path}');
} else {
print('No video selected');
}
}
}
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
......@@ -5,24 +7,43 @@ import 'package:jema_app/teacherchat.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'childrenProfile.dart';
class ChildrenHomePage extends StatelessWidget {
late User? user;
final TextEditingController _searchController = TextEditingController();
late StreamController<String> _searchTermController;
late final Stream<QuerySnapshot> _usersStream;
ChildrenHomePage() {
user = FirebaseAuth.instance.currentUser;
initializeStreams();
_searchTermController = StreamController<String>.broadcast();
_usersStream = FirebaseFirestore.instance
.collection('students')
.where('user', isEqualTo: user?.uid)
.snapshots();
_searchTermController.stream.listen((searchTerm) {
_usersStream = searchStudents(searchTerm);
});
}
@override
void dispose() {
_searchController.dispose();
_searchTermController.close();
}
void initializeStreams() {
_usersStream = FirebaseFirestore.instance
.collection('classroom')
.where('userId', isEqualTo: user?.uid)
.collection('students')
.where('user', isEqualTo: user?.uid)
.snapshots();
}
@override
void initState() {}
@override
Widget build(BuildContext context) {
return WillPopScope(
......@@ -88,6 +109,10 @@ class ChildrenHomePage extends StatelessWidget {
],
),
child: TextField(
controller: _searchController,
onChanged: (value) {
_searchTermController.add(value);
},
decoration: InputDecoration(
hintText: 'Search',
border: InputBorder.none,
......@@ -120,8 +145,9 @@ class ChildrenHomePage extends StatelessWidget {
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
var document = snapshot.data!.docs[index];
var name = document['className'];
var name = document['Firstname'];
var className = document['className'];
var image = document['image'];
return Padding(
padding: const EdgeInsets.all(8.0),
......@@ -138,15 +164,14 @@ class ChildrenHomePage extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
CrossAxisAlignment.start,
children: [
Container(
width: 77,
height: 77,
decoration: ShapeDecoration(
image: DecorationImage(
image: AssetImage(
"lib/assets/tsignup1.png"),
image: NetworkImage(image),
fit: BoxFit.fill,
),
shape: OvalBorder(),
......@@ -185,7 +210,7 @@ class ChildrenHomePage extends StatelessWidget {
padding:
const EdgeInsets.all(8.0),
child: Text(
'Class Room 01',
className,
style: TextStyle(
color: Colors.black,
fontSize: 14,
......@@ -203,11 +228,16 @@ class ChildrenHomePage extends StatelessWidget {
),
),
const SizedBox(width: 70),
InkWell(
Row(
mainAxisAlignment: MainAxisAlignment
.end, // Aligns children to the right
children: [
GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ChildrenProfilePage(),
builder: (_) =>
ChildrenProfilePage(document),
),
);
},
......@@ -231,9 +261,11 @@ class ChildrenHomePage extends StatelessWidget {
fontWeight: FontWeight.w600,
height: 1,
),
textAlign: TextAlign.center,
textAlign: TextAlign.right,
),
),
),
],
),
],
),
......@@ -247,8 +279,15 @@ class ChildrenHomePage extends StatelessWidget {
],
),
),
),
);
}
Stream<QuerySnapshot> searchStudents(String searchTerm) {
return FirebaseFirestore.instance
.collection('students')
.where('user', isEqualTo: user?.uid)
.where('FirstName', isGreaterThanOrEqualTo: searchTerm)
.snapshots();
}
}
import 'dart:io';
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cross_file/src/types/interface.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/teacherchat.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:video_player/video_player.dart';
import 'TeacherProfile.dart';
class ChildrenVideo extends StatelessWidget {
late User? user;
late String video;
late VideoPlayerController videoPlayerController;
late final Stream<QuerySnapshot> _usersStream;
ChildrenVideo({required this.video}) {
user = FirebaseAuth.instance.currentUser;
initializeStreams();
}
Future<void> initializeStreams() async {
_usersStream = FirebaseFirestore.instance
.collection('students')
.where('user', isEqualTo: user?.uid)
.snapshots();
videoPlayerController = VideoPlayerController.file(File(video));
await videoPlayerController.initialize();
await videoPlayerController
.setLooping(true); // Optional: Set looping to true
await videoPlayerController.play();
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
// Disable the back button press
return false;
},
child: Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.of(context).pop();
},
),
actions: [
Text(
'Video ',
style: TextStyle(
color: Color(0xFF554994),
fontSize: 24,
fontFamily: 'Poppins',
fontWeight: FontWeight.w700,
height: 0.04,
letterSpacing: -0.96,
),
)
],
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
height: 400,
child: AspectRatio(
aspectRatio: videoPlayerController.value.aspectRatio,
child: VideoPlayer(videoPlayerController),
),
),
), //)
SizedBox(height: 30),
Text(
'Select Kids ',
style: TextStyle(
color: Color(0xFF21205B),
fontSize: 16,
fontFamily: 'Poppins',
fontWeight: FontWeight.w500,
height: 0.06,
),
),
SizedBox(height: 10),
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: _usersStream,
builder: (context, snapshot) {
print("--------------------------------------");
print(snapshot.data!.docs.length);
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
}
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
var itemCount = snapshot.data!.docs.length;
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
4, // Adjust this value to control the number of items per row
crossAxisSpacing:
8.0, // Adjust spacing between items horizontally
mainAxisSpacing:
8.0, // Adjust spacing between items vertically
),
itemCount: itemCount,
itemBuilder: (context, index) {
var document = snapshot.data!.docs[index];
var className = document['Firstname'];
var image = document['image'];
var isCheck = document['isCheck'];
return Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 0, 0),
child: InkWell(
onTap: () {
print(document);
if (isCheck == 1) {
updateStudentAge(document.id, 0);
} else {
// Handle view class button press
updateStudentAge(document.id, 1);
}
},
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: 74.24,
height: 74.24,
child: Stack(
children: [
Positioned(
left: 0,
top: 0,
child: Container(
width: 74.24,
height: 74.24,
decoration: ShapeDecoration(
image: DecorationImage(
image: NetworkImage(
image,
),
fit: BoxFit.fill,
),
shape: OvalBorder(),
),
),
),
Positioned(
left: 0,
top: 0,
child: Container(
width: 74.24,
height: 74.24,
decoration: ShapeDecoration(
color: isCheck == 1
? Color.fromARGB(
72, 219, 219, 219)
: Color.fromARGB(
71, 218, 49, 11),
shape: OvalBorder(),
),
),
),
Positioned(
left: 7.42,
top: 51.97,
child: Container(
width: 59.40,
padding: const EdgeInsets.all(4.95),
decoration: ShapeDecoration(
color: isCheck == 1
? Color.fromARGB(
160, 28, 136, 224)
: Color.fromARGB(
71, 218, 49, 11),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(4.95),
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Text(
className,
style: TextStyle(
color: Colors.white,
fontSize: 12.37,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
height: 0.08,
),
),
],
),
),
),
],
),
)
],
),
),
),
);
},
);
},
),
),
Center(
child: Container(
decoration: BoxDecoration(
border: Border.all(
color:
Colors.grey), // You can customize the color and width
borderRadius: BorderRadius.circular(
8), // You can customize the border radius
),
child: TextButton(
onPressed: () => {_showTimePicker(context)},
child: Text(
'Add Activity',
style: TextStyle(
color: Color(0xFF554994),
fontSize: 16,
fontFamily: 'Poppins',
fontWeight: FontWeight.w500,
height: 0.06,
),
),
),
))
],
),
),
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.chat),
label: 'Chat',
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'Profile',
),
],
selectedItemColor: Colors.blue,
onTap: (index) {
switch (index) {
case 0:
// Navigate to Home
break;
case 1:
// Navigate to Chat
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherChatPage()),
);
break;
case 2:
// Navigate to Profile
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherProfilePage(
uid: user?.uid,
)),
);
break;
}
},
),
),
);
}
void updateStudentAge(String documentId, int check) async {
try {
await FirebaseFirestore.instance
.collection('students')
.doc(documentId)
.update({
'isCheck': check,
// Add more fields to update if needed
});
print('Document updated successfully!');
} catch (e) {
print('Error updating document: $e');
}
}
Future<void> _showTimePicker(BuildContext context) async {
final TimeOfDay? pickedTime = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
if (pickedTime != null) {
_uploadImage(File(video), context).then((videoUrl) {
_saveActivity(videoUrl, context);
});
print('Selected Time: ${pickedTime.format(context)}');
}
}
Future<String> _uploadImage(File videoFile, context) async {
try {
Reference storageReference = FirebaseStorage.instance
.ref()
.child('activity_video/${DateTime.now().millisecondsSinceEpoch}');
UploadTask uploadTask = storageReference.putFile(videoFile);
await uploadTask.whenComplete(() => null);
String videoUrl = await storageReference.getDownloadURL();
return videoUrl;
} catch (e) {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
title: 'Error',
desc: 'An error occurred while uploading your image!',
btnOkOnPress: () {
Navigator.pop(context);
},
)..show();
return '';
}
}
Future<void> _saveActivity(String videoUrl, context) async {
try {
await FirebaseFirestore.instance.collection('activities').add({
'videoUrl': videoUrl,
'timestamp': Timestamp.now(),
'user': user!.uid,
// Add more fields as needed
});
AwesomeDialog(
context: context,
dialogType: DialogType.success,
animType: AnimType.rightSlide,
title: 'Activity Saved',
desc: 'Your activity has been saved successfully!',
btnOkOnPress: () {
Navigator.pop(context);
},
)..show();
} catch (e) {
print('Error saving activity: $e');
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
title: 'Error',
desc: 'An error occurred while saving your activity!',
btnOkOnPress: () {
Navigator.pop(context);
},
)..show();
}
}
}
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/parentHome.dart';
import 'package:jema_app/teacherhome.dart';
class ParentLoginPage extends StatefulWidget {
const ParentLoginPage({Key? key, required this.backgroundColor})
: super(key: key);
final Color backgroundColor;
@override
_ParentLoginPage createState() =>
_ParentLoginPage(backgroundColor: backgroundColor);
}
class _ParentLoginPage extends State<ParentLoginPage> {
_ParentLoginPage({Key? key, required this.backgroundColor});
final Color backgroundColor;
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: IconButton(
icon: const Icon(
Icons.arrow_back,
color: Color.fromARGB(255, 0, 0, 0),
),
onPressed: () {
Navigator.pop(context);
},
),
),
body: Container(
color: backgroundColor,
child: SafeArea(
child: SingleChildScrollView(
child: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.all(10.0),
child: Image.asset(
'lib/assets/teachersignin.png',
width: 290,
height: 250,
),
),
const SizedBox(height: 10),
const Text(
'Welcome back',
style: TextStyle(
color: Colors.purple,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: TextFormField(
controller: emailController,
style: const TextStyle(color: Colors.black),
decoration: InputDecoration(
labelText: 'Email',
labelStyle: TextStyle(color: Colors.black),
fillColor: Colors.grey[200],
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide.none,
),
suffixIcon: Icon(Icons.email, color: Colors.black),
),
validator: (value) {
RegExp regex = new RegExp(r'^.{6,}$');
if (value!.isEmpty) {
return "Password cannot be empty";
}
if (!regex.hasMatch(value)) {
return ("please enter valid password min. 6 character");
} else {
return null;
}
},
),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: TextFormField(
controller: passwordController,
style: const TextStyle(color: Colors.black),
obscureText: true,
decoration: InputDecoration(
labelText: 'Password',
labelStyle: TextStyle(color: Colors.black),
fillColor: Colors.grey[200],
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide.none,
),
suffixIcon: Icon(Icons.lock, color: Colors.black),
),
),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
signIn(emailController.text, passwordController.text,
context);
},
onLongPress: () {},
child: Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: Colors.green,
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'Login',
style: TextStyle(color: Colors.black),
),
),
),
),
style: ElevatedButton.styleFrom(
primary: Colors.transparent,
elevation: 0,
),
),
],
),
),
),
),
),
),
);
}
void route(context) {
User? user = FirebaseAuth.instance.currentUser;
var kk = FirebaseFirestore.instance
.collection('users')
.doc(user!.uid)
.get()
.then((DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists) {
if (documentSnapshot.get('rool') == "parent") {
AwesomeDialog(
context: context,
dialogType: DialogType.success,
animType: AnimType.rightSlide,
title: 'Successfully login',
desc: ' Go to your home page',
btnCancelOnPress: () {},
btnOkOnPress: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
ParentHomePage(documentSnapshot.get('phoneNo')),
),
);
},
)..show();
print("login teacher");
} else {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => TeacherHomePage(),
),
);
}
} else {
AwesomeDialog(
context: context,
dialogType: DialogType.warning,
animType: AnimType.rightSlide,
title: 'Faild login',
desc: 'No user found for that email',
btnOkOnPress: () {},
)..show();
print('Document does not exist on the database');
}
});
}
void signIn(String email, String password, context) async {
try {
UserCredential userCredential =
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: password,
);
route(context);
} on FirebaseAuthException catch (e) {
if (e.code == 'user-not-found') {
AwesomeDialog(
context: context,
dialogType: DialogType.warning,
animType: AnimType.rightSlide,
title: 'Faild login',
desc: ' No user found for that email',
btnOkOnPress: () {},
)..show();
print('No user found for that email.');
} else if (e.code == 'wrong-password') {
AwesomeDialog(
context: context,
dialogType: DialogType.warning,
animType: AnimType.rightSlide,
title: 'Faild login',
desc: ' Wrong password',
btnOkOnPress: () {},
)..show();
print('Wrong password provided for that user.');
} else {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
title: 'Error',
desc: e.message,
btnOkOnPress: () {},
)..show();
}
}
}
}
......@@ -4,7 +4,9 @@ import 'package:flutter/material.dart';
import 'package:jema_app/teacherchat.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:jema_app/teacherhome.dart';
import 'ChatScreen.dart';
import 'TeacherProfile.dart'; // Import the AddClassroomPage file
class ReportKidsPage extends StatelessWidget {
......@@ -229,20 +231,26 @@ class ReportKidsPage extends StatelessWidget {
onTap: (index) {
switch (index) {
case 0:
// Navigate to Home
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherHomePage()),
);
break;
case 1:
// Navigate to Chat
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherChatPage()),
MaterialPageRoute(builder: (context) => ChatScreen()),
);
break;
case 2:
// Navigate to Profile
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherProfilePage()),
MaterialPageRoute(
builder: (context) => TeacherProfilePage(
uid: user?.uid,
)),
);
break;
}
......
......@@ -3,23 +3,73 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/login.dart';
import 'package:jema_app/teacherchat.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:jema_app/teacherhome.dart';
class TeacherProfilePage extends StatelessWidget {
import 'ChatScreen.dart';
class TeacherProfilePage extends StatefulWidget {
final String? uid; // Make uid nullable
TeacherProfilePage({required this.uid, Key? key});
@override
_TeacherProfilePageState createState() => _TeacherProfilePageState(uid);
}
class _TeacherProfilePageState extends State<TeacherProfilePage> {
late User? user;
late final Stream<QuerySnapshot> _usersStream;
late String fullName = "";
late String email = "";
late String state = "";
late String capacity = "";
late String school = "";
late Map<String, dynamic> targetDoc;
final FirebaseAuth _auth = FirebaseAuth.instance;
TeacherProfilePage() {
late String uid;
_TeacherProfilePageState(uid) {
this.uid = uid;
}
@override
void initState() {
super.initState();
user = FirebaseAuth.instance.currentUser;
initializeStreams();
getUserData();
}
void initializeStreams() {
_usersStream = FirebaseFirestore.instance
.collection('classroom')
.where('userId', isEqualTo: user?.uid)
.snapshots();
print("Document does not exist " + uid);
FirebaseFirestore.instance
.collection('users')
.doc(
uid) // Assuming you want to get a specific document based on the user's UID
.get()
.then((DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists) {
// Access the data of the document
targetDoc = documentSnapshot.data() as Map<String, dynamic>? ?? {};
print("doc" + targetDoc.toString());
// Check if the document ID matches a specific value
setState(() {
// Process the document data
fullName = targetDoc['fullName'];
email = targetDoc['email'];
state = targetDoc['state'];
capacity = targetDoc['enrolmentCapacity'];
school = targetDoc['school'];
});
print(
"Full Name: $fullName, Email: $email, State: $state, Capacity: $capacity, School: $school");
} else {
print("Document does not exist");
}
}).catchError((error) {
print("Error getting document: $error");
});
}
@override
......@@ -131,7 +181,7 @@ class TeacherProfilePage extends StatelessWidget {
left: 0,
top: 0,
child: Text(
'Name',
'Full Name',
style: TextStyle(
color: Color(0xFF797C7B),
fontSize: 14,
......@@ -145,7 +195,7 @@ class TeacherProfilePage extends StatelessWidget {
left: 4,
top: 24,
child: Text(
'Jhon Abraham',
fullName,
style: TextStyle(
color: Color(0xFF000D07),
fontSize: 18,
......@@ -185,7 +235,7 @@ class TeacherProfilePage extends StatelessWidget {
left: 4,
top: 24,
child: Text(
'jhonabraham20@gmail.com',
email,
style: TextStyle(
color: Color(0xFF000D07),
fontSize: 18,
......@@ -224,7 +274,7 @@ class TeacherProfilePage extends StatelessWidget {
left: 4,
top: 24,
child: Text(
'33 street west subidbazar,sylhet',
state,
style: TextStyle(
color: Color(0xFF000D07),
fontSize: 18,
......@@ -263,7 +313,7 @@ class TeacherProfilePage extends StatelessWidget {
left: 4,
top: 24,
child: Text(
'33 street west subidbazar,sylhet',
capacity,
style: TextStyle(
color: Color(0xFF000D07),
fontSize: 18,
......@@ -288,7 +338,7 @@ class TeacherProfilePage extends StatelessWidget {
left: 0,
top: 0,
child: Text(
'Country',
'School',
style: TextStyle(
color: Color(0xFF797C7B),
fontSize: 14,
......@@ -302,7 +352,7 @@ class TeacherProfilePage extends StatelessWidget {
left: 4,
top: 24,
child: Text(
'33 street west subidbazar,sylhet',
school,
style: TextStyle(
color: Color(0xFF000D07),
fontSize: 18,
......@@ -445,10 +495,23 @@ class TeacherProfilePage extends StatelessWidget {
selectedItemColor: Colors.blue,
onTap: (index) {
// Handle bottom navigation item tap
if (index == 0) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherHomePage()),
);
}
if (index == 1) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherChatPage()),
MaterialPageRoute(builder: (context) => ChatScreen()),
);
}
if (index == 2) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherProfilePage(uid: user?.uid)),
);
}
},
......@@ -470,4 +533,35 @@ class TeacherProfilePage extends StatelessWidget {
print('Error signing out: $e');
}
}
// Define a function to fetch user data from Firestore
Future<void> getUserData() async {
FirebaseFirestore.instance
.collection('users')
.doc(user
?.uid) // Assuming you want to get a specific document based on the user's UID
.get()
.then((DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists) {
// Access the data of the document
targetDoc = documentSnapshot.data() as Map<String, dynamic>? ?? {};
// Check if the document ID matches a specific value
setState(() {
// Process the document data
fullName = targetDoc['fullName'];
String email = targetDoc['email'];
String state = targetDoc['state'];
String capacity = targetDoc['enrolmentCapacity'];
String school = targetDoc['school'];
});
print(
"Full Name: $fullName, Email: $email, State: $state, Capacity: $capacity, School: $school");
} else {
print("Document does not exist");
}
}).catchError((error) {
print("Error getting document: $error");
});
}
}
......@@ -17,13 +17,17 @@ class _AddClassroomPageState extends State<AddClassroomPage> {
final TextEditingController roomCapacityController = TextEditingController();
final TextEditingController ratioController = TextEditingController();
final TextStyle poppinsTextStyle = TextStyle(
fontFamily: 'Poppins',
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add Classroom'),
),
body: Center(
body: SingleChildScrollView(
child: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
......@@ -37,42 +41,56 @@ class _AddClassroomPageState extends State<AddClassroomPage> {
fit: BoxFit.contain,
),
SizedBox(height: 20),
TextField(
TextFormField(
controller: classNameController,
decoration: InputDecoration(
labelText: 'Classroom Name',
suffixIcon: Icon(Icons.school), // Classroom icon
prefixIcon: Icon(Icons.school), // Classroom icon
),
),
SizedBox(height: 10),
TextField(
TextFormField(
controller: roomCapacityController,
decoration: InputDecoration(
labelText: 'Room Capacity',
suffixIcon: Icon(Icons.people), // People icon
prefixIcon: Icon(Icons.people), // People icon
),
keyboardType: TextInputType.number,
),
SizedBox(height: 10),
TextField(
TextFormField(
controller: ratioController,
decoration: InputDecoration(
labelText: 'Student to Staff Ratio',
suffixIcon: Icon(Icons.numbers), // Your ratio icon
prefixIcon: Icon(Icons.numbers), // Your ratio icon
),
keyboardType: TextInputType.number,
),
SizedBox(height: 20),
ElevatedButton(
Container(
height: 50.0,
width: 150.0,
decoration: BoxDecoration(
color: Color.fromARGB(203, 164, 88, 177),
borderRadius: BorderRadius.circular(4.0),
),
child: TextButton(
onPressed: () {
postDetailsToFirestore(context);
},
child: Text('Create Classroom'),
child: Text(
'Create Classroom',
style: poppinsTextStyle.copyWith(
color: Colors.white,
),
),
),
),
],
),
),
),
),
);
}
......
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
class AddStudentPage extends StatefulWidget {
const AddStudentPage({Key? key});
const AddStudentPage({required this.classname});
final String classname;
@override
State<AddStudentPage> createState() => _AddStudentState();
State<AddStudentPage> createState() => _AddStudentState(classname);
}
class _AddStudentState extends State<AddStudentPage> {
final _formkey = GlobalKey<FormState>();
final _auth = FirebaseAuth.instance;
//Bio Part
TextEditingController _firstnameController = TextEditingController();
TextEditingController _lastnameController = TextEditingController();
......@@ -42,6 +49,10 @@ class _AddStudentState extends State<AddStudentPage> {
ImagePicker _imagePicker = ImagePicker();
XFile? _selectedImage;
String classname;
_AddStudentState(String classname) : this.classname = classname;
@override
Widget build(BuildContext context) {
return Scaffold(
......@@ -90,7 +101,7 @@ class _AddStudentState extends State<AddStudentPage> {
radius: 50.0,
backgroundImage: _selectedImage != null
? Image.file(File(_selectedImage!.path)).image
: AssetImage('assets/profile_image.jpg'),
: AssetImage('lib/assets/classlogo.png'),
),
),
......@@ -179,7 +190,7 @@ class _AddStudentState extends State<AddStudentPage> {
child: TextField(
controller: _sexController,
decoration: InputDecoration(
hintText: 'Sex',
hintText: 'Male/Female',
filled: true,
fillColor: Color.fromARGB(107, 196, 196, 196),
border: OutlineInputBorder(
......@@ -572,8 +583,23 @@ class _AddStudentState extends State<AddStudentPage> {
SizedBox(height: 30),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
onPressed: () async {
if (Image == null) {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
title: 'Please Select Image',
btnOkOnPress: () {
Navigator.pop(context);
},
)..show();
} else {
// Handle signup logic here
String firstname = _firstnameController.text;
String lastname = _lastnameController.text;
......@@ -598,12 +624,42 @@ class _AddStudentState extends State<AddStudentPage> {
String zip = _zipController.text;
String country = _countryController.text;
String state = _stateController.text;
print(
'Firstname: $firstname,Lastname: $lastname ,Sex: $sex, Birthday: $birthday, Doctorname: $doctorname, Doctorphone: $doctorphone, Allergies: $allergies, Medicine: $medicine, Parentname: $parentname, Parentphone: $parentphone, Parentemail: $parentemail, Adressline1: $adressline1, Adressline2: $adressline2, City: $city, Zip: $zip, Country: $country, State: $state');
var imageName = DateTime.now()
.millisecondsSinceEpoch
.toString();
var storageRef = FirebaseStorage.instance
.ref()
.child('student_images/$imageName.jpg');
var uploadTask =
storageRef.putFile(File(_selectedImage!.path));
var downloadUrl =
await (await uploadTask).ref.getDownloadURL();
// You can perform signup/authentication logic here
postDetailsToFirestore(
downloadUrl,
firstname,
lastname,
sex,
birthday,
doctorname,
doctorphone,
allergies,
medicine,
parentname,
parentphone,
parentemail,
adressline1,
adressline2,
city,
zip,
country,
state,
classname,
context);
}
},
style: ElevatedButton.styleFrom(
primary: Colors.blue,
primary: Colors.green,
onPrimary: Colors.white,
),
child: Row(
......@@ -613,9 +669,23 @@ class _AddStudentState extends State<AddStudentPage> {
Text('Signup'),
],
),
],
),
),
ElevatedButton(
onPressed: () {
// Handle signup logic here
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
primary: Colors.white,
onPrimary: Colors.black,
),
child: Row(
children: [
Column(
children: [
Text('Signup'),
Text('Cancel'),
],
),
],
......@@ -623,10 +693,73 @@ class _AddStudentState extends State<AddStudentPage> {
),
],
),
],
),
),
),
),
),
);
}
postDetailsToFirestore(
String image,
String firstname,
String lastname,
String sex,
String birthday,
String doctorname,
String doctorphone,
String allergies,
String medicine,
String parentname,
String parentphone,
String parentemail,
String adressline1,
String adressline2,
String city,
String zip,
String country,
String state,
String classname,
context) async {
FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance;
var user = _auth.currentUser;
CollectionReference ref = FirebaseFirestore.instance.collection('students');
ref.doc().set({
"Firstname": firstname,
"Lastname": lastname,
"Sex": sex,
"Birthday": birthday,
"Doctorname": doctorname,
"Doctorphone": doctorphone,
"Allergies": allergies,
"Medicine": medicine,
"Parentname": parentname,
"Parentphone": parentphone,
"Parentemail": parentemail,
"Adressline1": adressline1,
"Adressline2": adressline2,
"City": city,
"Zip": zip,
"Country": country,
"State": state,
"user": user!.uid,
"image": image,
"className": classname,
"isCheck": 0,
"role": 'Student'
});
AwesomeDialog(
context: context,
dialogType: DialogType.success,
animType: AnimType.rightSlide,
title: 'Successfully Created',
btnOkOnPress: () {
Navigator.pop(context);
},
)..show();
}
}
......@@ -4,13 +4,21 @@ import 'package:flutter/material.dart';
import 'package:jema_app/teacherchat.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:jema_app/teacherhome.dart';
import 'ChatScreen.dart';
import 'TeacherProfile.dart';
class ChildrenProfilePage extends StatelessWidget {
late User? user;
late final Stream<QuerySnapshot> _usersStream;
ChildrenProfilePage() {
int _age = 0;
late final userDetails;
ChildrenProfilePage(document) {
this.userDetails = document;
user = FirebaseAuth.instance.currentUser;
initializeStreams();
calculateAge(userDetails['Birthday']);
}
void initializeStreams() {
......@@ -136,7 +144,7 @@ class ChildrenProfilePage extends StatelessWidget {
CrossAxisAlignment.start,
children: [
Text(
'David Smith',
userDetails['Firstname'],
style: TextStyle(
color: Color(0xFF11324D),
fontSize: 20,
......@@ -163,7 +171,7 @@ class ChildrenProfilePage extends StatelessWidget {
),
const SizedBox(height: 11),
Text(
'Student',
userDetails['role'],
style: TextStyle(
color: Color(0xFF21205B),
fontSize: 14,
......@@ -206,7 +214,7 @@ class ChildrenProfilePage extends StatelessWidget {
),
),
TextSpan(
text: '05',
text: _age.toString(),
style: TextStyle(
color: Color(0xFF21205B),
fontSize: 14,
......@@ -240,7 +248,7 @@ class ChildrenProfilePage extends StatelessWidget {
),
),
TextSpan(
text: '12. 02. 2019',
text: userDetails['Birthday'],
style: TextStyle(
color: Color(0xFF21205B),
fontSize: 14,
......@@ -274,7 +282,7 @@ class ChildrenProfilePage extends StatelessWidget {
),
),
TextSpan(
text: 'Male',
text: userDetails['Sex'],
style: TextStyle(
color: Color(0xFF21205B),
fontSize: 14,
......@@ -498,7 +506,7 @@ class ChildrenProfilePage extends StatelessWidget {
],
),
))),
Padding(
/* Padding(
padding: const EdgeInsets.fromLTRB(8, 30, 0, 0),
child: SingleChildScrollView(
child: Container(
......@@ -727,7 +735,7 @@ class ChildrenProfilePage extends StatelessWidget {
),
),
),
)
)**/
],
),
),
......@@ -749,10 +757,23 @@ class ChildrenProfilePage extends StatelessWidget {
selectedItemColor: Colors.blue,
onTap: (index) {
// Handle bottom navigation item tap
if (index == 0) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherHomePage()),
);
}
if (index == 1) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherChatPage()),
MaterialPageRoute(builder: (context) => ChatScreen()),
);
}
if (index == 2) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherProfilePage(uid: user?.uid)),
);
}
},
......@@ -760,4 +781,22 @@ class ChildrenProfilePage extends StatelessWidget {
),
);
}
void calculateAge(birthday) {
String birthdayText = birthday.trim();
if (birthdayText.isNotEmpty) {
try {
DateTime birthday = DateTime.parse(birthdayText);
DateTime now = DateTime.now();
Duration difference = now.difference(birthday);
_age = (difference.inDays / 365).floor();
} catch (e) {
print('Invalid date format: $e');
// Handle invalid date format
}
} else {
// Handle empty input
}
}
}
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/Attendance.dart';
import 'package:jema_app/ChildrenActivity.dart';
import 'package:jema_app/ReportKids.dart';
import 'CheckKids.dart';
import 'ChildrenHomePage.dart';
......@@ -11,6 +14,8 @@ class ClassroomViewPage extends StatelessWidget {
var documents;
late Future<List<DocumentSnapshot>> students = getStudentData();
late User? user;
final TextEditingController _searchController = TextEditingController();
late StreamController<String> _searchTermController;
ClassroomViewPage({super.key, required this.documents}) {
user = FirebaseAuth.instance.currentUser;
......@@ -48,22 +53,66 @@ class ClassroomViewPage extends StatelessWidget {
),
),
SizedBox(height: 10),
ElevatedButton(
Container(
height: 35.0,
width: 120.0,
decoration: BoxDecoration(
color: Color.fromARGB(203, 164, 88, 177),
borderRadius: BorderRadius.circular(4.0),
),
child: TextButton(
onPressed: () {
// Navigate to AddStudentPage
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddStudentPage()),
MaterialPageRoute(
builder: (context) =>
AddStudentPage(classname: documents)),
);
},
child: Text('Add Student'),
child: Text(
'Add Student',
style: TextStyle(
color: Colors.white,
),
),
),
),
SizedBox(height: 10),
TextField(
Padding(
padding: const EdgeInsets.fromLTRB(20, 40, 20, 20),
child: Container(
width: 293,
height: 44,
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
shadows: [
BoxShadow(
color: Color(0x3F000000),
blurRadius: 4,
offset: Offset(0, 1),
spreadRadius: 0,
),
],
),
child: TextField(
controller: _searchController,
onChanged: (value) {
_searchTermController.add(value);
},
decoration: InputDecoration(
hintText: 'Search...',
prefixIcon: Icon(Icons.search),
border: OutlineInputBorder(),
hintText: 'Search',
border: InputBorder.none,
icon: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.search),
),
suffixIcon: Icon(Icons.mic),
contentPadding: EdgeInsets.all(8),
),
),
),
),
SizedBox(height: 10),
......@@ -143,7 +192,7 @@ class ClassroomViewPage extends StatelessWidget {
),
),
TextSpan(
text: '10',
text: '',
style: TextStyle(
color: Colors.white,
fontSize: 14,
......@@ -251,7 +300,7 @@ class ClassroomViewPage extends StatelessWidget {
),
),
TextSpan(
text: '12',
text: '',
style: TextStyle(
color: Colors.white,
fontSize: 14,
......@@ -284,7 +333,13 @@ class ClassroomViewPage extends StatelessWidget {
),
),
),
Padding(
GestureDetector(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => ChildrenActivity(),
));
},
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
width: 170,
......@@ -317,7 +372,8 @@ class ClassroomViewPage extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Activities',
......@@ -349,6 +405,7 @@ class ClassroomViewPage extends StatelessWidget {
),
),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
......
......@@ -2,7 +2,9 @@ import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/parentHome.dart';
import 'package:jema_app/teacherhome.dart';
import 'package:shared_preferences/shared_preferences.dart';
class LoginPage extends StatefulWidget {
const LoginPage({Key? key, required this.backgroundColor}) : super(key: key);
......@@ -178,12 +180,24 @@ class _LoginPage extends State<LoginPage> {
print("login teacher");
} else {
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
title: ' login Perent',
desc: ' Go to your home page',
btnCancelOnPress: () {},
btnOkOnPress: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => TeacherHomePage(),
builder: (context) =>
ParentHomePage(documentSnapshot.get('phoneNo')),
),
);
},
)..show();
print("login parent");
}
} else {
AwesomeDialog(
......
......@@ -7,9 +7,11 @@ import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}
......
import 'package:flutter/material.dart';
import 'ParentLogin.dart';
import 'login.dart';
class ParentTeacherPage extends StatelessWidget {
const ParentTeacherPage({Key? key, required this.backgroundColor}) : super(key: key);
const ParentTeacherPage({Key? key, required this.backgroundColor})
: super(key: key);
final Color backgroundColor;
......@@ -53,6 +55,14 @@ class ParentTeacherPage extends StatelessWidget {
ElevatedButton(
onPressed: () {
// logic for navigating to the parent login page
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ParentLoginPage(
backgroundColor: backgroundColor,
),
),
);
},
child: Container(
width: 200,
......
import 'package:flutter/material.dart';
import 'package:jema_app/parentSignUp.dart';
import 'package:jema_app/teachersignup.dart';
import 'ParentLogin.dart';
import 'login.dart';
class ParentTeacherSignUpPage extends StatelessWidget {
const ParentTeacherSignUpPage({Key? key, required this.backgroundColor})
: super(key: key);
final Color backgroundColor;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: const Color.fromARGB(255, 0, 0, 0),
),
onPressed: () {
Navigator.pop(context);
},
),
),
body: Container(
color: backgroundColor,
child: SafeArea(
child: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: Image.asset(
'lib/assets/p_or_t.png',
width: 280,
height: 450,
),
),
const SizedBox(height: 20),
Text(
'Which Best Describe You ?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 105, 19, 145),
),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
// logic for navigating to the parent login page
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ParentSignupPage(),
),
);
},
child: Container(
width: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: Color.fromARGB(220, 164, 68, 215),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'Parent',
style: TextStyle(color: Colors.white),
),
),
),
),
style: ElevatedButton.styleFrom(
primary: Colors.transparent,
elevation: 0,
),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherSignupPage(),
),
);
},
child: Container(
width: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: Color.fromARGB(220, 164, 68, 215),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'Teacher',
style: TextStyle(color: Colors.white),
),
),
),
),
style: ElevatedButton.styleFrom(
primary: Colors.transparent,
elevation: 0,
),
),
],
),
),
),
),
),
);
}
}
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:jema_app/teacherchat.dart';
import 'ChatScreen.dart';
import 'TeacherProfile.dart';
import 'childrenProfile.dart';
class ParentHomePage extends StatelessWidget {
late User? user;
late final Stream<QuerySnapshot> _usersStream;
late String phoneNo;
ParentHomePage(param0) {
this.phoneNo = param0;
user = FirebaseAuth.instance.currentUser;
initializeStreams();
}
void initializeStreams() {
_usersStream = FirebaseFirestore.instance
.collection('students')
.where('Parentphone', isEqualTo: phoneNo)
.snapshots();
}
// Define a TextStyle with the Poppins font
final TextStyle poppinsTextStyle = TextStyle(
fontFamily: 'Poppins',
);
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
// Disable the back button press
return false;
},
child: Scaffold(
appBar: AppBar(
leading: Flexible(
child: Image.asset(
'lib/assets/logo.png',
fit: BoxFit.contain,
height: 150, // Adjust the height to make the logo bigger
),
),
actions: [
IconButton(
icon: Icon(Icons.notifications),
onPressed: () {
// Handle notification icon press
},
),
],
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 20),
Text(
'Explore, learn, and play in our magical world of wonder!',
style: poppinsTextStyle.copyWith(
// fontWeight: FontWeight.bold,
fontSize: 13,
),
),
SizedBox(height: 10),
Expanded(
child: Image.asset(
'lib/assets/teacherhome.png',
fit: BoxFit.contain,
),
),
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () {
// Navigate to the AddClassroomPage
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddClassroomPage()),
);
},
child: Row(
children: [],
),
),
],
),
Divider(),
SizedBox(height: 10),
Text(
'All Kids',
style: poppinsTextStyle.copyWith(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 12),
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: _usersStream,
builder: (context, snapshot) {
print("--------------------------------------");
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
}
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
var itemcount = snapshot.data!.docs.length;
return ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
var document = snapshot.data!.docs[index];
var className = document['className'];
var name = document['Firstname'];
print(className);
return Padding(
padding: const EdgeInsets.only(
bottom: 8.0), // Adjust the spacing as needed
child: ListTile(
leading: CircleAvatar(
radius: 27.0,
backgroundImage:
AssetImage('lib/assets/classlogo.png'),
),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
'$name',
style: poppinsTextStyle.copyWith(
fontWeight: FontWeight.bold),
),
],
),
Row(
children: [
Text(
'$className',
style: poppinsTextStyle.copyWith(
fontSize: 12.0),
),
],
),
],
),
trailing: Container(
height: 35.0,
width: 80.0,
decoration: BoxDecoration(
color: Color.fromARGB(203, 164, 88, 177),
borderRadius: BorderRadius.circular(4.0),
),
child: TextButton(
onPressed: () {
print(document);
// Handle view class button press
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChildrenProfilePage(
document,
),
),
);
},
child: Text(
'View',
style: poppinsTextStyle.copyWith(
color: Colors.white,
),
),
),
),
),
);
},
);
},
),
),
],
),
),
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.chat),
label: 'Chat',
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'Profile',
),
],
selectedItemColor: Colors.blue,
onTap: (index) {
// Handle bottom navigation item tap
switch (index) {
case 0:
break;
case 1:
// Navigate to Chat
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ChatScreen()),
);
break;
case 2:
// Navigate to Profile
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherProfilePage(
uid: user?.uid,
)),
);
break;
}
},
),
),
);
}
}
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'login.dart';
class ParentSignupPage extends StatefulWidget {
const ParentSignupPage({Key? key}) : super(key: key);
@override
_ParentSignupPageState createState() => _ParentSignupPageState();
}
class _ParentSignupPageState extends State<ParentSignupPage> {
// TextEditingController for text input fields
final _formkey = GlobalKey<FormState>();
final _auth = FirebaseAuth.instance;
TextEditingController fullNameController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController phoneNumberController = TextEditingController();
TextEditingController passwordController = TextEditingController();
// TextEditingController schoolNameController = TextEditingController();
// TextEditingController enrolmentCapacityController = TextEditingController();
// TextEditingController countryController = TextEditingController();
// TextEditingController stateRegionController = TextEditingController();
bool agreeTermsAndConditions = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Parent Signup'),
),
body: SingleChildScrollView(
child: Column(
children: [
Image.asset(
'lib/assets/tsignup1.png',
width: 240,
height: 270,
fit: BoxFit.cover,
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildTextInputWithIcon(
controller: fullNameController,
labelText: 'Full Name',
icon: Icons.person,
),
const SizedBox(height: 10),
_buildTextInputWithIcon(
controller: emailController,
labelText: 'Email',
icon: Icons.email,
),
const SizedBox(height: 10),
_buildTextInputWithIcon(
controller: phoneNumberController,
labelText: 'Phone Number',
icon: Icons.phone,
),
const SizedBox(height: 10),
_buildTextInputWithIcon(
controller: passwordController,
labelText: 'Password',
icon: Icons.lock,
obscureText: true,
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
// Logic to navigate to the next page with additional information
signUp(emailController.text, passwordController.text,
'parent', context);
},
child: Text('Finish'),
),
],
),
),
],
),
),
);
}
Widget _buildTextInputWithIcon({
required TextEditingController controller,
required String labelText,
required IconData icon,
bool obscureText = false,
}) {
return TextFormField(
controller: controller,
obscureText: obscureText,
decoration: InputDecoration(
labelText: labelText,
suffixIcon: Icon(icon),
filled: true,
fillColor: Colors.grey[200], // Light gray background color
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent), // No border color when focused
borderRadius: BorderRadius.circular(10.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent), // No border color when not focused
borderRadius: BorderRadius.circular(10.0),
),
),
);
}
void signUp(String email, String password, String rool, context) async {
CircularProgressIndicator();
await _auth
.createUserWithEmailAndPassword(email: email, password: password)
.then((value) => {postDetailsToFirestore(email, rool, context)})
.catchError((e) {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
title: 'Error',
desc: ' error',
btnOkOnPress: () {},
)..show();
});
}
postDetailsToFirestore(String email, String rool, context) async {
FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance;
var user = _auth.currentUser;
CollectionReference ref = FirebaseFirestore.instance.collection('users');
print("user!.uid == : " + emailController.text);
ref.doc(user!.uid).set({
"fullName": fullNameController.text,
'email': emailController.text,
'phoneNo': phoneNumberController.text,
"agreeTermsAndConditions": agreeTermsAndConditions,
'rool': rool
});
AwesomeDialog(
context: context,
dialogType: DialogType.success,
animType: AnimType.rightSlide,
title: 'Successfully Created',
desc: ' Go to Login page',
btnOkOnPress: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => LoginPage(
backgroundColor: Color.fromARGB(255, 0, 183, 255),
)));
},
)..show();
}
}
import 'package:flutter/material.dart';
import 'package:jema_app/p_or_t.dart';
import 'package:jema_app/parentSignUp.dart';
import 'package:jema_app/teachersignup.dart';
import 'p_or_t_s.dart';
class SignInUpPage extends StatelessWidget {
const SignInUpPage({Key? key, required this.backgroundColor})
: super(key: key);
......@@ -30,13 +33,16 @@ class SignInUpPage extends StatelessWidget {
),
),
const SizedBox(height: 20),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
// Navigate to the signup page (TeacherSignupPage)
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherSignupPage(),
builder: (context) => ParentTeacherSignUpPage(
backgroundColor: backgroundColor,
),
),
);
},
......
import 'package:flutter/material.dart';
import 'ChatScreen.dart';
class TeacherChatPage extends StatefulWidget {
@override
_TeacherChatPageState createState() => _TeacherChatPageState();
......@@ -12,7 +14,10 @@ class _TeacherChatPageState extends State<TeacherChatPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Chat'),
title: GestureDetector(
onTap: () => Navigator.push(
context, MaterialPageRoute(builder: (context) => ChatScreen())),
child: Text('Chat')),
),
body: ChatList(),
bottomNavigationBar: BottomNavigationBar(
......
......@@ -5,6 +5,7 @@ import 'package:jema_app/classroomview.dart';
import 'package:jema_app/addclassroom.dart';
import 'package:jema_app/teacherchat.dart';
import 'ChatScreen.dart';
import 'TeacherProfile.dart';
class TeacherHomePage extends StatelessWidget {
......@@ -81,7 +82,8 @@ class TeacherHomePage extends StatelessWidget {
// Navigate to the AddClassroomPage
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddClassroomPage()),
MaterialPageRoute(
builder: (context) => AddClassroomPage()),
);
},
child: Row(
......@@ -141,11 +143,13 @@ class TeacherHomePage extends StatelessWidget {
var className = document['className'];
return Padding(
padding: const EdgeInsets.only(bottom: 8.0), // Adjust the spacing as needed
padding: const EdgeInsets.only(
bottom: 8.0), // Adjust the spacing as needed
child: ListTile(
leading: CircleAvatar(
radius: 27.0,
backgroundImage: AssetImage('lib/assets/classlogo.png'),
backgroundImage:
AssetImage('lib/assets/classlogo.png'),
),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
......@@ -154,7 +158,8 @@ class TeacherHomePage extends StatelessWidget {
children: [
Text(
'$className',
style: poppinsTextStyle.copyWith(fontWeight: FontWeight.bold),
style: poppinsTextStyle.copyWith(
fontWeight: FontWeight.bold),
),
],
),
......@@ -162,7 +167,8 @@ class TeacherHomePage extends StatelessWidget {
children: [
Text(
'Class $index',
style: poppinsTextStyle.copyWith(fontSize: 12.0),
style: poppinsTextStyle.copyWith(
fontSize: 12.0),
),
],
),
......@@ -232,14 +238,15 @@ class TeacherHomePage extends StatelessWidget {
// Navigate to Chat
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherChatPage()),
MaterialPageRoute(builder: (context) => ChatScreen()),
);
break;
case 2:
// Navigate to Profile
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherProfilePage()),
MaterialPageRoute(
builder: (context) => TeacherProfilePage(uid: user?.uid)),
);
break;
}
......
......@@ -252,10 +252,10 @@ packages:
dependency: "direct main"
description:
name: image_picker
sha256: "26222b01a0c9a2c8fe02fc90b8208bd3325da5ed1f4a2acabf75939031ac0bdd"
sha256: b6951e25b795d053a6ba03af5f710069c99349de9341af95155d52665cb4607c
url: "https://pub.dev"
source: hosted
version: "1.0.7"
version: "0.8.9"
image_picker_android:
dependency: transitive
description:
......
......@@ -35,11 +35,11 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
image_picker: ^0.8.0
firebase_core: ^2.24.2
firebase_auth: ^4.15.3
cloud_firestore: ^4.13.6
awesome_dialog: ^3.1.0
image_picker: ^1.0.6
dev_dependencies:
......@@ -82,7 +82,6 @@ flutter:
- lib/assets/Vector25.png
- lib/assets/Vector26.png
- lib/assets/Ellipse 8.png
- lib/assets/classlogo.png
......
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