fluffychat/lib/config/routes.dart

388 lines
13 KiB
Dart
Raw Permalink Normal View History

2021-10-26 18:50:34 +02:00
import 'package:flutter/material.dart';
import 'package:vrouter/vrouter.dart';
2021-12-24 14:18:09 +01:00
import 'package:fluffychat/pages/add_story/add_story.dart';
2021-11-09 21:32:16 +01:00
import 'package:fluffychat/pages/archive/archive.dart';
import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/pages/chat_details/chat_details.dart';
import 'package:fluffychat/pages/chat_encryption_settings/chat_encryption_settings.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/pages/chat_permissions_settings/chat_permissions_settings.dart';
import 'package:fluffychat/pages/device_settings/device_settings.dart';
import 'package:fluffychat/pages/homeserver_picker/homeserver_picker.dart';
import 'package:fluffychat/pages/invitation_selection/invitation_selection.dart';
import 'package:fluffychat/pages/login/login.dart';
import 'package:fluffychat/pages/new_group/new_group.dart';
import 'package:fluffychat/pages/new_private_chat/new_private_chat.dart';
import 'package:fluffychat/pages/new_space/new_space.dart';
import 'package:fluffychat/pages/search/search.dart';
import 'package:fluffychat/pages/settings/settings.dart';
import 'package:fluffychat/pages/settings_3pid/settings_3pid.dart';
import 'package:fluffychat/pages/settings_account/settings_account.dart';
import 'package:fluffychat/pages/settings_chat/settings_chat.dart';
import 'package:fluffychat/pages/settings_emotes/settings_emotes.dart';
import 'package:fluffychat/pages/settings_ignore_list/settings_ignore_list.dart';
import 'package:fluffychat/pages/settings_multiple_emotes/settings_multiple_emotes.dart';
import 'package:fluffychat/pages/settings_notifications/settings_notifications.dart';
import 'package:fluffychat/pages/settings_security/settings_security.dart';
2021-12-25 10:20:18 +01:00
import 'package:fluffychat/pages/settings_stories/settings_stories.dart';
2021-11-09 21:32:16 +01:00
import 'package:fluffychat/pages/settings_style/settings_style.dart';
import 'package:fluffychat/pages/sign_up/signup.dart';
2021-12-24 14:18:09 +01:00
import 'package:fluffychat/pages/story/story_page.dart';
2021-11-09 21:32:16 +01:00
import 'package:fluffychat/widgets/layouts/empty_page.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/widgets/layouts/loading_view.dart';
import 'package:fluffychat/widgets/layouts/side_view_layout.dart';
import 'package:fluffychat/widgets/layouts/two_column_layout.dart';
import 'package:fluffychat/widgets/log_view.dart';
2021-01-16 12:46:38 +01:00
2021-05-23 13:11:55 +02:00
class AppRoutes {
2021-05-23 18:46:15 +02:00
final bool columnMode;
2021-01-16 12:46:38 +01:00
2021-06-22 12:31:18 +02:00
AppRoutes(this.columnMode);
2021-01-16 12:46:38 +01:00
2021-05-23 13:11:55 +02:00
List<VRouteElement> get routes => [
2021-05-23 18:46:15 +02:00
..._homeRoutes,
if (columnMode) ..._tabletRoutes,
if (!columnMode) ..._mobileRoutes,
];
List<VRouteElement> get _mobileRoutes => [
VWidget(
path: '/rooms',
2021-10-14 18:09:30 +02:00
widget: const ChatList(),
2021-05-23 18:46:15 +02:00
stackedRoutes: [
2021-12-24 14:18:09 +01:00
VWidget(
path: '/stories/create',
widget: const AddStoryPage(),
),
VWidget(
path: '/stories/:roomid',
widget: const StoryPage(),
2021-12-28 19:30:19 +01:00
stackedRoutes: [
VWidget(
path: 'share',
widget: const AddStoryPage(),
),
],
2021-12-24 14:18:09 +01:00
),
2021-08-04 09:56:05 +02:00
VWidget(
path: '/spaces/:roomid',
2021-10-14 18:09:30 +02:00
widget: const ChatDetails(),
2021-08-04 09:56:05 +02:00
stackedRoutes: _chatDetailsRoutes,
),
2021-10-14 18:09:30 +02:00
VWidget(path: ':roomid', widget: const Chat(), stackedRoutes: [
2021-05-23 18:46:15 +02:00
VWidget(
path: 'encryption',
2021-10-14 18:09:30 +02:00
widget: const ChatEncryptionSettings(),
2021-05-23 18:46:15 +02:00
),
VWidget(
path: 'invite',
2021-10-14 18:09:30 +02:00
widget: const InvitationSelection(),
2021-05-23 18:46:15 +02:00
),
VWidget(
path: 'details',
2021-10-14 18:09:30 +02:00
widget: const ChatDetails(),
2021-05-23 18:46:15 +02:00
stackedRoutes: _chatDetailsRoutes,
),
]),
VWidget(
path: '/settings',
2021-10-14 18:09:30 +02:00
widget: const Settings(),
2021-05-23 18:46:15 +02:00
stackedRoutes: _settingsRoutes,
),
VWidget(
path: '/search',
2021-10-14 18:09:30 +02:00
widget: const Search(),
2021-05-23 18:46:15 +02:00
),
VWidget(
path: '/archive',
2021-10-14 18:09:30 +02:00
widget: const Archive(),
2021-05-23 18:46:15 +02:00
),
VWidget(
path: '/newprivatechat',
2021-10-14 18:09:30 +02:00
widget: const NewPrivateChat(),
2021-05-23 18:46:15 +02:00
),
VWidget(
path: '/newgroup',
2021-10-14 18:09:30 +02:00
widget: const NewGroup(),
2021-05-23 18:46:15 +02:00
),
2021-08-01 08:05:40 +02:00
VWidget(
path: '/newspace',
2021-10-14 18:09:30 +02:00
widget: const NewSpace(),
2021-08-01 08:05:40 +02:00
),
2021-05-23 18:46:15 +02:00
],
),
];
List<VRouteElement> get _tabletRoutes => [
VNester(
path: '/rooms',
widgetBuilder: (child) => TwoColumnLayout(
2021-10-14 18:09:30 +02:00
mainView: const ChatList(),
2021-05-23 18:46:15 +02:00
sideView: child,
),
buildTransition: _fadeTransition,
nestedRoutes: [
VWidget(
path: '',
2021-10-14 18:09:30 +02:00
widget: const EmptyPage(),
2021-05-23 18:46:15 +02:00
buildTransition: _fadeTransition,
stackedRoutes: [
2021-12-25 15:27:13 +01:00
VWidget(
path: '/stories/create',
buildTransition: _fadeTransition,
widget: const AddStoryPage(),
),
VWidget(
path: '/stories/:roomid',
buildTransition: _fadeTransition,
widget: const StoryPage(),
2021-12-28 19:30:19 +01:00
stackedRoutes: [
VWidget(
path: 'share',
widget: const AddStoryPage(),
),
],
2021-12-25 15:27:13 +01:00
),
2021-08-04 09:56:05 +02:00
VWidget(
path: '/spaces/:roomid',
2021-10-14 18:09:30 +02:00
widget: const ChatDetails(),
2021-08-04 09:56:05 +02:00
buildTransition: _fadeTransition,
stackedRoutes: _chatDetailsRoutes,
),
2021-05-23 18:46:15 +02:00
VWidget(
path: '/newprivatechat',
2021-10-14 18:09:30 +02:00
widget: const NewPrivateChat(),
2021-05-23 18:46:15 +02:00
buildTransition: _fadeTransition,
),
VWidget(
path: '/newgroup',
2021-10-14 18:09:30 +02:00
widget: const NewGroup(),
2021-05-23 18:46:15 +02:00
buildTransition: _fadeTransition,
),
2021-08-01 08:05:40 +02:00
VWidget(
path: '/newspace',
2021-10-14 18:09:30 +02:00
widget: const NewSpace(),
2021-08-01 08:05:40 +02:00
buildTransition: _fadeTransition,
),
2021-05-23 18:46:15 +02:00
VNester(
path: ':roomid',
widgetBuilder: (child) => SideViewLayout(
2021-10-14 18:09:30 +02:00
mainView: const Chat(),
2021-05-23 18:46:15 +02:00
sideView: child,
),
buildTransition: _fadeTransition,
nestedRoutes: [
VWidget(
path: '',
2021-10-14 18:09:30 +02:00
widget: const Chat(),
2021-05-23 18:46:15 +02:00
buildTransition: _fadeTransition,
),
VWidget(
path: 'encryption',
2021-10-14 18:09:30 +02:00
widget: const ChatEncryptionSettings(),
2021-05-23 18:46:15 +02:00
buildTransition: _fadeTransition,
),
VWidget(
path: 'details',
2021-10-14 18:09:30 +02:00
widget: const ChatDetails(),
2021-05-23 18:46:15 +02:00
buildTransition: _fadeTransition,
stackedRoutes: _chatDetailsRoutes,
),
VWidget(
path: 'invite',
2021-10-14 18:09:30 +02:00
widget: const InvitationSelection(),
2021-05-23 18:46:15 +02:00
buildTransition: _fadeTransition,
),
],
),
],
),
],
),
VWidget(
path: '/rooms',
2021-10-14 18:09:30 +02:00
widget: const TwoColumnLayout(
2021-05-23 18:46:15 +02:00
mainView: ChatList(),
sideView: EmptyPage(),
),
buildTransition: _fadeTransition,
stackedRoutes: [
VNester(
path: '/settings',
widgetBuilder: (child) => TwoColumnLayout(
2021-10-14 18:09:30 +02:00
mainView: const Settings(),
2021-05-23 18:46:15 +02:00
sideView: child,
),
buildTransition: _dynamicTransition,
nestedRoutes: [
VWidget(
path: '',
2021-10-14 18:09:30 +02:00
widget: const EmptyPage(),
2021-05-23 18:46:15 +02:00
buildTransition: _dynamicTransition,
stackedRoutes: _settingsRoutes,
),
],
),
VWidget(
path: '/search',
2021-10-14 18:09:30 +02:00
widget: const TwoColumnLayout(
2021-05-23 18:46:15 +02:00
mainView: Search(),
sideView: EmptyPage(),
),
buildTransition: _fadeTransition,
),
VWidget(
path: '/archive',
2021-10-14 18:09:30 +02:00
widget: const TwoColumnLayout(
2021-05-23 18:46:15 +02:00
mainView: Archive(),
sideView: EmptyPage(),
),
buildTransition: _fadeTransition,
),
],
),
];
List<VRouteElement> get _homeRoutes => [
2021-10-14 18:09:30 +02:00
VWidget(path: '/', widget: const LoadingView()),
2021-05-23 13:11:55 +02:00
VWidget(
path: '/home',
2021-10-14 18:09:30 +02:00
widget: const HomeserverPicker(),
2021-05-23 13:11:55 +02:00
buildTransition: _fadeTransition,
stackedRoutes: [
VWidget(
path: 'login',
2021-10-14 18:09:30 +02:00
widget: const Login(),
2021-06-11 10:08:04 +02:00
buildTransition: _fadeTransition,
),
2021-09-10 10:30:54 +02:00
VWidget(
path: 'signup',
2021-10-14 18:09:30 +02:00
widget: const SignupPage(),
2021-09-10 10:30:54 +02:00
buildTransition: _fadeTransition,
),
2021-06-26 10:43:07 +02:00
VWidget(
path: 'logs',
2021-10-14 18:09:30 +02:00
widget: const LogViewer(),
2021-06-26 10:43:07 +02:00
buildTransition: _dynamicTransition,
),
2021-05-23 13:11:55 +02:00
],
),
];
2021-01-16 12:46:38 +01:00
2021-05-23 13:11:55 +02:00
List<VRouteElement> get _chatDetailsRoutes => [
VWidget(
path: 'permissions',
2021-10-14 18:09:30 +02:00
widget: const ChatPermissionsSettings(),
2021-05-23 13:11:55 +02:00
buildTransition: _dynamicTransition,
),
VWidget(
path: 'invite',
2021-10-14 18:09:30 +02:00
widget: const InvitationSelection(),
2021-05-23 13:11:55 +02:00
buildTransition: _dynamicTransition,
),
VWidget(
2021-06-24 16:39:17 +02:00
path: 'multiple_emotes',
2021-10-14 18:09:30 +02:00
widget: const MultipleEmotesSettings(),
2021-05-23 13:11:55 +02:00
buildTransition: _dynamicTransition,
),
2021-06-24 16:39:17 +02:00
VWidget(
path: 'emotes',
2021-10-14 18:09:30 +02:00
widget: const EmotesSettings(),
2021-06-24 16:39:17 +02:00
buildTransition: _dynamicTransition,
),
VWidget(
path: 'emotes/:state_key',
2021-10-14 18:09:30 +02:00
widget: const EmotesSettings(),
2021-06-24 16:39:17 +02:00
buildTransition: _dynamicTransition,
),
2021-05-23 13:11:55 +02:00
];
2021-01-16 12:46:38 +01:00
2021-05-23 15:02:36 +02:00
List<VRouteElement> get _settingsRoutes => [
VWidget(
path: 'notifications',
2021-10-14 18:09:30 +02:00
widget: const SettingsNotifications(),
2021-05-23 15:02:36 +02:00
buildTransition: _dynamicTransition,
),
VWidget(
path: 'style',
widget: const SettingsStyle(),
buildTransition: _dynamicTransition,
),
2021-11-13 21:21:13 +01:00
VWidget(
path: 'devices',
widget: const DevicesSettings(),
buildTransition: _dynamicTransition,
),
2021-05-23 15:02:36 +02:00
VWidget(
2021-06-23 11:26:12 +02:00
path: 'chat',
2021-10-14 18:09:30 +02:00
widget: const SettingsChat(),
2021-05-23 15:02:36 +02:00
buildTransition: _dynamicTransition,
2021-06-23 11:26:12 +02:00
stackedRoutes: [
VWidget(
path: 'emotes',
2021-10-14 18:09:30 +02:00
widget: const EmotesSettings(),
2021-06-23 11:26:12 +02:00
buildTransition: _dynamicTransition,
),
],
2021-05-23 15:02:36 +02:00
),
VWidget(
2021-06-23 11:26:12 +02:00
path: 'account',
2021-10-14 18:09:30 +02:00
widget: const SettingsAccount(),
2021-05-23 15:02:36 +02:00
buildTransition: _dynamicTransition,
2021-06-23 11:26:12 +02:00
stackedRoutes: [
VWidget(
path: 'add',
2021-10-14 18:09:30 +02:00
widget: const HomeserverPicker(),
buildTransition: _fadeTransition,
stackedRoutes: [
VWidget(
path: 'login',
2021-10-14 18:09:30 +02:00
widget: const Login(),
buildTransition: _fadeTransition,
),
VWidget(
path: 'signup',
2021-10-14 18:09:30 +02:00
widget: const SignupPage(),
buildTransition: _fadeTransition,
),
],
),
2021-06-23 11:26:12 +02:00
],
2021-05-23 15:02:36 +02:00
),
VWidget(
2021-06-23 11:26:12 +02:00
path: 'security',
2021-10-14 18:09:30 +02:00
widget: const SettingsSecurity(),
2021-05-23 15:02:36 +02:00
buildTransition: _dynamicTransition,
2021-06-23 11:26:12 +02:00
stackedRoutes: [
2021-12-25 10:20:18 +01:00
VWidget(
path: 'stories',
widget: const SettingsStories(),
buildTransition: _dynamicTransition,
),
2021-06-23 11:26:12 +02:00
VWidget(
path: 'ignorelist',
2021-10-14 18:09:30 +02:00
widget: const SettingsIgnoreList(),
2021-06-23 11:26:12 +02:00
buildTransition: _dynamicTransition,
),
VWidget(
path: '3pid',
2021-10-14 18:09:30 +02:00
widget: const Settings3Pid(),
2021-06-23 11:26:12 +02:00
buildTransition: _dynamicTransition,
),
],
2021-05-23 15:02:36 +02:00
),
VWidget(
2021-06-26 10:43:07 +02:00
path: 'logs',
2021-10-14 18:09:30 +02:00
widget: const LogViewer(),
2021-05-23 15:02:36 +02:00
buildTransition: _dynamicTransition,
),
];
2021-05-23 13:11:55 +02:00
FadeTransition Function(dynamic, dynamic, dynamic)? get _dynamicTransition =>
2021-05-23 18:46:15 +02:00
columnMode ? _fadeTransition : null;
2021-10-14 18:09:30 +02:00
FadeTransition _fadeTransition(animation1, _, child) =>
FadeTransition(opacity: animation1, child: child);
2021-01-16 12:46:38 +01:00
}