feat: add back navigation to agent network screen and update route transition animation
This commit is contained in:
@@ -21,14 +21,57 @@ class _AppShellState extends State<AppShell> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
// Wire push notification taps to GoRouter navigation
|
// Wire push notification taps to GoRouter navigation
|
||||||
PushNotificationService().onNotificationTap = (actionUrl) {
|
PushNotificationService().onNotificationTap = (actionUrl) {
|
||||||
if (mounted && actionUrl != null && actionUrl.isNotEmpty) {
|
if (!mounted) return;
|
||||||
context.go(actionUrl);
|
if (actionUrl == null || actionUrl.isEmpty) {
|
||||||
} else if (mounted) {
|
|
||||||
context.go('/notifications');
|
context.go('/notifications');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// Translate web routes to mobile routes
|
||||||
|
final mobileRoute = _translateRoute(actionUrl);
|
||||||
|
context.go(mobileRoute);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Translate web-style actionUrl to mobile route.
|
||||||
|
String _translateRoute(String url) {
|
||||||
|
final uri = Uri.parse(url);
|
||||||
|
final path = uri.path;
|
||||||
|
|
||||||
|
// Message notification: /user/message?conversationId=xxx or /agent/message?conversationId=xxx
|
||||||
|
if (path.contains('/message')) {
|
||||||
|
final convId = uri.queryParameters['conversationId'];
|
||||||
|
if (convId != null && convId.isNotEmpty) {
|
||||||
|
return '/messages/chat/$convId';
|
||||||
|
}
|
||||||
|
return '/messages';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connection request/network
|
||||||
|
if (path.contains('/network')) {
|
||||||
|
// Agent sees network, user sees agent search
|
||||||
|
if (path.startsWith('/agent')) {
|
||||||
|
return '/agent/network';
|
||||||
|
}
|
||||||
|
return '/agents/search';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Profile routes
|
||||||
|
if (path.contains('/profiles') || path.contains('/profile')) {
|
||||||
|
return '/home';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's already a valid mobile route, use as-is
|
||||||
|
if (path.startsWith('/messages') ||
|
||||||
|
path.startsWith('/home') ||
|
||||||
|
path.startsWith('/notifications') ||
|
||||||
|
path.startsWith('/agents')) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback
|
||||||
|
return '/notifications';
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|||||||
@@ -151,7 +151,18 @@ class AgentNetworkScreen extends ConsumerWidget {
|
|||||||
width: 0.5),
|
width: 0.5),
|
||||||
borderRadius: BorderRadius.circular(7),
|
borderRadius: BorderRadius.circular(7),
|
||||||
),
|
),
|
||||||
child: const Text(
|
child: Row(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () => context.go('/home'),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.arrow_back_ios_new_rounded,
|
||||||
|
size: 18,
|
||||||
|
color: AppColors.primaryDark,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
const Text(
|
||||||
'Manage My Network',
|
'Manage My Network',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontFamily: 'Fractul',
|
fontFamily: 'Fractul',
|
||||||
@@ -160,6 +171,8 @@ class AgentNetworkScreen extends ConsumerWidget {
|
|||||||
color: AppColors.primaryDark,
|
color: AppColors.primaryDark,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -276,8 +276,14 @@ Widget _fadeTransition(
|
|||||||
Widget child,
|
Widget child,
|
||||||
) {
|
) {
|
||||||
return FadeTransition(
|
return FadeTransition(
|
||||||
opacity: CurveTween(curve: Curves.easeInOut).animate(animation),
|
opacity: CurveTween(curve: Curves.easeOut).animate(animation),
|
||||||
|
child: SlideTransition(
|
||||||
|
position: Tween<Offset>(
|
||||||
|
begin: const Offset(0.02, 0),
|
||||||
|
end: Offset.zero,
|
||||||
|
).animate(CurvedAnimation(parent: animation, curve: Curves.easeOut)),
|
||||||
child: child,
|
child: child,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user