Commit 2db64725 authored by Uditha Prabhasha 's avatar Uditha Prabhasha

init project

parent 6c0f32f5
File added
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
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/teacherhome.dart';
class AddClassroomPage extends StatefulWidget {
@override
_AddClassroomPageState createState() => _AddClassroomPageState();
}
final _formkey = GlobalKey<FormState>();
final _auth = FirebaseAuth.instance;
class _AddClassroomPageState extends State<AddClassroomPage> {
final TextEditingController classNameController = TextEditingController();
final TextEditingController roomCapacityController = TextEditingController();
final TextEditingController ratioController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add Classroom'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'lib/assets/addclassroom.png',
height: 260,
width: 340,
fit: BoxFit.contain,
),
SizedBox(height: 20),
TextField(
controller: classNameController,
decoration: InputDecoration(
labelText: 'Classroom Name',
suffixIcon: Icon(Icons.school), // Classroom icon
),
),
SizedBox(height: 10),
TextField(
controller: roomCapacityController,
decoration: InputDecoration(
labelText: 'Room Capacity',
suffixIcon: Icon(Icons.people), // People icon
),
keyboardType: TextInputType.number,
),
SizedBox(height: 10),
TextField(
controller: ratioController,
decoration: InputDecoration(
labelText: 'Student to Staff Ratio',
suffixIcon: Icon(Icons.numbers), // Your ratio icon
),
keyboardType: TextInputType.number,
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
postDetailsToFirestore(context);
},
child: Text('Create Classroom'),
),
],
),
),
),
);
}
postDetailsToFirestore(context) async {
FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance;
var user = _auth.currentUser;
CollectionReference ref =
FirebaseFirestore.instance.collection('classroom');
print("class == : " + classNameController.text);
ref.doc(classNameController.text).set({
"className": classNameController.text,
'roomCapacity': roomCapacityController.text,
'ratio': ratioController.text,
'userId': user!.uid,
});
AwesomeDialog(
context: context,
dialogType: DialogType.success,
animType: AnimType.rightSlide,
title: 'Successfully Created',
desc: ' Go to Home page',
btnOkOnPress: () {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => TeacherHomePage()));
},
)..show();
}
}
import 'package:flutter/material.dart';
class AddStudentPage extends StatefulWidget {
@override
_AddStudentPageState createState() => _AddStudentPageState();
}
class _AddStudentPageState extends State<AddStudentPage> {
String _selectedSex = 'Male';
bool _isSpecialNeedsChild = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add Student'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
CircleAvatar(
radius: 50,
// Add logic to handle profile image selection
// backgroundImage: AssetImage('path_to_profile_image'),
),
SizedBox(height: 16),
buildTextFormField('First Name', 'Enter first name'),
buildTextFormField('Last Name', 'Enter last name'),
buildDateOfBirthField(),
buildSexDropdown(),
buildMedicineFields(),
buildSpecialNeedsFields(),
SizedBox(height: 16),
ElevatedButton(
onPressed: () {
// Add logic to save student data
// Navigator.pop(context); // Navigate back after saving
},
child: Text('Save Student'),
),
],
),
),
),
);
}
Widget buildTextFormField(String label, String hint) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: TextFormField(
decoration: InputDecoration(
labelText: label,
hintText: hint,
),
),
);
}
Widget buildDateOfBirthField() {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: TextFormField(
readOnly: true,
onTap: () async {
// Add logic to show date picker
// final DateTime picked = await showDatePicker(
// context: context,
// initialDate: DateTime.now(),
// firstDate: DateTime(2000),
// lastDate: DateTime(2101),
// );
// if (picked != null && picked != DateTime.now()) {
// // Handle the selected date
// }
},
decoration: InputDecoration(
labelText: 'Date of Birth',
hintText: 'Select date of birth',
),
),
);
}
Widget buildSexDropdown() {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: DropdownButtonFormField<String>(
value: _selectedSex,
onChanged: (value) {
setState(() {
_selectedSex = value!;
});
},
items: ['Male', 'Female'].map((sex) {
return DropdownMenuItem<String>(
value: sex,
child: Text(sex),
);
}).toList(),
decoration: InputDecoration(
labelText: 'Sex',
),
),
);
}
Widget buildMedicineFields() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildTextFormField('Doctor Name', 'Enter doctor name'),
buildTextFormField('Doctor Phone', 'Enter doctor phone'),
buildTextFormField('Allergies', 'Enter allergies'),
buildTextFormField('Medicine', 'Enter medicine'),
],
);
}
Widget buildSpecialNeedsFields() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text('Special Needs Child: '),
Checkbox(
value: _isSpecialNeedsChild,
onChanged: (value) {
setState(() {
_isSpecialNeedsChild = value!;
});
},
),
],
),
if (_isSpecialNeedsChild)
buildTextFormField('Special Note', 'Enter special note'),
],
);
}
}
void main() {
runApp(MaterialApp(
home: AddStudentPage(),
));
}
This diff is collapsed.
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}
static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyA-VNu0nraKLX921wfo0xlAETvSnezKCSA',
appId: '1:534654186450:web:6c63eb1660afd41fba8e0b',
messagingSenderId: '534654186450',
projectId: 'classroom-75d8f',
authDomain: 'classroom-75d8f.firebaseapp.com',
storageBucket: 'classroom-75d8f.appspot.com',
measurementId: 'G-R7676GHN7C',
);
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyDuW4dw6QbPc9QJwYAHltnrDtvBTfUeB04',
appId: '1:534654186450:android:c1708c45dad3296cba8e0b',
messagingSenderId: '534654186450',
projectId: 'classroom-75d8f',
storageBucket: 'classroom-75d8f.appspot.com',
);
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyARBNc6IJnk7pHvfy8G0BHPX09fkmYUthM',
appId: '1:534654186450:ios:466e45c9dd7a6ef8ba8e0b',
messagingSenderId: '534654186450',
projectId: 'classroom-75d8f',
storageBucket: 'classroom-75d8f.appspot.com',
iosBundleId: 'com.example.jemaApp',
);
static const FirebaseOptions macos = FirebaseOptions(
apiKey: 'AIzaSyARBNc6IJnk7pHvfy8G0BHPX09fkmYUthM',
appId: '1:534654186450:ios:8ffcae2dcde0109fba8e0b',
messagingSenderId: '534654186450',
projectId: 'classroom-75d8f',
storageBucket: 'classroom-75d8f.appspot.com',
iosBundleId: 'com.example.jemaApp.RunnerTests',
);
}
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/teacherhome.dart';
class LoginPage extends StatefulWidget {
const LoginPage({Key? key, required this.backgroundColor}) : super(key: key);
final Color backgroundColor;
@override
_LoginPage createState() => _LoginPage(backgroundColor: backgroundColor);
}
class _LoginPage extends State<LoginPage> {
_LoginPage({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') == "teacher") {
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) => TeacherHomePage(),
),
);
},
)..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();
}
}
}
}
void main() {
runApp(const MaterialApp(
home: LoginPage(
backgroundColor: Color.fromARGB(255, 225, 226, 226),
),
));
}
import 'dart:async';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:jema_app/sign_in_up.dart';
import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme:
ColorScheme.fromSeed(seedColor: Color.fromARGB(0, 255, 255, 255)),
useMaterial3: true,
textTheme: const TextTheme(
headlineMedium: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
color: Colors.white,
fontFamily: 'Poppins',
),
),
),
home: const MyHomePage(
title: '',
backgroundColor: Color.fromARGB(255, 0, 183, 255),
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage(
{Key? key, required this.title, required this.backgroundColor})
: super(key: key);
final String title;
final Color backgroundColor;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
double scaleFactor = 1.0;
@override
void initState() {
super.initState();
Timer.periodic(Duration(milliseconds: 500), (timer) {
setState(() {
// Toggle between zoom in and zoom out
scaleFactor = scaleFactor == 1.0 ? 1.05 : 1.0;
});
});
Future.delayed(Duration(seconds: 3), () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignInUpPage(
backgroundColor: const Color.fromARGB(255, 255, 255, 255))),
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: null,
body: Container(
color: widget.backgroundColor,
child: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignInUpPage(
backgroundColor:
const Color.fromARGB(255, 255, 255, 255))),
);
},
child: Transform.scale(
scale: scaleFactor,
child: Image.asset(
'lib/assets/landingimg.png',
width: 310,
height: 370,
),
),
),
),
Text(
'Welcome little explorer!',
style: Theme.of(context).textTheme.headlineMedium,
),
const Text(
"Let's dive into a world of fun and \nlearning together!",
style: TextStyle(
color: Colors.white,
fontFamily: 'Poppins',
),
textAlign: TextAlign.center,
),
],
),
),
),
),
);
}
}
import 'package:flutter/material.dart';
import 'login.dart';
class ParentTeacherPage extends StatelessWidget {
const ParentTeacherPage({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
},
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) => LoginPage(
backgroundColor: backgroundColor,
),
),
);
},
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:flutter/material.dart';
import 'package:jema_app/p_or_t.dart';
import 'package:jema_app/teachersignup.dart';
class SignInUpPage extends StatelessWidget {
const SignInUpPage({Key? key, required this.backgroundColor})
: super(key: key);
final Color backgroundColor;
@override
Widget build(BuildContext context) {
return Scaffold(
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/signinup.png',
width: 290,
height: 460,
),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
// Navigate to the signup page (TeacherSignupPage)
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TeacherSignupPage(),
),
);
},
child: Container(
width: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: Color.fromARGB(255, 96, 188, 99),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'Sign Up',
style: TextStyle(color: Colors.white),
),
),
),
),
style: ElevatedButton.styleFrom(
primary: Colors.transparent,
elevation: 0,
),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
// Navigate to the sign in page (ParentTeacherPage)
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ParentTeacherPage(
backgroundColor: backgroundColor,
),
),
);
},
child: Container(
width: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: const Color.fromARGB(255, 213, 80, 236),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'Sign In',
style: TextStyle(color: Colors.white),
),
),
),
),
style: ElevatedButton.styleFrom(
primary: Colors.transparent,
elevation: 0,
),
),
],
),
),
),
),
),
);
}
}
void main() {
runApp(const MaterialApp(
home: SignInUpPage(
backgroundColor: Color.fromARGB(255, 225, 226, 226),
),
));
}
import 'package:flutter/material.dart';
class TeacherActivitiesPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Activities'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 20),
Text(
'Activities',
style: TextStyle(
color: Color(0xFF554994),
fontSize: 24,
fontFamily: 'Poppins',
fontWeight: FontWeight.w700,
height: 0.04,
letterSpacing: -0.96,
),
),
SizedBox(height: 20),
// Your activities widgets here
// ...
],
),
),
);
}
}
import 'package:flutter/material.dart';
class TeacherChatPage extends StatefulWidget {
@override
_TeacherChatPageState createState() => _TeacherChatPageState();
}
class _TeacherChatPageState extends State<TeacherChatPage> {
int _currentIndex = 1; // Set the default selected index to 'Chat'
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Chat'),
),
body: ChatList(),
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,
currentIndex: _currentIndex,
onTap: (index) {
setState(() {
_currentIndex = index;
});
// Handle bottom navigation item tap
},
),
);
}
}
class ChatList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: 5, // Replace with the actual number of chats
itemBuilder: (context, index) {
return ChatItem(
profileImage:
'lib/assets/profile_image.png', // Replace with the actual image path
name: 'Student ${index + 1}',
lastMessage: 'Hello, how are you?',
time: '2:30 PM',
onTap: () {
// Handle chat item tap
},
);
},
);
}
}
class ChatItem extends StatelessWidget {
final String profileImage;
final String name;
final String lastMessage;
final String time;
final VoidCallback onTap;
const ChatItem({
required this.profileImage,
required this.name,
required this.lastMessage,
required this.time,
required this.onTap,
});
@override
Widget build(BuildContext context) {
return ListTile(
onTap: onTap,
leading: CircleAvatar(
backgroundImage: AssetImage(profileImage),
),
title: Text(name),
subtitle: Text(lastMessage),
trailing: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(time),
SizedBox(height: 5),
// Add additional indicators (e.g., unread message count) if needed
],
),
);
}
}
void main() {
runApp(MaterialApp(
home: TeacherChatPage(),
));
}
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.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 the AddClassroomPage file
class TeacherHomePage extends StatelessWidget {
late User? user;
late final Stream<QuerySnapshot> _usersStream;
TeacherHomePage() {
user = FirebaseAuth.instance.currentUser;
initializeStreams();
}
void initializeStreams() {
_usersStream = FirebaseFirestore.instance
.collection('classroom')
.where('userId', isEqualTo: user?.uid)
.snapshots();
}
@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,
),
),
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: TextStyle(
fontSize: 12,
),
),
SizedBox(height: 10),
Expanded(
child: Image.asset(
'lib/assets/teacherhome.png',
fit: BoxFit.contain,
),
),
SizedBox(height: 20),
TextButton(
onPressed: () {
// Navigate to the AddClassroomPage
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddClassroomPage()),
);
},
child: Text(
'Add Classroom',
style: TextStyle(
color: Colors.blue,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
Divider(),
SizedBox(height: 10),
Text(
'Class Rooms',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
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 ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
var document = snapshot.data!.docs[index];
var className = document['className'];
return ListTile(
leading: CircleAvatar(
backgroundImage: AssetImage('lib/assets/logo.png'),
),
title: Text(className),
trailing: ElevatedButton(
onPressed: () {
print(document);
// Handle view class button press
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ClassroomViewPage(
documents: className,
),
),
);
},
child: Text('View'),
),
);
},
);
},
),
),
],
),
),
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
if (index == 1) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TeacherChatPage()),
);
}
},
),
),
);
}
}
This diff is collapsed.
This diff is collapsed.
name: jema_app
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: '>=3.0.1 <4.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
firebase_core: ^2.24.2
firebase_auth: ^4.15.3
cloud_firestore: ^4.13.6
awesome_dialog: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- lib/assets/teachersignin.png
- lib/assets/logo.png
- lib/assets/p_or_t.png
- lib/assets/teacherhome.png
- lib/assets/teachersignin.png
- lib/assets/tsignup1.png
- lib/assets/signinup.png
- lib/assets/landingimg.png
- lib/assets/addclassroom.png
- lib/assets/Vector 2.png
- lib/assets/Vector22.png
- lib/assets/Vector23.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
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