Skip to content

Commit

Permalink
flag, chat, user profile, interests
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-pedro99 committed Dec 4, 2023
1 parent cfbe448 commit b9f18be
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ migrate_working_dir/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
Expand Down
2 changes: 1 addition & 1 deletion lib/app/bloc/auth/auth_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ final class AuthLogout extends AuthEvent {}

final class AuthLoginWithGoogle extends AuthEvent {}

final class AuthSignUpWithGoogle extends AuthEvent {}
final class AuthSignUpWithGoogle extends AuthEvent {}
1 change: 0 additions & 1 deletion lib/app/data/model/chat/conversation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ChatConversation {
final bool? hasUnreadMessages;
final List<dynamic> users;
final int? unreadMessagesCount;


ChatConversation({
this.id,
Expand Down
6 changes: 6 additions & 0 deletions lib/app/data/model/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class DBUser {
bool? isMentor;
String? email;
bool? isProfileComplete;
List<String>? topics; // Added topics property

DBUser({
this.college,
Expand All @@ -27,6 +28,7 @@ class DBUser {
this.isMentor,
this.email,
this.isProfileComplete,
this.topics, // Added topics parameter in the constructor
});

DBUser.fromJson(Map<String, dynamic> json) {
Expand All @@ -43,6 +45,9 @@ class DBUser {
isMentor = json['isMentor'];
email = json['email'];
isProfileComplete = json['isProfileComplete'];
topics = json['topics'] != null
? List<String>.from(json['topics'])
: null; // Added topics assignment
}

Map<String, dynamic> toJson() {
Expand All @@ -60,6 +65,7 @@ class DBUser {
data['isMentor'] = isMentor;
data['email'] = email;
data['isProfileComplete'] = isProfileComplete;
data['topics'] = topics; // Added topics assignment
return data;
}
}
17 changes: 13 additions & 4 deletions lib/app/data/services/meeting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,25 @@ class MeetingService {
// Stream of all meetings
var allMeetingsStream = _firestore.collection('meetings').snapshots();

await for (var combinedSnapshot in Rx.combineLatest2(userMeetingsStream, allMeetingsStream, (userMeetings, allMeetings) {
return userMeetings.docs.map((doc) => Meeting.fromMap(doc.data(), doc.id)).toList()
await for (var combinedSnapshot in Rx.combineLatest2(
userMeetingsStream, allMeetingsStream, (userMeetings, allMeetings) {
return userMeetings.docs
.map((doc) => Meeting.fromMap(doc.data(), doc.id))
.toList()
..addAll(allMeetings.docs
.where((doc) => doc.data()['emailIDs'].toString().split(',').map((email) => email.trim()).contains(currentUserEmail))
.where((doc) => doc
.data()['emailIDs']
.toString()
.split(',')
.map((email) => email.trim())
.contains(currentUserEmail))
.map((doc) => Meeting.fromMap(doc.data(), doc.id))
.toList());
})) {
yield combinedSnapshot.toSet().toList(); // To remove duplicates
}
}

static Future<void> deleteMeeting(String eventId) async {
await _firestore.collection('meetings').doc(eventId).delete();
}
Expand All @@ -43,4 +52,4 @@ class MeetingService {
var userDocument = await _firestore.collection('users').doc(userId).get();
return userDocument.data()?['name'] ?? 'Unknown User';
}
}
}
2 changes: 1 addition & 1 deletion lib/app/views/screens/auth/otp_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class _OTPScreenState extends State<OTPScreen> {
child: TextFormField(
controller: controller,
textAlign: TextAlign.center,
canRequestFocus: true,
// canRequestFocus: true,
keyboardType: TextInputType.number,
style: TextStyle(color: Theme.of(context).primaryColor, fontSize: 24),
onEditingComplete: () {
Expand Down
23 changes: 16 additions & 7 deletions lib/app/views/screens/auth/signup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,22 @@ class _SignUpScreenState extends State<SignUpScreen> {
rounded: true,
onPressed: () {
if (formKey.currentState!.validate()) {
BlocProvider.of<AuthBloc>(context).add(AuthSignUp(
user: UserAuthSignUp(
name: nameController.text,
email: mailController.text,
password: passwordController.text,
),
));
if (mailController.text.endsWith("@iiitd.ac.in")) {
BlocProvider.of<AuthBloc>(context).add(AuthSignUp(
user: UserAuthSignUp(
name: nameController.text,
email: mailController.text,
password: passwordController.text,
),
));
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
"Please enter a valid IIITD email address"),
),
);
}
}
},
child: const Text("Sign Up")),
Expand Down
40 changes: 39 additions & 1 deletion lib/app/views/screens/auth/user_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,26 @@ class _UserDetailsScreenState extends State<UserDetailsScreen> {
'PhD': ['CB', 'CSE', 'ECE', 'HCD', 'Maths', 'SSH'],
};

final List<String> topics = [];
final List<String> selectedTopics = [];

@override
void initState() {
super.initState();
yearOfJoiningController = TextEditingController();
yearOfGraduationController = TextEditingController();
collegeController = TextEditingController();
companyController = TextEditingController();
loadTopics();
}

loadTopics() async {
final dbTopicsCollection =
await FirebaseFirestore.instance.collection('topics').get();

dbTopicsCollection.docs.forEach((element) {
topics.add(element.data()['name']);
});
}

@override
Expand Down Expand Up @@ -80,6 +93,8 @@ class _UserDetailsScreenState extends State<UserDetailsScreen> {
child: Form(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomTextBox(
controller: yearOfGraduationController,
Expand Down Expand Up @@ -145,6 +160,27 @@ class _UserDetailsScreenState extends State<UserDetailsScreen> {
hintText: 'Company',
validationMessage: 'Please enter the company name',
),
// list of topics of interests in selectable chips

const SizedBox(height: 20),
const Text("Select your topics of interest"),
const SizedBox(height: 4),
Wrap(
spacing: 8.0,
children: topics.map((topic) {
bool isSelected = selectedTopics.contains(topic);
return FilterChip(
label: Text(topic),
selected: isSelected,
showCheckmark: true,
onSelected: (bool value) {
setState(() {
selectedTopics.add(topic);
});
},
);
}).toList(),
),
],
const SizedBox(height: 20),
CustomButton(
Expand All @@ -161,6 +197,7 @@ class _UserDetailsScreenState extends State<UserDetailsScreen> {
isMentor: isMentor,
college: collegeController.text,
company: companyController.text,
topics: selectedTopics,
adminApproval: false,
isProfileComplete: true);

Expand All @@ -173,7 +210,8 @@ class _UserDetailsScreenState extends State<UserDetailsScreen> {
course: selectedCourse,
branch: selectedBranch,
isMentor: isMentor,
adminApproval: false,
topics: [],
adminApproval: true,
isProfileComplete: true);

if (isMentor) {
Expand Down
1 change: 0 additions & 1 deletion lib/app/views/screens/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class _ChatScreenState extends State<ChatScreen> {
return InkResponse(
child: ConversationTile(
chat: chatRoom,

),
onTap: () {
final otherUser = chatRoom.users.firstWhere(
Expand Down
104 changes: 98 additions & 6 deletions lib/app/views/screens/chat/chat_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:iiitd_mentorship/app/data/model/chat/conversation.dart';
import 'package:iiitd_mentorship/app/data/model/chat/message.dart';
import 'package:iiitd_mentorship/app/data/model/user.dart';
Expand All @@ -9,6 +10,7 @@ import 'package:iiitd_mentorship/app/views/widgets/custom_textbox.dart';
import 'package:iiitd_mentorship/app/views/widgets/message_tile.dart';
import 'package:intl/intl.dart';


class ChatPage extends StatefulWidget {
const ChatPage(
{super.key, this.chatConversation, this.receiverUser, this.receiverId});
Expand All @@ -28,6 +30,7 @@ class _ChatPageState extends State<ChatPage> {
final currentUser = FirebaseAuth.instance.currentUser;
final db = FirebaseFirestore.instance;
String currentChatId = "";
bool reported = false;

@override
void initState() {
Expand Down Expand Up @@ -112,7 +115,87 @@ class _ChatPageState extends State<ChatPage> {
actions: [
IconButton(
icon: const Icon(Icons.flag),
onPressed: () {},
onPressed: () {
// show dialog with a list of reason to report the chat
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Report Chat'),
content: reported == false
? Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: const Text('Inappropriate Content'),
onTap: () {
Navigator.pop(context, 'Inappropriate');
},
),
ListTile(
title: const Text('Spam'),
onTap: () {
Navigator.pop(context, 'Spam');
},
),
// abusive language
ListTile(
title: const Text('Abusive Language'),
onTap: () {
Navigator.pop(context, 'Abusive');
},
),
ListTile(
title: const Text('Harassment'),
onTap: () {
Navigator.pop(context, 'Harassment');
},
),
ListTile(
title: const Text('Other'),
onTap: () {
Navigator.pop(context, 'Other');
},
),
],
)
: const SizedBox(
height: 100,
child: Center(
child: Column(
children: [
Icon(Icons.check_circle_outline,
color: Colors.green),
Text(
'You have reported this chat.\nWe will look into it.'),
],
),
),
),
);
},
).then((value) {
if (value != null) {
// add report to database
db.collection('reported_users').add({
'reported': currentChatId,
'reporter': currentUser!.uid,
'reason': value,
'date': Timestamp.now(),
}).then((value) {
setState(() {
reported = true;
});
}).onError((error, stackTrace) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(error.toString()),
),
);
});
}
});
},
),
],
),
Expand Down Expand Up @@ -186,10 +269,15 @@ class _ChatPageState extends State<ChatPage> {
//align message to left for received message and right for sent ones
var isMe = message.senderId == currentUser!.uid;

return MessageTile(
isMe: isMe,
message: message.message,
time: DateFormat('kk:mm').format(dateTime),
return InkWell(
onLongPress: (){
Clipboard.setData(ClipboardData(text: message.message));
},
child: MessageTile(
isMe: isMe,
message: message.message,
time: DateFormat('kk:mm').format(dateTime),
),
);
}

Expand All @@ -214,7 +302,11 @@ class _ChatPageState extends State<ChatPage> {
// send Icon button
IconButton(
icon: const Icon(Icons.send),
onPressed: sendMessage,
onPressed: (){
if (_messageController.text.isNotEmpty) {
sendMessage();
}
}
),
],
),
Expand Down
Loading

0 comments on commit b9f18be

Please sign in to comment.