2024-05-18 10:17:16 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
2024-05-29 14:42:11 +00:00
|
|
|
import 'package:solian/models/realm.dart';
|
2024-06-08 05:28:49 +00:00
|
|
|
import 'package:solian/screens/about.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-07-10 02:50:10 +00:00
|
|
|
import 'package:solian/screens/articles/article_detail.dart';
|
|
|
|
import 'package:solian/screens/articles/article_editor.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-06-22 17:52:05 +00:00
|
|
|
import 'package:solian/screens/chat.dart';
|
2024-07-09 13:23:38 +00:00
|
|
|
import 'package:solian/screens/feed/search.dart';
|
2024-05-25 05:19:16 +00:00
|
|
|
import 'package:solian/screens/posts/post_detail.dart';
|
2024-07-09 13:23:38 +00:00
|
|
|
import 'package:solian/screens/feed/draft_box.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-07-06 12:55:53 +00:00
|
|
|
import 'package:solian/screens/feed.dart';
|
2024-07-10 02:50:10 +00:00
|
|
|
import 'package:solian/screens/posts/post_editor.dart';
|
2024-05-22 15:18:01 +00:00
|
|
|
import 'package:solian/shells/basic_shell.dart';
|
2024-07-12 05:15:46 +00:00
|
|
|
import 'package:solian/shells/root_shell.dart';
|
2024-06-27 06:31:15 +00:00
|
|
|
import 'package:solian/shells/title_shell.dart';
|
|
|
|
import 'package:solian/theme.dart';
|
|
|
|
import 'package:solian/widgets/sidebar/empty_placeholder.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
|
2024-05-18 16:56:32 +00:00
|
|
|
abstract class AppRouter {
|
2024-05-18 10:17:16 +00:00
|
|
|
static GoRouter instance = GoRouter(
|
|
|
|
routes: [
|
2024-07-12 05:15:46 +00:00
|
|
|
ShellRoute(
|
|
|
|
builder: (context, state, child) => RootShell(
|
|
|
|
state: state,
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
routes: [
|
|
|
|
_feedRoute,
|
|
|
|
_chatRoute,
|
|
|
|
_realmRoute,
|
|
|
|
_accountRoute,
|
|
|
|
],
|
|
|
|
),
|
2024-07-06 12:55:53 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
static final ShellRoute _feedRoute = ShellRoute(
|
2024-07-06 13:14:19 +00:00
|
|
|
builder: (context, state, child) => child,
|
2024-07-06 12:55:53 +00:00
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/',
|
|
|
|
name: 'feed',
|
2024-07-06 13:14:19 +00:00
|
|
|
builder: (context, state) => const FeedScreen(),
|
2024-07-06 12:55:53 +00:00
|
|
|
),
|
2024-07-07 06:22:53 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/feed/search',
|
|
|
|
name: 'feedSearch',
|
|
|
|
builder: (context, state) => TitleShell(
|
|
|
|
state: state,
|
|
|
|
child: FeedSearchScreen(
|
|
|
|
tag: state.uri.queryParameters['tag'],
|
|
|
|
category: state.uri.queryParameters['category'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-07-09 13:23:38 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/drafts',
|
|
|
|
name: 'draftBox',
|
|
|
|
builder: (context, state) => const DraftBoxScreen(),
|
|
|
|
),
|
2024-07-06 12:55:53 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/posts/view/:alias',
|
|
|
|
name: 'postDetail',
|
|
|
|
builder: (context, state) => TitleShell(
|
|
|
|
state: state,
|
|
|
|
child: PostDetailScreen(
|
|
|
|
alias: state.pathParameters['alias']!,
|
2024-05-25 05:19:16 +00:00
|
|
|
),
|
2024-07-06 12:55:53 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
GoRoute(
|
2024-07-10 02:50:10 +00:00
|
|
|
path: '/articles/view/:alias',
|
|
|
|
name: 'articleDetail',
|
|
|
|
builder: (context, state) => TitleShell(
|
|
|
|
state: state,
|
|
|
|
child: ArticleDetailScreen(
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/posts/editor',
|
|
|
|
name: 'postEditor',
|
2024-07-06 12:55:53 +00:00
|
|
|
builder: (context, state) {
|
2024-07-09 13:23:38 +00:00
|
|
|
final arguments = state.extra as PostPublishArguments?;
|
|
|
|
return PostPublishScreen(
|
2024-07-06 12:55:53 +00:00
|
|
|
edit: arguments?.edit,
|
|
|
|
reply: arguments?.reply,
|
|
|
|
repost: arguments?.repost,
|
|
|
|
realm: arguments?.realm,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-07-09 13:23:38 +00:00
|
|
|
GoRoute(
|
2024-07-10 02:50:10 +00:00
|
|
|
path: '/articles/editor',
|
|
|
|
name: 'articleEditor',
|
2024-07-09 13:23:38 +00:00
|
|
|
builder: (context, state) {
|
|
|
|
final arguments = state.extra as ArticlePublishArguments?;
|
|
|
|
return ArticlePublishScreen(
|
|
|
|
edit: arguments?.edit,
|
|
|
|
realm: arguments?.realm,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
)
|
2024-07-06 12:55:53 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
static final ShellRoute _chatRoute = ShellRoute(
|
|
|
|
builder: (context, state, child) => BasicShell(
|
|
|
|
state: state,
|
|
|
|
sidebarFirst: true,
|
|
|
|
showAppBar: false,
|
|
|
|
sidebar: const ChatScreen(),
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/chat',
|
|
|
|
name: 'chat',
|
|
|
|
builder: (context, state) => SolianTheme.isExtraLargeScreen(context)
|
|
|
|
? const EmptyPagePlaceholder()
|
|
|
|
: const ChatScreen(),
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/chat/organize',
|
|
|
|
name: 'channelOrganizing',
|
|
|
|
builder: (context, state) {
|
|
|
|
final arguments = state.extra as ChannelOrganizeArguments?;
|
|
|
|
return ChannelOrganizeScreen(
|
|
|
|
edit: arguments?.edit,
|
|
|
|
realm: arguments?.realm,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/chat/:alias',
|
|
|
|
name: 'channelChat',
|
|
|
|
builder: (context, state) {
|
|
|
|
return ChannelChatScreen(
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
realm: state.uri.queryParameters['realm'] ?? 'global',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/chat/:alias/detail',
|
|
|
|
name: 'channelDetail',
|
|
|
|
builder: (context, state) {
|
|
|
|
final arguments = state.extra as ChannelDetailArguments;
|
|
|
|
return TitleShell(
|
|
|
|
state: state,
|
|
|
|
child: ChannelDetailScreen(
|
|
|
|
channel: arguments.channel,
|
|
|
|
profile: arguments.profile,
|
|
|
|
realm: state.uri.queryParameters['realm'] ?? 'global',
|
2024-05-29 14:42:11 +00:00
|
|
|
),
|
2024-07-06 12:55:53 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
static final ShellRoute _realmRoute = ShellRoute(
|
|
|
|
builder: (context, state, child) => BasicShell(
|
|
|
|
state: state,
|
|
|
|
sidebarFirst: true,
|
|
|
|
showAppBar: false,
|
|
|
|
sidebar: const RealmListScreen(),
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/realms',
|
|
|
|
name: 'realms',
|
|
|
|
builder: (context, state) => SolianTheme.isExtraLargeScreen(context)
|
|
|
|
? const EmptyPagePlaceholder()
|
|
|
|
: const RealmListScreen(),
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/realms/:alias/detail',
|
|
|
|
name: 'realmDetail',
|
|
|
|
builder: (context, state) => TitleShell(
|
|
|
|
state: state,
|
|
|
|
child: RealmDetailScreen(
|
|
|
|
realm: state.extra as Realm,
|
|
|
|
alias: state.pathParameters['alias']!,
|
2024-05-29 14:42:11 +00:00
|
|
|
),
|
2024-07-06 12:55:53 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/realm/organize',
|
|
|
|
name: 'realmOrganizing',
|
|
|
|
builder: (context, state) {
|
|
|
|
final arguments = state.extra as RealmOrganizeArguments?;
|
|
|
|
return RealmOrganizeScreen(
|
|
|
|
edit: arguments?.edit,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/realm/:alias',
|
|
|
|
name: 'realmView',
|
|
|
|
builder: (context, state) {
|
|
|
|
return RealmViewScreen(
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
static final ShellRoute _accountRoute = ShellRoute(
|
|
|
|
builder: (context, state, child) => BasicShell(
|
|
|
|
state: state,
|
|
|
|
sidebarFirst: true,
|
|
|
|
showAppBar: false,
|
|
|
|
sidebar: const AccountScreen(),
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/account',
|
|
|
|
name: 'account',
|
|
|
|
builder: (context, state) => SolianTheme.isExtraLargeScreen(context)
|
|
|
|
? const EmptyPagePlaceholder()
|
2024-07-12 03:39:44 +00:00
|
|
|
: TitleShell(state: state, child: const AccountScreen()),
|
2024-07-06 12:55:53 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/account/friend',
|
|
|
|
name: 'accountFriend',
|
|
|
|
builder: (context, state) => TitleShell(
|
|
|
|
state: state,
|
|
|
|
child: const FriendScreen(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/account/personalize',
|
|
|
|
name: 'accountPersonalize',
|
|
|
|
builder: (context, state) => TitleShell(
|
|
|
|
state: state,
|
|
|
|
child: const PersonalizeScreen(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/about',
|
|
|
|
name: 'about',
|
|
|
|
builder: (context, state) => TitleShell(
|
|
|
|
state: state,
|
|
|
|
child: const AboutScreen(),
|
|
|
|
),
|
2024-05-29 14:42:11 +00:00
|
|
|
),
|
2024-05-18 10:17:16 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|