fluffychat/lib/config/routes.dart

350 lines
11 KiB
Dart
Raw Normal View History

2021-10-26 18:50:34 +02:00
import 'package:flutter/material.dart';
import 'package:vrouter/vrouter.dart';
2021-05-22 08:57:49 +02:00
import 'package:fluffychat/pages/archive.dart';
import 'package:fluffychat/pages/chat.dart';
import 'package:fluffychat/pages/chat_details.dart';
import 'package:fluffychat/pages/chat_encryption_settings.dart';
import 'package:fluffychat/pages/chat_list.dart';
import 'package:fluffychat/pages/chat_permissions_settings.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/pages/device_settings.dart';
import 'package:fluffychat/pages/homeserver_picker.dart';
import 'package:fluffychat/pages/invitation_selection.dart';
import 'package:fluffychat/pages/login.dart';
2021-05-22 08:57:49 +02:00
import 'package:fluffychat/pages/new_group.dart';
import 'package:fluffychat/pages/new_private_chat.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/pages/new_space.dart';
2021-05-22 08:57:49 +02:00
import 'package:fluffychat/pages/search.dart';
import 'package:fluffychat/pages/settings.dart';
import 'package:fluffychat/pages/settings_3pid.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/pages/settings_account.dart';
import 'package:fluffychat/pages/settings_chat.dart';
import 'package:fluffychat/pages/settings_emotes.dart';
2021-05-22 08:57:49 +02:00
import 'package:fluffychat/pages/settings_ignore_list.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/pages/settings_multiple_emotes.dart';
2021-05-22 08:57:49 +02:00
import 'package:fluffychat/pages/settings_notifications.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/pages/settings_security.dart';
2021-05-22 08:57:49 +02:00
import 'package:fluffychat/pages/settings_style.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/pages/signup.dart';
import 'package:fluffychat/pages/views/empty_page_view.dart';
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-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-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(
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,
),
VWidget(
path: 'style',
2021-10-14 18:09:30 +02:00
widget: const SettingsStyle(),
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: 'devices',
2021-10-14 18:09:30 +02:00
widget: const DevicesSettings(),
2021-06-23 11:26:12 +02:00
buildTransition: _dynamicTransition,
),
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: [
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
}