Skip to content

Commit

Permalink
profile screen dialog with last seen active functionality added
Browse files Browse the repository at this point in the history
  • Loading branch information
rudramistry001 committed Feb 9, 2024
1 parent 776fdd1 commit a0ee326
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 40 deletions.
10 changes: 10 additions & 0 deletions login/lib/api/apis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,14 @@ class APIs {
.where('id', isEqualTo: chatUser.Id)
.snapshots();
}

//for updating last seen of user

// update online or last active status of user
// static Future<void> updateActiveStatus(bool isOnline) async {
// firestore.collection('users').doc(user.uid).update({
// 'is_online': isOnline,
// 'last_active': DateTime.now().millisecondsSinceEpoch.toString(),
// 'push_token': me.PushToken,
// });
}
1 change: 1 addition & 0 deletions login/lib/auth/loginscreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class _LoginPageState extends State<LoginPage> {
print('Email: ${emailController.text}');
print('Password: ${passwordController.text}');
_signIn();
APIs.updateActiveStatus(true);
},
child: const Text('Login'),
),
Expand Down
102 changes: 62 additions & 40 deletions login/lib/dialogs/profile_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:login/model/chat_user_model.dart';

import '../../main.dart';
Expand All @@ -17,61 +18,82 @@ class ProfileDialog extends StatelessWidget {
return AlertDialog(
contentPadding: EdgeInsets.zero,
backgroundColor: Colors.white.withOpacity(.9),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
content: SizedBox(
width: mq.width * .6,
height: mq.height * .35,
child: Stack(
children: [
//user profile picture
Positioned(
top: mq.height * .075,
left: mq.width * .1,
child: ClipRRect(
borderRadius: BorderRadius.circular(mq.height * .25),
child: CachedNetworkImage(
width: mq.width * .5,
fit: BoxFit.cover,
imageUrl: user.Image,
errorWidget: (context, url, error) =>
const CircleAvatar(child: Icon(CupertinoIcons.person)),
width: mq.width * .6,
height: mq.height * .35,
child: Column(
children: [
Padding(
padding: EdgeInsets.only(left: 10.sp),
child: Row(
children: [
//user name
Expanded(
child: Text(
user.Name,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
),
),

//user name
Positioned(
left: mq.width * .04,
top: mq.height * .02,
width: mq.width * .55,
child: Text(user.Name,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w500)),
),

//info button
Positioned(
right: 8,
top: 6,
child: MaterialButton(
//info button
MaterialButton(
onPressed: () {
//for hiding image dialog
Navigator.pop(context);

//move to view profile screen
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ViewProfileScreen(user: user)));
context,
MaterialPageRoute(
builder: (_) => ViewProfileScreen(user: user),
),
);
},
minWidth: 0,
padding: const EdgeInsets.all(0),
shape: const CircleBorder(),
child: const Icon(Icons.info_outline,
color: Colors.blue, size: 30),
))
],
)),
),
],
),
),
// //user profile picture
// ClipRRect(
// borderRadius: BorderRadius.circular(100),
// child: CachedNetworkImage(
// width: mq.width * .2,
// height: mq.height * .2,
// fit: BoxFit.contain,
// imageUrl: user.Image,
// errorWidget: (context, url, error) => const CircleAvatar(
// child: Icon(CupertinoIcons.person),
// ),
// ),
// ),
15.verticalSpace,

ClipRRect(
borderRadius: BorderRadius.circular(mq.height * 1),
child: CachedNetworkImage(
width: mq.height * .22,
height: mq.height * .22,
fit: BoxFit.cover,
imageUrl: user.Image,
errorWidget: (context, url, error) =>
const CircleAvatar(child: Icon(CupertinoIcons.person)),
),
),
],
),
),
);
}
}
1 change: 1 addition & 0 deletions login/lib/screens/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
backgroundColor: Colors.lightBlue,
onPressed: () async {
Dialogs.showProgressBar(context);
await APIs.updateActiveStatus(false);
await APIs.auth.signOut().then((value) async {
Navigator.pop(context);
Navigator.pop(context);
Expand Down

0 comments on commit a0ee326

Please sign in to comment.