feat: Enable direct chat initiation from agent network, improve GIF rendering in chat, and fix message order and webview authentication.
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||
import 'package:real_estate_mobile/core/widgets/s3_image.dart';
|
||||
import 'package:real_estate_mobile/features/agents/presentation/providers/agent_network_provider.dart';
|
||||
import 'package:real_estate_mobile/features/messaging/presentation/providers/messaging_provider.dart';
|
||||
|
||||
class AgentNetworkScreen extends ConsumerWidget {
|
||||
const AgentNetworkScreen({super.key});
|
||||
@@ -406,19 +407,53 @@ class _RequestCard extends ConsumerWidget {
|
||||
}
|
||||
|
||||
// ── Connection Card (accepted connections in Manage My Network) ──
|
||||
class _ConnectionCard extends StatelessWidget {
|
||||
class _ConnectionCard extends ConsumerStatefulWidget {
|
||||
final Map<String, dynamic> data;
|
||||
|
||||
const _ConnectionCard({required this.data});
|
||||
|
||||
@override
|
||||
ConsumerState<_ConnectionCard> createState() => _ConnectionCardState();
|
||||
}
|
||||
|
||||
class _ConnectionCardState extends ConsumerState<_ConnectionCard> {
|
||||
bool _isStartingChat = false;
|
||||
|
||||
Future<void> _openChat() async {
|
||||
if (_isStartingChat) return;
|
||||
|
||||
final userId = widget.data['userId'] as String?;
|
||||
if (userId == null) {
|
||||
context.push('/messages');
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() => _isStartingChat = true);
|
||||
try {
|
||||
final conversationId = await ref
|
||||
.read(messagingProvider.notifier)
|
||||
.startConversationWithUser(userId);
|
||||
if (!mounted) return;
|
||||
if (conversationId != null) {
|
||||
context.push('/messages/chat/$conversationId');
|
||||
} else {
|
||||
context.push('/messages');
|
||||
}
|
||||
} catch (_) {
|
||||
if (mounted) context.push('/messages');
|
||||
} finally {
|
||||
if (mounted) setState(() => _isStartingChat = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = data['user'] as Map<String, dynamic>? ?? {};
|
||||
final user = widget.data['user'] as Map<String, dynamic>? ?? {};
|
||||
final userName =
|
||||
user['email'] as String? ?? user['name'] as String? ?? 'User';
|
||||
final userEmail = user['email'] as String? ?? '';
|
||||
final avatar = user['avatar'] as String?;
|
||||
final respondedAt = data['respondedAt'] as String?;
|
||||
final respondedAt = widget.data['respondedAt'] as String?;
|
||||
final connectedDate = _formatConnectedDate(respondedAt);
|
||||
|
||||
return Padding(
|
||||
@@ -499,10 +534,7 @@ class _ConnectionCard extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
// Message button
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// Navigate to messages — if we have userId, could create/open conversation
|
||||
context.push('/messages');
|
||||
},
|
||||
onTap: _isStartingChat ? null : _openChat,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
@@ -510,8 +542,17 @@ class _ConnectionCard extends StatelessWidget {
|
||||
shape: BoxShape.circle,
|
||||
color: AppColors.accentOrange.withValues(alpha: 0.1),
|
||||
),
|
||||
child: const Icon(Icons.chat_bubble_outline,
|
||||
size: 18, color: AppColors.accentOrange),
|
||||
child: _isStartingChat
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.chat_bubble_outline,
|
||||
size: 18, color: AppColors.accentOrange),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user