2024-05-18 10:17:16 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
2024-05-26 15:13:43 +00:00
|
|
|
import 'package:solian/models/channel.dart';
|
2024-05-29 14:42:11 +00:00
|
|
|
import 'package:solian/models/realm.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
import 'package:solian/screens/account.dart';
|
2024-05-23 13:12:47 +00:00
|
|
|
import 'package:solian/screens/account/friend.dart';
|
2024-05-22 15:18:01 +00:00
|
|
|
import 'package:solian/screens/account/personalize.dart';
|
2024-05-25 17:21:08 +00:00
|
|
|
import 'package:solian/screens/channel/channel_chat.dart';
|
2024-05-26 15:13:43 +00:00
|
|
|
import 'package:solian/screens/channel/channel_detail.dart';
|
2024-05-25 16:11:00 +00:00
|
|
|
import 'package:solian/screens/channel/channel_organize.dart';
|
2024-05-23 13:12:47 +00:00
|
|
|
import 'package:solian/screens/contact.dart';
|
2024-05-25 05:19:16 +00:00
|
|
|
import 'package:solian/screens/posts/post_detail.dart';
|
2024-05-28 14:13:23 +00:00
|
|
|
import 'package:solian/screens/realms.dart';
|
2024-05-29 14:42:11 +00:00
|
|
|
import 'package:solian/screens/realms/realm_detail.dart';
|
2024-05-28 14:13:23 +00:00
|
|
|
import 'package:solian/screens/realms/realm_organize.dart';
|
2024-05-29 14:42:11 +00:00
|
|
|
import 'package:solian/screens/realms/realm_view.dart';
|
2024-05-23 12:00:26 +00:00
|
|
|
import 'package:solian/screens/social.dart';
|
2024-05-25 16:11:00 +00:00
|
|
|
import 'package:solian/screens/posts/post_publish.dart';
|
2024-05-22 15:18:01 +00:00
|
|
|
import 'package:solian/shells/basic_shell.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
import 'package:solian/shells/nav_shell.dart';
|
|
|
|
|
2024-05-18 16:56:32 +00:00
|
|
|
abstract class AppRouter {
|
2024-05-18 10:17:16 +00:00
|
|
|
static GoRouter instance = GoRouter(
|
|
|
|
routes: [
|
|
|
|
ShellRoute(
|
2024-05-21 16:05:03 +00:00
|
|
|
builder: (context, state, child) =>
|
2024-05-28 16:14:41 +00:00
|
|
|
NavShell(state: state, showAppBar: false, child: child),
|
2024-05-18 10:17:16 +00:00
|
|
|
routes: [
|
|
|
|
GoRoute(
|
2024-05-22 15:18:01 +00:00
|
|
|
path: '/',
|
2024-05-23 12:00:26 +00:00
|
|
|
name: 'social',
|
|
|
|
builder: (context, state) => const SocialScreen(),
|
2024-05-18 10:17:16 +00:00
|
|
|
),
|
2024-05-23 13:12:47 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/contact',
|
|
|
|
name: 'contact',
|
|
|
|
builder: (context, state) => const ContactScreen(),
|
|
|
|
),
|
2024-05-28 14:13:23 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/realms',
|
|
|
|
name: 'realms',
|
|
|
|
builder: (context, state) => const RealmListScreen(),
|
|
|
|
),
|
2024-05-18 10:17:16 +00:00
|
|
|
GoRoute(
|
2024-05-22 15:18:01 +00:00
|
|
|
path: '/account',
|
|
|
|
name: 'account',
|
2024-05-18 10:17:16 +00:00
|
|
|
builder: (context, state) => const AccountScreen(),
|
|
|
|
),
|
2024-05-22 15:18:01 +00:00
|
|
|
],
|
|
|
|
),
|
2024-05-25 05:19:16 +00:00
|
|
|
ShellRoute(
|
|
|
|
builder: (context, state, child) =>
|
|
|
|
BasicShell(state: state, child: child),
|
|
|
|
routes: [
|
|
|
|
GoRoute(
|
2024-05-27 15:07:01 +00:00
|
|
|
path: '/posts/view/:alias',
|
2024-05-25 05:19:16 +00:00
|
|
|
name: 'postDetail',
|
|
|
|
builder: (context, state) => PostDetailScreen(
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-05-29 14:42:11 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/posts/publish',
|
|
|
|
name: 'postPublishing',
|
|
|
|
builder: (context, state) {
|
|
|
|
final arguments = state.extra as PostPublishingArguments?;
|
|
|
|
return PostPublishingScreen(
|
|
|
|
edit: arguments?.edit,
|
|
|
|
reply: arguments?.reply,
|
|
|
|
repost: arguments?.repost,
|
|
|
|
realm: arguments?.realm,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-05-22 15:18:01 +00:00
|
|
|
ShellRoute(
|
|
|
|
builder: (context, state, child) =>
|
|
|
|
BasicShell(state: state, child: child),
|
|
|
|
routes: [
|
2024-05-23 13:12:47 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/account/friend',
|
|
|
|
name: 'accountFriend',
|
|
|
|
builder: (context, state) => const FriendScreen(),
|
|
|
|
),
|
2024-05-22 15:18:01 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/account/personalize',
|
|
|
|
name: 'accountPersonalize',
|
|
|
|
builder: (context, state) => const PersonalizeScreen(),
|
|
|
|
),
|
2024-05-18 10:17:16 +00:00
|
|
|
],
|
|
|
|
),
|
2024-05-26 15:13:43 +00:00
|
|
|
ShellRoute(
|
|
|
|
builder: (context, state, child) =>
|
|
|
|
BasicShell(state: state, child: child),
|
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/chat/:alias/detail',
|
|
|
|
name: 'channelDetail',
|
|
|
|
builder: (context, state) => ChannelDetailScreen(
|
|
|
|
channel: state.extra as Channel,
|
|
|
|
realm: state.uri.queryParameters['realm'] ?? 'global',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-05-25 16:11:00 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/chat/organize',
|
|
|
|
name: 'channelOrganizing',
|
|
|
|
builder: (context, state) {
|
|
|
|
final arguments = state.extra as ChannelOrganizeArguments?;
|
|
|
|
return ChannelOrganizeScreen(
|
|
|
|
edit: arguments?.edit,
|
|
|
|
realm: state.uri.queryParameters['realm'],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-05-25 17:21:08 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/chat/:alias',
|
|
|
|
name: 'channelChat',
|
|
|
|
builder: (context, state) {
|
|
|
|
return ChannelChatScreen(
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
realm: state.uri.queryParameters['realm'] ?? 'global',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-05-29 14:42:11 +00:00
|
|
|
ShellRoute(
|
|
|
|
builder: (context, state, child) =>
|
|
|
|
BasicShell(state: state, child: child),
|
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/realms/:alias/detail',
|
|
|
|
name: 'realmDetail',
|
|
|
|
builder: (context, state) => RealmDetailScreen(
|
|
|
|
realm: state.extra as Realm,
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-05-28 14:13:23 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/realm/organize',
|
|
|
|
name: 'realmOrganizing',
|
|
|
|
builder: (context, state) {
|
|
|
|
final arguments = state.extra as RealmOrganizeArguments?;
|
|
|
|
return RealmOrganizeScreen(
|
|
|
|
edit: arguments?.edit,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-05-29 14:42:11 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/realm/:alias',
|
|
|
|
name: 'realmView',
|
|
|
|
builder: (context, state) {
|
|
|
|
return RealmViewScreen(
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-05-18 10:17:16 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|