2024-11-15 15:08:29 +00:00
|
|
|
import 'package:animations/animations.dart';
|
2024-11-21 14:55:00 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-11-08 16:09:46 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import 'package:surface/screens/account.dart';
|
2024-11-09 17:04:39 +00:00
|
|
|
import 'package:surface/screens/account/profile_edit.dart';
|
|
|
|
import 'package:surface/screens/account/publishers/publisher_edit.dart';
|
|
|
|
import 'package:surface/screens/account/publishers/publisher_new.dart';
|
|
|
|
import 'package:surface/screens/account/publishers/publishers.dart';
|
2024-11-13 16:08:09 +00:00
|
|
|
import 'package:surface/screens/album.dart';
|
2024-11-09 10:28:45 +00:00
|
|
|
import 'package:surface/screens/auth/login.dart';
|
|
|
|
import 'package:surface/screens/auth/register.dart';
|
2024-11-13 16:08:09 +00:00
|
|
|
import 'package:surface/screens/chat.dart';
|
2024-11-23 16:22:08 +00:00
|
|
|
import 'package:surface/screens/chat/call_room.dart';
|
2024-11-28 15:35:25 +00:00
|
|
|
import 'package:surface/screens/chat/channel_detail.dart';
|
2024-11-16 05:54:36 +00:00
|
|
|
import 'package:surface/screens/chat/manage.dart';
|
2024-11-16 17:16:54 +00:00
|
|
|
import 'package:surface/screens/chat/room.dart';
|
2024-11-08 16:09:46 +00:00
|
|
|
import 'package:surface/screens/explore.dart';
|
2024-11-30 14:39:49 +00:00
|
|
|
import 'package:surface/screens/friend.dart';
|
2024-11-08 16:09:46 +00:00
|
|
|
import 'package:surface/screens/home.dart';
|
2024-11-23 08:55:23 +00:00
|
|
|
import 'package:surface/screens/notification.dart';
|
2024-11-10 14:56:09 +00:00
|
|
|
import 'package:surface/screens/post/post_detail.dart';
|
2024-11-09 17:34:58 +00:00
|
|
|
import 'package:surface/screens/post/post_editor.dart';
|
2024-12-01 14:30:32 +00:00
|
|
|
import 'package:surface/screens/post/post_publisher.dart';
|
2024-11-23 11:06:09 +00:00
|
|
|
import 'package:surface/screens/post/post_search.dart';
|
2024-11-16 05:54:36 +00:00
|
|
|
import 'package:surface/screens/realm.dart';
|
|
|
|
import 'package:surface/screens/realm/manage.dart';
|
2024-12-01 04:34:27 +00:00
|
|
|
import 'package:surface/screens/realm/realm_detail.dart';
|
2024-11-10 13:48:42 +00:00
|
|
|
import 'package:surface/screens/settings.dart';
|
2024-11-10 14:56:09 +00:00
|
|
|
import 'package:surface/types/post.dart';
|
2024-11-15 15:08:29 +00:00
|
|
|
import 'package:surface/widgets/navigation/app_background.dart';
|
2024-11-08 16:09:46 +00:00
|
|
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
|
|
|
|
2024-11-14 14:21:13 +00:00
|
|
|
final _appRoutes = [
|
|
|
|
ShellRoute(
|
2024-11-15 15:08:29 +00:00
|
|
|
builder: (context, state, child) => AppPageScaffold(
|
2024-11-14 14:21:13 +00:00
|
|
|
body: child,
|
|
|
|
showAppBar: false,
|
2024-11-09 10:28:45 +00:00
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/',
|
|
|
|
name: 'home',
|
2024-11-15 14:46:12 +00:00
|
|
|
pageBuilder: (context, state) => NoTransitionPage(
|
|
|
|
child: const HomeScreen(),
|
|
|
|
),
|
2024-11-09 17:34:58 +00:00
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/posts',
|
|
|
|
name: 'explore',
|
2024-11-15 14:46:12 +00:00
|
|
|
pageBuilder: (context, state) => NoTransitionPage(
|
|
|
|
child: const ExploreScreen(),
|
|
|
|
),
|
2024-11-15 15:08:29 +00:00
|
|
|
routes: [
|
|
|
|
GoRoute(
|
2024-11-23 16:22:08 +00:00
|
|
|
path: '/write/:mode',
|
2024-11-15 15:08:29 +00:00
|
|
|
name: 'postEditor',
|
2024-11-23 09:32:48 +00:00
|
|
|
builder: (context, state) => AppBackground(
|
|
|
|
isLessOptimization: true,
|
2024-11-15 15:08:29 +00:00
|
|
|
child: PostEditorScreen(
|
|
|
|
mode: state.pathParameters['mode']!,
|
|
|
|
postEditId: int.tryParse(
|
|
|
|
state.uri.queryParameters['editing'] ?? '',
|
|
|
|
),
|
|
|
|
postReplyId: int.tryParse(
|
|
|
|
state.uri.queryParameters['replying'] ?? '',
|
|
|
|
),
|
|
|
|
postRepostId: int.tryParse(
|
|
|
|
state.uri.queryParameters['reposting'] ?? '',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-11-23 11:06:09 +00:00
|
|
|
GoRoute(
|
2024-11-23 16:22:08 +00:00
|
|
|
path: '/search',
|
2024-11-23 11:06:09 +00:00
|
|
|
name: 'postSearch',
|
|
|
|
builder: (context, state) => const AppBackground(
|
2024-11-27 15:03:18 +00:00
|
|
|
isLessOptimization: true,
|
2024-11-23 11:06:09 +00:00
|
|
|
child: PostSearchScreen(),
|
|
|
|
),
|
|
|
|
),
|
2024-12-01 14:30:32 +00:00
|
|
|
GoRoute(
|
2024-12-02 14:42:31 +00:00
|
|
|
path: '/publishers/:name',
|
2024-12-01 14:30:32 +00:00
|
|
|
name: 'postPublisher',
|
|
|
|
builder: (context, state) => AppBackground(
|
|
|
|
child: PostPublisherScreen(name: state.pathParameters['name']!),
|
|
|
|
),
|
|
|
|
),
|
2024-11-15 15:08:29 +00:00
|
|
|
GoRoute(
|
2024-11-23 16:22:08 +00:00
|
|
|
path: '/:slug',
|
2024-11-15 15:08:29 +00:00
|
|
|
name: 'postDetail',
|
2024-11-23 09:32:48 +00:00
|
|
|
builder: (context, state) => AppBackground(
|
2024-11-15 15:08:29 +00:00
|
|
|
child: PostDetailScreen(
|
|
|
|
slug: state.pathParameters['slug']!,
|
|
|
|
preload: state.extra as SnPost?,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/account',
|
|
|
|
name: 'account',
|
2024-11-15 14:46:12 +00:00
|
|
|
pageBuilder: (context, state) => NoTransitionPage(
|
|
|
|
child: const AccountScreen(),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/chat',
|
|
|
|
name: 'chat',
|
2024-11-15 14:46:12 +00:00
|
|
|
pageBuilder: (context, state) => NoTransitionPage(
|
|
|
|
child: const ChatScreen(),
|
|
|
|
),
|
2024-11-16 05:54:36 +00:00
|
|
|
routes: [
|
2024-11-16 17:16:54 +00:00
|
|
|
GoRoute(
|
2024-11-23 16:22:08 +00:00
|
|
|
path: '/:scope/:alias',
|
2024-11-16 17:16:54 +00:00
|
|
|
name: 'chatRoom',
|
|
|
|
builder: (context, state) => AppBackground(
|
2024-11-17 13:30:02 +00:00
|
|
|
isLessOptimization: true,
|
2024-11-16 17:16:54 +00:00
|
|
|
child: ChatRoomScreen(
|
|
|
|
scope: state.pathParameters['scope']!,
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-11-16 05:54:36 +00:00
|
|
|
GoRoute(
|
2024-11-23 16:22:08 +00:00
|
|
|
path: '/:scope/:alias/call',
|
|
|
|
name: 'chatCallRoom',
|
|
|
|
builder: (context, state) => AppBackground(
|
|
|
|
child: CallRoomScreen(
|
|
|
|
scope: state.pathParameters['scope']!,
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-11-28 15:35:25 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/:scope/:alias/detail',
|
|
|
|
name: 'channelDetail',
|
|
|
|
builder: (context, state) => AppBackground(
|
|
|
|
child: ChannelDetailScreen(
|
|
|
|
scope: state.pathParameters['scope']!,
|
|
|
|
alias: state.pathParameters['alias']!,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-11-23 16:22:08 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/manage',
|
2024-11-16 05:54:36 +00:00
|
|
|
name: 'chatManage',
|
|
|
|
pageBuilder: (context, state) => CustomTransitionPage(
|
2024-11-28 15:35:25 +00:00
|
|
|
child: ChatManageScreen(
|
|
|
|
editingChannelAlias: state.uri.queryParameters['editing'],
|
|
|
|
),
|
2024-11-16 05:54:36 +00:00
|
|
|
transitionsBuilder:
|
|
|
|
(context, animation, secondaryAnimation, child) {
|
|
|
|
return FadeThroughTransition(
|
|
|
|
animation: animation,
|
|
|
|
secondaryAnimation: secondaryAnimation,
|
2024-11-21 14:55:00 +00:00
|
|
|
fillColor: Colors.transparent,
|
2024-11-16 05:54:36 +00:00
|
|
|
child: AppBackground(
|
|
|
|
isLessOptimization: true,
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2024-12-01 04:34:27 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/:alias',
|
|
|
|
name: 'realmDetail',
|
|
|
|
builder: (context, state) => AppBackground(
|
|
|
|
child: RealmDetailScreen(alias: state.pathParameters['alias']!),
|
|
|
|
),
|
|
|
|
),
|
2024-11-16 05:54:36 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/realm',
|
|
|
|
name: 'realm',
|
|
|
|
pageBuilder: (context, state) => NoTransitionPage(
|
|
|
|
child: const RealmScreen(),
|
|
|
|
),
|
|
|
|
routes: [
|
|
|
|
GoRoute(
|
2024-11-23 16:22:08 +00:00
|
|
|
path: '/manage',
|
2024-11-16 05:54:36 +00:00
|
|
|
name: 'realmManage',
|
|
|
|
pageBuilder: (context, state) => CustomTransitionPage(
|
|
|
|
child: RealmManageScreen(
|
|
|
|
editingRealmAlias: state.uri.queryParameters['editing'],
|
|
|
|
),
|
|
|
|
transitionsBuilder:
|
|
|
|
(context, animation, secondaryAnimation, child) {
|
|
|
|
return FadeThroughTransition(
|
|
|
|
animation: animation,
|
|
|
|
secondaryAnimation: secondaryAnimation,
|
2024-11-21 14:55:00 +00:00
|
|
|
fillColor: Colors.transparent,
|
2024-11-16 05:54:36 +00:00
|
|
|
child: AppBackground(
|
|
|
|
isLessOptimization: true,
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/album',
|
|
|
|
name: 'album',
|
2024-11-15 14:46:12 +00:00
|
|
|
pageBuilder: (context, state) => NoTransitionPage(
|
|
|
|
child: const AlbumScreen(),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
2024-11-30 14:39:49 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/friend',
|
|
|
|
name: 'friend',
|
|
|
|
pageBuilder: (context, state) => NoTransitionPage(
|
|
|
|
child: const FriendScreen(),
|
|
|
|
),
|
|
|
|
),
|
2024-11-23 08:55:23 +00:00
|
|
|
GoRoute(
|
|
|
|
path: '/notification',
|
|
|
|
name: 'notification',
|
|
|
|
pageBuilder: (context, state) => NoTransitionPage(
|
|
|
|
child: const NotificationScreen(),
|
|
|
|
),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
ShellRoute(
|
2024-11-15 15:08:29 +00:00
|
|
|
builder: (context, state, child) => AppPageScaffold(body: child),
|
2024-11-14 14:21:13 +00:00
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/auth/login',
|
|
|
|
name: 'authLogin',
|
2024-12-01 04:34:27 +00:00
|
|
|
builder: (context, state) => const AppBackground(
|
|
|
|
child: LoginScreen(),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/auth/register',
|
|
|
|
name: 'authRegister',
|
2024-12-01 04:34:27 +00:00
|
|
|
builder: (context, state) => const AppBackground(
|
|
|
|
child: RegisterScreen(),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/account/profile/edit',
|
|
|
|
name: 'accountProfileEdit',
|
2024-12-01 04:34:27 +00:00
|
|
|
builder: (context, state) => const AppBackground(
|
|
|
|
child: ProfileEditScreen(),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/account/publishers',
|
|
|
|
name: 'accountPublishers',
|
2024-12-01 04:34:27 +00:00
|
|
|
builder: (context, state) => const AppBackground(
|
|
|
|
child: PublisherScreen(),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/account/publishers/new',
|
|
|
|
name: 'accountPublisherNew',
|
2024-12-01 04:34:27 +00:00
|
|
|
builder: (context, state) => const AppBackground(
|
|
|
|
child: AccountPublisherNewScreen(),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
GoRoute(
|
|
|
|
path: '/account/publishers/edit/:name',
|
|
|
|
name: 'accountPublisherEdit',
|
2024-12-01 04:34:27 +00:00
|
|
|
builder: (context, state) => AppBackground(
|
|
|
|
child: AccountPublisherEditScreen(
|
|
|
|
name: state.pathParameters['name']!,
|
|
|
|
),
|
2024-11-10 13:48:42 +00:00
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
ShellRoute(
|
2024-11-15 15:08:29 +00:00
|
|
|
builder: (context, state, child) => AppPageScaffold(body: child),
|
2024-11-14 14:21:13 +00:00
|
|
|
routes: [
|
|
|
|
GoRoute(
|
|
|
|
path: '/settings',
|
|
|
|
name: 'settings',
|
2024-11-24 12:54:01 +00:00
|
|
|
builder: (context, state) => const AppBackground(
|
|
|
|
child: SettingsScreen(),
|
|
|
|
),
|
2024-11-14 14:21:13 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
final appRouter = GoRouter(
|
2024-11-15 15:08:29 +00:00
|
|
|
routes: [
|
|
|
|
ShellRoute(
|
|
|
|
routes: _appRoutes,
|
|
|
|
builder: (context, state, child) => AppRootScaffold(body: child),
|
|
|
|
),
|
|
|
|
],
|
2024-11-08 16:09:46 +00:00
|
|
|
);
|