From b9f18be996815c4638c5e8859f618862063a46ba Mon Sep 17 00:00:00 2001 From: Antonio Pedro Date: Mon, 4 Dec 2023 19:20:06 +0530 Subject: [PATCH 1/2] flag, chat, user profile, interests --- .gitignore | 2 +- lib/app/bloc/auth/auth_event.dart | 2 +- lib/app/data/model/chat/conversation.dart | 1 - lib/app/data/model/user.dart | 6 + lib/app/data/services/meeting.dart | 17 +- lib/app/views/screens/auth/otp_screen.dart | 2 +- lib/app/views/screens/auth/signup.dart | 23 +- lib/app/views/screens/auth/user_detail.dart | 40 ++- lib/app/views/screens/chat/chat.dart | 1 - lib/app/views/screens/chat/chat_page.dart | 104 +++++++- lib/app/views/screens/home/home.dart | 19 +- .../views/screens/profile/user_profile.dart | 231 ++++++++++++++++++ lib/app/views/screens/schedule/create.dart | 12 +- .../schedule/meeting_details_page.dart | 64 ++--- lib/app/views/screens/search/search.dart | 19 +- 15 files changed, 472 insertions(+), 71 deletions(-) create mode 100644 lib/app/views/screens/profile/user_profile.dart diff --git a/.gitignore b/.gitignore index 2f5b817..a586437 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/lib/app/bloc/auth/auth_event.dart b/lib/app/bloc/auth/auth_event.dart index 4537d8c..cef9e4f 100644 --- a/lib/app/bloc/auth/auth_event.dart +++ b/lib/app/bloc/auth/auth_event.dart @@ -19,4 +19,4 @@ final class AuthLogout extends AuthEvent {} final class AuthLoginWithGoogle extends AuthEvent {} -final class AuthSignUpWithGoogle extends AuthEvent {} \ No newline at end of file +final class AuthSignUpWithGoogle extends AuthEvent {} diff --git a/lib/app/data/model/chat/conversation.dart b/lib/app/data/model/chat/conversation.dart index 59356ff..929ea1a 100644 --- a/lib/app/data/model/chat/conversation.dart +++ b/lib/app/data/model/chat/conversation.dart @@ -13,7 +13,6 @@ class ChatConversation { final bool? hasUnreadMessages; final List users; final int? unreadMessagesCount; - ChatConversation({ this.id, diff --git a/lib/app/data/model/user.dart b/lib/app/data/model/user.dart index 198725e..8787dec 100644 --- a/lib/app/data/model/user.dart +++ b/lib/app/data/model/user.dart @@ -12,6 +12,7 @@ class DBUser { bool? isMentor; String? email; bool? isProfileComplete; + List? topics; // Added topics property DBUser({ this.college, @@ -27,6 +28,7 @@ class DBUser { this.isMentor, this.email, this.isProfileComplete, + this.topics, // Added topics parameter in the constructor }); DBUser.fromJson(Map json) { @@ -43,6 +45,9 @@ class DBUser { isMentor = json['isMentor']; email = json['email']; isProfileComplete = json['isProfileComplete']; + topics = json['topics'] != null + ? List.from(json['topics']) + : null; // Added topics assignment } Map toJson() { @@ -60,6 +65,7 @@ class DBUser { data['isMentor'] = isMentor; data['email'] = email; data['isProfileComplete'] = isProfileComplete; + data['topics'] = topics; // Added topics assignment return data; } } diff --git a/lib/app/data/services/meeting.dart b/lib/app/data/services/meeting.dart index 607f097..917c21b 100644 --- a/lib/app/data/services/meeting.dart +++ b/lib/app/data/services/meeting.dart @@ -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 deleteMeeting(String eventId) async { await _firestore.collection('meetings').doc(eventId).delete(); } @@ -43,4 +52,4 @@ class MeetingService { var userDocument = await _firestore.collection('users').doc(userId).get(); return userDocument.data()?['name'] ?? 'Unknown User'; } -} \ No newline at end of file +} diff --git a/lib/app/views/screens/auth/otp_screen.dart b/lib/app/views/screens/auth/otp_screen.dart index 9a5324b..a22aa4c 100644 --- a/lib/app/views/screens/auth/otp_screen.dart +++ b/lib/app/views/screens/auth/otp_screen.dart @@ -134,7 +134,7 @@ class _OTPScreenState extends State { child: TextFormField( controller: controller, textAlign: TextAlign.center, - canRequestFocus: true, + // canRequestFocus: true, keyboardType: TextInputType.number, style: TextStyle(color: Theme.of(context).primaryColor, fontSize: 24), onEditingComplete: () { diff --git a/lib/app/views/screens/auth/signup.dart b/lib/app/views/screens/auth/signup.dart index 496eaea..27da29a 100644 --- a/lib/app/views/screens/auth/signup.dart +++ b/lib/app/views/screens/auth/signup.dart @@ -168,13 +168,22 @@ class _SignUpScreenState extends State { rounded: true, onPressed: () { if (formKey.currentState!.validate()) { - BlocProvider.of(context).add(AuthSignUp( - user: UserAuthSignUp( - name: nameController.text, - email: mailController.text, - password: passwordController.text, - ), - )); + if (mailController.text.endsWith("@iiitd.ac.in")) { + BlocProvider.of(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")), diff --git a/lib/app/views/screens/auth/user_detail.dart b/lib/app/views/screens/auth/user_detail.dart index 6162fed..f067ec2 100644 --- a/lib/app/views/screens/auth/user_detail.dart +++ b/lib/app/views/screens/auth/user_detail.dart @@ -43,6 +43,9 @@ class _UserDetailsScreenState extends State { 'PhD': ['CB', 'CSE', 'ECE', 'HCD', 'Maths', 'SSH'], }; + final List topics = []; + final List selectedTopics = []; + @override void initState() { super.initState(); @@ -50,6 +53,16 @@ class _UserDetailsScreenState extends State { 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 @@ -80,6 +93,8 @@ class _UserDetailsScreenState extends State { child: Form( key: formKey, child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ CustomTextBox( controller: yearOfGraduationController, @@ -145,6 +160,27 @@ class _UserDetailsScreenState extends State { 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( @@ -161,6 +197,7 @@ class _UserDetailsScreenState extends State { isMentor: isMentor, college: collegeController.text, company: companyController.text, + topics: selectedTopics, adminApproval: false, isProfileComplete: true); @@ -173,7 +210,8 @@ class _UserDetailsScreenState extends State { course: selectedCourse, branch: selectedBranch, isMentor: isMentor, - adminApproval: false, + topics: [], + adminApproval: true, isProfileComplete: true); if (isMentor) { diff --git a/lib/app/views/screens/chat/chat.dart b/lib/app/views/screens/chat/chat.dart index 315389e..556169a 100644 --- a/lib/app/views/screens/chat/chat.dart +++ b/lib/app/views/screens/chat/chat.dart @@ -92,7 +92,6 @@ class _ChatScreenState extends State { return InkResponse( child: ConversationTile( chat: chatRoom, - ), onTap: () { final otherUser = chatRoom.users.firstWhere( diff --git a/lib/app/views/screens/chat/chat_page.dart b/lib/app/views/screens/chat/chat_page.dart index 9949070..47de299 100644 --- a/lib/app/views/screens/chat/chat_page.dart +++ b/lib/app/views/screens/chat/chat_page.dart @@ -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'; @@ -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}); @@ -28,6 +30,7 @@ class _ChatPageState extends State { final currentUser = FirebaseAuth.instance.currentUser; final db = FirebaseFirestore.instance; String currentChatId = ""; + bool reported = false; @override void initState() { @@ -112,7 +115,87 @@ class _ChatPageState extends State { 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()), + ), + ); + }); + } + }); + }, ), ], ), @@ -186,10 +269,15 @@ class _ChatPageState extends State { //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), + ), ); } @@ -214,7 +302,11 @@ class _ChatPageState extends State { // send Icon button IconButton( icon: const Icon(Icons.send), - onPressed: sendMessage, + onPressed: (){ + if (_messageController.text.isNotEmpty) { + sendMessage(); + } + } ), ], ), diff --git a/lib/app/views/screens/home/home.dart b/lib/app/views/screens/home/home.dart index 78aee7b..06990c4 100644 --- a/lib/app/views/screens/home/home.dart +++ b/lib/app/views/screens/home/home.dart @@ -4,6 +4,7 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:iiitd_mentorship/app/data/model/mentor.dart'; import 'package:iiitd_mentorship/app/data/model/user.dart'; +import 'package:iiitd_mentorship/app/views/screens/profile/user_profile.dart'; import 'package:iiitd_mentorship/app/views/widgets/mentor_tile.dart'; import 'package:iiitd_mentorship/app/views/widgets/session_action.dart'; import 'package:iiitd_mentorship/app/views/widgets/topic_tile.dart'; @@ -33,6 +34,7 @@ class _MyHomePageState extends State { return FirebaseFirestore.instance .collection("users") .where("isMentor", isEqualTo: true) + // .where("uid", isNotEqualTo: currentUser!.uid) .snapshots(); } @@ -170,7 +172,7 @@ class _MyHomePageState extends State { }) .toList() .where((element) { - return element.uid != currentUser!.uid; + return element.uid != currentUser!.uid && element.adminApproval!; }) .toList(); @@ -184,8 +186,19 @@ class _MyHomePageState extends State { width: MediaQuery.of(context).size.width * 0.7, - child: MentorTile( - mentor: mentorsList[index], + child: InkResponse( + onTap: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + UserProfileScreen( + user: mentorsList[ + index])), + ); + }, + child: MentorTile( + mentor: mentorsList[index], + ), )); }, ), diff --git a/lib/app/views/screens/profile/user_profile.dart b/lib/app/views/screens/profile/user_profile.dart new file mode 100644 index 0000000..3eb64f7 --- /dev/null +++ b/lib/app/views/screens/profile/user_profile.dart @@ -0,0 +1,231 @@ +import 'package:flutter/material.dart'; +import 'package:iiitd_mentorship/app/data/model/user.dart'; +import 'package:iiitd_mentorship/app/views/screens/chat/chat_page.dart'; +import 'package:iiitd_mentorship/app/views/screens/schedule/create.dart'; + +class UserProfileScreen extends StatefulWidget { + const UserProfileScreen({super.key, required this.user}); + + final DBUser user; + + @override + State createState() => _UserProfileScreenState(); +} + +class _UserProfileScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: 200, + flexibleSpace: FlexibleSpaceBar( + title: Text( + widget.user.name!, + style: const TextStyle( + fontWeight: FontWeight.bold, + + ), + ), + background: Image.network( + (widget.user.photoUrl == null || widget.user.photoUrl!.isEmpty) + ? 'https://images.unsplash.com/photo-1531384441138-2736e62e0919?auto=format&fit=crop&q=80&w=1587&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D' + : widget.user.photoUrl!, + fit: BoxFit.cover, + ), + ), + floating: true, + pinned: true, + + actions: [ + IconButton( + onPressed: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: const Text("Report"), + content: const Text( + "Are you sure you want to report this user?"), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("Cancel"), + ), + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("Report"), + ), + ], + ); + }, + ); + }, + icon: const Icon(Icons.flag, color: Colors.black), + ), + ], + ), + SliverList( + delegate: SliverChildListDelegate( + [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.user.name!, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.black), + ), + Text( + widget.user.email!, + ), + const SizedBox(height: 4), + Text( + "Currently working at ${widget.user.company ?? widget.user.college ?? 'IIITD'}. This is some random text to fill the space.", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w200, + ), + ), + const SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkResponse( + child: Chip( + label: const Text("Send message"), + avatar: const Icon( + Icons.chat_bubble_outline, + color: Colors.white, + ), + labelPadding: const EdgeInsets.all(8), + backgroundColor: Theme.of(context).primaryColor, + labelStyle: const TextStyle( + color: Colors.white, + ), + ), + onTap: () { + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (context) => + ChatPage(receiverUser: widget.user), + ), + ); + }, + ), + const SizedBox(width: 16), + InkResponse( + child: const Chip( + label: Text("New meeting"), + avatar: Icon(Icons.today_outlined, + color: Colors.black54), + labelPadding: EdgeInsets.all(8), + backgroundColor: Colors.white, + labelStyle: TextStyle( + color: Colors.black54, + ), + side: BorderSide( + color: Colors.black54, + ), + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ScheduleMeetingScreen( + email: widget.user.email!, + title: + "Meeting with ${widget.user.name}"))); + }, + ), + ], + ), + const SizedBox(height: 16), + ListTile( + leading: const Icon(Icons.school), + title: const Text( + 'Current Company/College', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + subtitle: Text( + widget.user.company ?? widget.user.college ?? 'IIITD', + style: const TextStyle( + fontSize: 14, + ), + ), + ), + ListTile( + leading: const Icon(Icons.school), + title: const Text( + 'Branch', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + subtitle: Text( + widget.user.branch!, + style: const TextStyle( + fontSize: 14, + ), + ), + ), + ListTile( + leading: const Icon(Icons.today), + title: const Text( + 'Year', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + subtitle: Text( + widget.user.yearOfGraduation!, + style: const TextStyle( + fontSize: 14, + ), + ), + ), + const Divider(), + Text( + 'Topics ${widget.user.name!} can help with', + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 8), + Wrap( + spacing: 8, + runSpacing: 8, + children: + (widget.user.topics != null || widget.user.topics!.isNotEmpty)? + widget.user.topics! + .map( + (interest) => Chip( + label: Text(interest), + ), + ) + .toList() : [const Text("No topics selected")], + + ), + ], + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/app/views/screens/schedule/create.dart b/lib/app/views/screens/schedule/create.dart index a72f524..58789cc 100644 --- a/lib/app/views/screens/schedule/create.dart +++ b/lib/app/views/screens/schedule/create.dart @@ -6,8 +6,9 @@ import 'package:iiitd_mentorship/app/views/widgets/custom_button.dart'; import 'package:iiitd_mentorship/app/views/widgets/custom_textbox.dart'; class ScheduleMeetingScreen extends StatefulWidget { - const ScheduleMeetingScreen({super.key}); - + const ScheduleMeetingScreen({super.key, this.title, this.email}); + final String? title; + final String? email; @override State createState() => _ScheduleMeetingScreenState(); } @@ -21,6 +22,13 @@ class _ScheduleMeetingScreenState extends State { TimeOfDay _endTime = TimeOfDay.now(); final formKey = GlobalKey(); + @override + void initState() { + super.initState(); + _titleController.text = widget.title ?? ''; + _emailController.text = widget.email ?? ''; + } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/views/screens/schedule/meeting_details_page.dart b/lib/app/views/screens/schedule/meeting_details_page.dart index 6c51d12..7ade715 100644 --- a/lib/app/views/screens/schedule/meeting_details_page.dart +++ b/lib/app/views/screens/schedule/meeting_details_page.dart @@ -14,38 +14,38 @@ class MeetingDetailsPage extends StatelessWidget { title: const Text('Meeting Details'), elevation: 0, ), - body: FutureBuilder( - future: MeetingService.getUserName(meeting.userId), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const Center(child: CircularProgressIndicator()); - } - if (!snapshot.hasData || snapshot.data == 'Unknown User') { - return Center(child: Text('No Creator Information Available')); - } - return SingleChildScrollView( - child: Container( - padding: const EdgeInsets.all(16.0), - child: Column( - children: [ - _creatorNameCard(context, snapshot.data!), - meetingDetailCard(context, Icons.title, 'Title', meeting.title), - meetingDetailCard(context, Icons.description, 'Description', - meeting.description), - meetingDetailCard( - context, Icons.email, 'Invitees', meeting.emailIDs), - meetingDetailCard(context, Icons.calendar_today, 'Start', - meeting.from.toString()), - meetingDetailCard( - context, Icons.calendar_today, 'End', meeting.to.toString()), - const SizedBox(height: 20), - cancelMeetingButton(context), - ], - ), - ), - ); - } - ), + body: FutureBuilder( + future: MeetingService.getUserName(meeting.userId), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } + if (!snapshot.hasData || snapshot.data == 'Unknown User') { + return Center(child: Text('No Creator Information Available')); + } + return SingleChildScrollView( + child: Container( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + _creatorNameCard(context, snapshot.data!), + meetingDetailCard( + context, Icons.title, 'Title', meeting.title), + meetingDetailCard(context, Icons.description, 'Description', + meeting.description), + meetingDetailCard( + context, Icons.email, 'Invitees', meeting.emailIDs), + meetingDetailCard(context, Icons.calendar_today, 'Start', + meeting.from.toString()), + meetingDetailCard(context, Icons.calendar_today, 'End', + meeting.to.toString()), + const SizedBox(height: 20), + cancelMeetingButton(context), + ], + ), + ), + ); + }), ); } diff --git a/lib/app/views/screens/search/search.dart b/lib/app/views/screens/search/search.dart index 993c58a..d7d843c 100644 --- a/lib/app/views/screens/search/search.dart +++ b/lib/app/views/screens/search/search.dart @@ -3,6 +3,7 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:iiitd_mentorship/app/data/model/user.dart'; import 'package:iiitd_mentorship/app/views/screens/chat/chat_page.dart'; +import 'package:iiitd_mentorship/app/views/screens/profile/user_profile.dart'; import 'package:iiitd_mentorship/app/views/screens/search/widgets/mentor_result_tile.dart'; import 'package:iiitd_mentorship/app/views/widgets/custom_textbox.dart'; @@ -30,6 +31,7 @@ class _SearchScreenState extends State { return FirebaseFirestore.instance .collection('users') .where('name', isGreaterThanOrEqualTo: search) + .where('adminApproval', isEqualTo: true) .get() .asStream(); } @@ -138,6 +140,8 @@ class _SearchScreenState extends State { Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (context) => ChatPage( + receiverId: + mentorsFiltered[index].uid, receiverUser: mentorsFiltered[index]), ), @@ -145,17 +149,10 @@ class _SearchScreenState extends State { } else { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => Scaffold( - appBar: AppBar( - title: Text( - mentorsFiltered[index].name!), - ), - body: Center( - child: Text( - mentorsFiltered[index].name!), - ), - ), - ), + builder: (context) => + UserProfileScreen( + user: mentorsFiltered[ + index])), ); } }, From 1d2598a270fd79831078969818b4b3f4ad915abc Mon Sep 17 00:00:00 2001 From: Antonio Pedro Date: Mon, 4 Dec 2023 19:25:57 +0530 Subject: [PATCH 2/2] small fixes --- lib/app/views/screens/chat/chat_page.dart | 16 ++++------ lib/app/views/screens/home/home.dart | 3 +- .../views/screens/profile/user_profile.dart | 32 +++++++++---------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/lib/app/views/screens/chat/chat_page.dart b/lib/app/views/screens/chat/chat_page.dart index 47de299..5d47d41 100644 --- a/lib/app/views/screens/chat/chat_page.dart +++ b/lib/app/views/screens/chat/chat_page.dart @@ -10,7 +10,6 @@ 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}); @@ -270,7 +269,7 @@ class _ChatPageState extends State { var isMe = message.senderId == currentUser!.uid; return InkWell( - onLongPress: (){ + onLongPress: () { Clipboard.setData(ClipboardData(text: message.message)); }, child: MessageTile( @@ -301,13 +300,12 @@ class _ChatPageState extends State { // send Icon button IconButton( - icon: const Icon(Icons.send), - onPressed: (){ - if (_messageController.text.isNotEmpty) { - sendMessage(); - } - } - ), + icon: const Icon(Icons.send), + onPressed: () { + if (_messageController.text.isNotEmpty) { + sendMessage(); + } + }), ], ), ), diff --git a/lib/app/views/screens/home/home.dart b/lib/app/views/screens/home/home.dart index 06990c4..e4f162a 100644 --- a/lib/app/views/screens/home/home.dart +++ b/lib/app/views/screens/home/home.dart @@ -172,7 +172,8 @@ class _MyHomePageState extends State { }) .toList() .where((element) { - return element.uid != currentUser!.uid && element.adminApproval!; + return element.uid != currentUser!.uid && + element.adminApproval!; }) .toList(); diff --git a/lib/app/views/screens/profile/user_profile.dart b/lib/app/views/screens/profile/user_profile.dart index 3eb64f7..5930630 100644 --- a/lib/app/views/screens/profile/user_profile.dart +++ b/lib/app/views/screens/profile/user_profile.dart @@ -21,13 +21,12 @@ class _UserProfileScreenState extends State { SliverAppBar( expandedHeight: 200, flexibleSpace: FlexibleSpaceBar( - title: Text( - widget.user.name!, - style: const TextStyle( - fontWeight: FontWeight.bold, - + title: Text( + widget.user.name!, + style: const TextStyle( + fontWeight: FontWeight.bold, + ), ), - ), background: Image.network( (widget.user.photoUrl == null || widget.user.photoUrl!.isEmpty) ? 'https://images.unsplash.com/photo-1531384441138-2736e62e0919?auto=format&fit=crop&q=80&w=1587&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D' @@ -37,7 +36,6 @@ class _UserProfileScreenState extends State { ), floating: true, pinned: true, - actions: [ IconButton( onPressed: () { @@ -207,16 +205,16 @@ class _UserProfileScreenState extends State { Wrap( spacing: 8, runSpacing: 8, - children: - (widget.user.topics != null || widget.user.topics!.isNotEmpty)? - widget.user.topics! - .map( - (interest) => Chip( - label: Text(interest), - ), - ) - .toList() : [const Text("No topics selected")], - + children: (widget.user.topics != null || + widget.user.topics!.isNotEmpty) + ? widget.user.topics! + .map( + (interest) => Chip( + label: Text(interest), + ), + ) + .toList() + : [const Text("No topics selected")], ), ], ),