mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 11:45:10 +00:00
refactor: Space routes to normal room routes
This commit is contained in:
parent
b715eff839
commit
e14173688a
7 changed files with 186 additions and 199 deletions
|
@ -138,17 +138,6 @@ abstract class AppRoutes {
|
|||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: 'spaces/:roomid',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
ChatDetails(
|
||||
roomId: state.pathParameters['roomid']!,
|
||||
),
|
||||
),
|
||||
routes: _chatDetailsRoutes,
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'archive',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
|
@ -213,7 +202,101 @@ abstract class AppRoutes {
|
|||
? const EmptyPage()
|
||||
: const Settings(),
|
||||
),
|
||||
routes: _settingsRoutes,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'notifications',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsNotifications(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'style',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsStyle(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'devices',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const DevicesSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chat',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsChat(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'emotes',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const EmotesSettings(),
|
||||
),
|
||||
),
|
||||
],
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'addaccount',
|
||||
redirect: loggedOutRedirect,
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const HomeserverPicker(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'login',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const Login(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: 'security',
|
||||
redirect: loggedOutRedirect,
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsSecurity(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'stories',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsStories(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'ignorelist',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsIgnoreList(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: '3pid',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const Settings3Pid(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
],
|
||||
|
@ -252,7 +335,60 @@ abstract class AppRoutes {
|
|||
roomId: state.pathParameters['roomid']!,
|
||||
),
|
||||
),
|
||||
routes: _chatDetailsRoutes,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'members',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
ChatMembersPage(
|
||||
roomId: state.pathParameters['roomid']!,
|
||||
),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'permissions',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const ChatPermissionsSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'invite',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
InvitationSelection(
|
||||
roomId: state.pathParameters['roomid']!,
|
||||
),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'multiple_emotes',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const MultipleEmotesSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'emotes',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const EmotesSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'emotes/:state_key',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const EmotesSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
],
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
],
|
||||
|
@ -263,155 +399,6 @@ abstract class AppRoutes {
|
|||
),
|
||||
];
|
||||
|
||||
static final List<RouteBase> _chatDetailsRoutes = [
|
||||
GoRoute(
|
||||
path: 'members',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
ChatMembersPage(
|
||||
roomId: state.pathParameters['roomid']!,
|
||||
),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'permissions',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const ChatPermissionsSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'invite',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
InvitationSelection(roomId: state.pathParameters['roomid']!),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'multiple_emotes',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const MultipleEmotesSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'emotes',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const EmotesSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'emotes/:state_key',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const EmotesSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
];
|
||||
|
||||
static final List<RouteBase> _settingsRoutes = [
|
||||
GoRoute(
|
||||
path: 'notifications',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsNotifications(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'style',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsStyle(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'devices',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const DevicesSettings(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chat',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsChat(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'emotes',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const EmotesSettings(),
|
||||
),
|
||||
),
|
||||
],
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'addaccount',
|
||||
redirect: loggedOutRedirect,
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const HomeserverPicker(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'login',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const Login(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: 'security',
|
||||
redirect: loggedOutRedirect,
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsSecurity(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'stories',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsStories(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'ignorelist',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const SettingsIgnoreList(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: '3pid',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
const Settings3Pid(),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
static Page defaultPageBuilder(BuildContext context, Widget child) =>
|
||||
CustomTransitionPage(
|
||||
child: child,
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:matrix/matrix.dart';
|
|||
|
||||
import 'package:fluffychat/pages/archive/archive.dart';
|
||||
import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
|
||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||
|
||||
class ArchiveView extends StatelessWidget {
|
||||
final ArchiveController controller;
|
||||
|
@ -32,35 +33,38 @@ class ArchiveView extends StatelessWidget {
|
|||
)
|
||||
],
|
||||
),
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
if (snapshot.hasError) {
|
||||
return Center(
|
||||
child: Text(
|
||||
L10n.of(context)!.oopsSomethingWentWrong,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (!snapshot.hasData) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
);
|
||||
} else {
|
||||
archive = snapshot.data;
|
||||
if (archive == null || archive!.isEmpty) {
|
||||
return const Center(
|
||||
child: Icon(Icons.archive_outlined, size: 80),
|
||||
body: MaxWidthBody(
|
||||
withScrolling: false,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
if (snapshot.hasError) {
|
||||
return Center(
|
||||
child: Text(
|
||||
L10n.of(context)!.oopsSomethingWentWrong,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: archive!.length,
|
||||
itemBuilder: (BuildContext context, int i) => ChatListItem(
|
||||
archive![i],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
if (!snapshot.hasData) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
);
|
||||
} else {
|
||||
archive = snapshot.data;
|
||||
if (archive == null || archive!.isEmpty) {
|
||||
return const Center(
|
||||
child: Icon(Icons.archive_outlined, size: 80),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: archive!.length,
|
||||
itemBuilder: (BuildContext context, int i) => ChatListItem(
|
||||
archive![i],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -39,12 +39,10 @@ import 'send_location_dialog.dart';
|
|||
import 'sticker_picker_dialog.dart';
|
||||
|
||||
class ChatPage extends StatelessWidget {
|
||||
final Widget? sideView;
|
||||
final String roomId;
|
||||
|
||||
const ChatPage({
|
||||
Key? key,
|
||||
this.sideView,
|
||||
required this.roomId,
|
||||
}) : super(key: key);
|
||||
|
||||
|
@ -69,11 +67,11 @@ class ChatPage extends StatelessWidget {
|
|||
Expanded(
|
||||
child: ChatPageWithRoom(
|
||||
key: Key('chat_page_$roomId'),
|
||||
sideView: sideView,
|
||||
room: room,
|
||||
),
|
||||
),
|
||||
if (FluffyThemes.isThreeColumnMode(context))
|
||||
if (FluffyThemes.isThreeColumnMode(context) &&
|
||||
room.membership == Membership.join)
|
||||
Container(
|
||||
width: FluffyThemes.columnWidth,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
|
@ -93,12 +91,10 @@ class ChatPage extends StatelessWidget {
|
|||
}
|
||||
|
||||
class ChatPageWithRoom extends StatefulWidget {
|
||||
final Widget? sideView;
|
||||
final Room room;
|
||||
|
||||
const ChatPageWithRoom({
|
||||
Key? key,
|
||||
required this.sideView,
|
||||
required this.room,
|
||||
}) : super(key: key);
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ class ChatListController extends State<ChatList>
|
|||
void editSpace(BuildContext context, String spaceId) async {
|
||||
await Matrix.of(context).client.getRoomById(spaceId)!.postLoad();
|
||||
if (mounted) {
|
||||
context.go('/rooms/spaces/$spaceId');
|
||||
context.push('/rooms/$spaceId/details');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
}
|
||||
if (spaceChild.roomType == 'm.space') {
|
||||
if (spaceChild.roomId == widget.controller.activeSpaceId) {
|
||||
context.go('/rooms/spaces/${spaceChild.roomId}');
|
||||
context.go('/rooms/${spaceChild.roomId}');
|
||||
} else {
|
||||
widget.controller.setActiveSpace(spaceChild.roomId);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class StoriesHeader extends StatelessWidget {
|
|||
);
|
||||
if (result.error != null) return;
|
||||
}
|
||||
context.go('/stories/$roomId');
|
||||
context.go('/rooms/stories/$roomId');
|
||||
}
|
||||
|
||||
void _contextualActions(BuildContext context, Room room) async {
|
||||
|
|
|
@ -38,7 +38,7 @@ class NewSpaceController extends State<NewSpace> {
|
|||
),
|
||||
);
|
||||
if (roomID.error == null) {
|
||||
context.go('/rooms/spaces/${roomID.result!}');
|
||||
context.go('/rooms/${roomID.result!}');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue