Skip to content
Merged

#124 #125

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 97 additions & 77 deletions mobile/lib/pages/chat_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:mobile/controllers/auth.dart';
import 'package:mobile/controllers/chat.dart';
import 'package:mobile/pages/chat_page.dart';
import 'package:mobile/providers/group_controller_provider.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -297,88 +298,107 @@ class _ChatDetailsPageState extends State<ChatDetailsPage> {
showModalBottomSheet(
context: context,
builder: (context) {
return SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text('Message ${member.displayName}'),
onTap: () {
/* Navigate to 1-on-1 chat */
},
),
ListTile(
title: Text('View Profile (@${member.username})'),
onTap: () {
Navigator.pop(context);
},
),
if (isCurrentUserAdmin &&
member.userId != context.read<AuthState>().currentUser?.id)
ListTile(
title: const Text(
'Remove from group',
style: TextStyle(color: Colors.red),
),
onTap: () async {
Navigator.pop(context);
final confirm = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Remove Participant'),
content: Text(
'Are you sure you want to remove ${member.displayName} from this group?',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
Navigator.pop(context, true);
},
child: const Text(
'Remove',
style: TextStyle(color: Colors.red),
),
return ClipRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text('Message @${member.username}'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ChatPage(
chatUserId: member.userId,
displayName: member.displayName,
isGroup: false,
),
],
),
);

if (confirm == true && mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Removing member...'),
duration: Duration(seconds: 1),
),
);

final success = await context
.read<GroupController>()
.removeMemberFromGroup(widget.chatId, member.userId);

if (success && mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('${member.displayName} removed.'),
),
);
context.read<ChatController>().fetchGroupMembers(
widget.chatId,
);
} else if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Failed to remove member.'),
},
),
// feels redundent to have a view profile option since we don't have a profile page yet
// ListTile(
// title: Text('View Profile (@${member.username})'),
// onTap: () {
// Navigator.pop(context);
// },
// ),
if (isCurrentUserAdmin &&
member.userId !=
context.read<AuthState>().currentUser?.id)
ListTile(
title: const Text(
'Remove from group',
style: TextStyle(color: Colors.red),
),
onTap: () async {
Navigator.pop(context);
final confirm = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Remove Participant'),
content: Text(
'Are you sure you want to remove ${member.displayName} from this group?',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
Navigator.pop(context, true);
},
child: const Text(
'Remove',
style: TextStyle(color: Colors.red),
),
),
],
),
);
}
}
},
),
],

if (confirm == true && mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Removing member...'),
duration: Duration(seconds: 1),
),
);

final success = await context
.read<GroupController>()
.removeMemberFromGroup(
widget.chatId,
member.userId,
);

if (success && mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('${member.displayName} removed.'),
),
);
context.read<ChatController>().fetchGroupMembers(
widget.chatId,
);
} else if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Failed to remove member.'),
),
);
}
}
},
),
],
),
),
),
);
},
Expand Down
65 changes: 36 additions & 29 deletions mobile/lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,37 +171,44 @@ class SettingsPage extends StatelessWidget {
),
),
SizedBox(width: 20),
Hero(
tag: 'User Data',
child: Material(
type: MaterialType.transparency,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Spacer(),
Text(
user != null ? user.displayName : 'Profile N/A',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Theme.of(
context,
).colorScheme.onSurface,
Expanded(
child: Hero(
tag: 'User Data',
child: Material(
type: MaterialType.transparency,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Spacer(),
Text(
user != null
? user.displayName
: 'Profile N/A',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Theme.of(
context,
).colorScheme.onSurface,
),
softWrap: true,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
Text(
user != null
? '@${user.username}'
: 'Could not load profile',
style: TextStyle(
fontSize: 12,
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
Text(
user != null
? '@${user.username}'
: 'Could not load profile',
style: TextStyle(
fontSize: 12,
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
),
),
Spacer(),
],
Spacer(),
],
),
),
),
),
Expand Down
Loading