2023-07-17 01:00:16 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:go_router/go_router.dart';
|
2023-09-09 16:48:47 +08:00
|
|
|
|
2024-04-09 17:23:28 +08:00
|
|
|
import '/models/route_state_model.dart';
|
2023-09-09 16:48:47 +08:00
|
|
|
import 'router_key.dart';
|
2024-04-09 17:23:28 +08:00
|
|
|
import '/models/contact_model.dart';
|
|
|
|
import '/models/init_get_it.dart';
|
|
|
|
import '/screens/contact/contact_apply_screen/applicant_profile_screen/applicant_profile_screen.dart';
|
|
|
|
import '/screens/contact_add/create_group_chat_screen.dart';
|
|
|
|
import '/screens/contact/contact_apply_screen/apply_list_screen.dart';
|
|
|
|
import '/screens/contact/contact_screen.dart';
|
|
|
|
import '/screens/contact/manage_group_screen/manage_group_screen.dart';
|
|
|
|
import '/screens/contact_add/add_friend_screen/add_friend_screen.dart';
|
|
|
|
import '/screens/contact_add/search_new_contact_screen.dart';
|
2023-07-17 01:00:16 +08:00
|
|
|
|
2023-10-21 21:25:09 +08:00
|
|
|
final contactRoute = GoRoute(
|
2023-07-17 01:00:16 +08:00
|
|
|
path: '/contact',
|
|
|
|
name: 'Contact',
|
2023-08-03 15:51:18 +08:00
|
|
|
builder: (context, state) {
|
2024-03-16 12:15:13 +08:00
|
|
|
if (state.uri.queryParameters.isNotEmpty) {
|
|
|
|
var deletedFriendId = state.uri.queryParameters['deletedFriendId'];
|
2023-08-27 10:18:31 +08:00
|
|
|
if (deletedFriendId != null) {
|
|
|
|
getIt.get<Contact>().removeFriend(deletedFriendId);
|
|
|
|
getIt.get<ContactAccountProfile>().removeFriend(deletedFriendId);
|
|
|
|
}
|
2023-08-03 15:51:18 +08:00
|
|
|
}
|
2023-09-09 16:48:47 +08:00
|
|
|
getIt.get<RouteState>().changeRoute('Contact');
|
2023-08-03 15:51:18 +08:00
|
|
|
return ContactScreen();
|
|
|
|
},
|
2023-07-17 01:00:16 +08:00
|
|
|
routes: [
|
|
|
|
GoRoute(
|
2023-09-09 16:48:47 +08:00
|
|
|
path: 'search_new_contact',
|
|
|
|
name: 'SearchNewContact',
|
2023-07-27 18:17:52 +08:00
|
|
|
parentNavigatorKey: rootNavigatorKey,
|
2023-09-09 16:48:47 +08:00
|
|
|
builder: (context, state) {
|
|
|
|
return const SearchNewContactScreen();
|
|
|
|
},
|
2023-07-17 01:00:16 +08:00
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: 'friend',
|
|
|
|
name: 'AddFriend',
|
|
|
|
parentNavigatorKey: rootNavigatorKey,
|
2023-09-09 16:48:47 +08:00
|
|
|
builder: (context, state) {
|
|
|
|
return AddFriendScreen(
|
2024-03-16 12:15:13 +08:00
|
|
|
accountProfile: state.uri.queryParameters,
|
2023-09-09 16:48:47 +08:00
|
|
|
);
|
|
|
|
},
|
2023-07-17 01:00:16 +08:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-08-23 16:30:41 +08:00
|
|
|
GoRoute(
|
|
|
|
path: 'create_group_chat',
|
|
|
|
name: 'CreateGroupChat',
|
|
|
|
parentNavigatorKey: rootNavigatorKey,
|
2023-09-09 16:48:47 +08:00
|
|
|
builder: (context, state) {
|
|
|
|
return const CreateGroupChatScreen();
|
|
|
|
},
|
2023-08-23 16:30:41 +08:00
|
|
|
),
|
2023-07-17 01:00:16 +08:00
|
|
|
GoRoute(
|
|
|
|
path: 'apply_list',
|
|
|
|
name: 'ApplyList',
|
2023-07-27 18:17:52 +08:00
|
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
|
|
builder: (context, state) => const ApplyListScreen(),
|
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: 'applicant_profile',
|
|
|
|
name: 'ApplicantProfile',
|
|
|
|
parentNavigatorKey: rootNavigatorKey,
|
2023-09-09 16:48:47 +08:00
|
|
|
builder: (context, state) {
|
|
|
|
return ApplicantProfileScreen(
|
2024-03-16 12:15:13 +08:00
|
|
|
accountProfile: state.uri.queryParameters,
|
2023-09-09 16:48:47 +08:00
|
|
|
);
|
|
|
|
},
|
2023-07-27 18:17:52 +08:00
|
|
|
),
|
|
|
|
],
|
2023-07-17 01:00:16 +08:00
|
|
|
),
|
|
|
|
GoRoute(
|
2023-09-09 16:48:47 +08:00
|
|
|
path: 'manage_group',
|
|
|
|
name: 'ManageGroup',
|
2023-07-27 18:17:52 +08:00
|
|
|
parentNavigatorKey: rootNavigatorKey,
|
2023-07-17 01:00:16 +08:00
|
|
|
pageBuilder: (context, state) {
|
|
|
|
return CustomTransitionPage(
|
|
|
|
key: state.pageKey,
|
2023-09-09 16:48:47 +08:00
|
|
|
child: const ManageGroupScreen(),
|
2023-07-17 01:00:16 +08:00
|
|
|
transitionDuration: const Duration(
|
|
|
|
milliseconds: 200,
|
|
|
|
),
|
|
|
|
reverseTransitionDuration: const Duration(milliseconds: 200),
|
|
|
|
transitionsBuilder: (
|
|
|
|
context,
|
|
|
|
animation,
|
|
|
|
secondaryAnimation,
|
|
|
|
child,
|
|
|
|
) {
|
|
|
|
const begin = Offset(1.0, 0.0);
|
|
|
|
const end = Offset.zero;
|
|
|
|
final tween = Tween(begin: begin, end: end);
|
|
|
|
final offsetAnimation = animation.drive(tween);
|
|
|
|
return SlideTransition(
|
|
|
|
position: offsetAnimation,
|
|
|
|
child: child,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
2023-09-09 16:48:47 +08:00
|
|
|
builder: (context, state) {
|
|
|
|
return const ManageGroupScreen();
|
|
|
|
},
|
2023-07-17 01:00:16 +08:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|