176 lines
5.3 KiB
Dart
176 lines
5.3 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:fluro/fluro.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:yumi/modules/room/background/room_background_preview_page.dart';
|
|
import 'package:yumi/modules/room/background/room_background_select_page.dart';
|
|
import 'package:yumi/modules/room/background/room_background_upload_page.dart';
|
|
import 'package:yumi/modules/room/edit/room_edit_page.dart';
|
|
import 'package:yumi/modules/room/music/room_music_page.dart';
|
|
import 'package:yumi/modules/room/them/room_theme_page.dart';
|
|
import 'package:yumi/modules/room/voice_room_page.dart';
|
|
import 'package:yumi/app/routes/sc_router_init.dart';
|
|
|
|
class VoiceRoomRoute implements SCIRouterProvider {
|
|
static String voiceRoom = '/room';
|
|
static String roomEdit = '/room/roomEdit';
|
|
static String roomTheme = '/room/roomTheme';
|
|
static String roomBackgroundSelect = '/room/background/select';
|
|
static String roomBackgroundPreview = '/room/background/preview';
|
|
static String roomBackgroundUpload = '/room/background/upload';
|
|
static String roomMusic = '/room/music';
|
|
|
|
static Route<T> _buildRoute<T>(Widget page, {RouteSettings? settings}) {
|
|
if (Platform.isIOS) {
|
|
return CupertinoPageRoute<T>(builder: (_) => page, settings: settings);
|
|
}
|
|
return MaterialPageRoute<T>(builder: (_) => page, settings: settings);
|
|
}
|
|
|
|
static Route<T> _buildDarkRoute<T>(Widget page, {RouteSettings? settings}) {
|
|
return PageRouteBuilder<T>(
|
|
settings: settings,
|
|
opaque: true,
|
|
barrierColor: const Color(0xFF071F1B),
|
|
transitionDuration: const Duration(milliseconds: 180),
|
|
reverseTransitionDuration: const Duration(milliseconds: 160),
|
|
pageBuilder:
|
|
(context, animation, secondaryAnimation) =>
|
|
ColoredBox(color: const Color(0xFF071F1B), child: page),
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
final tween = Tween<Offset>(
|
|
begin: const Offset(1, 0),
|
|
end: Offset.zero,
|
|
).chain(CurveTween(curve: Curves.easeOutCubic));
|
|
return SlideTransition(position: animation.drive(tween), child: child);
|
|
},
|
|
);
|
|
}
|
|
|
|
static Future<T?> openVoiceRoom<T>(
|
|
BuildContext context, {
|
|
bool replace = false,
|
|
bool rootNavigator = false,
|
|
}) {
|
|
final navigator = Navigator.of(context, rootNavigator: rootNavigator);
|
|
final route = _buildRoute<T>(
|
|
const VoiceRoomPage(),
|
|
settings: RouteSettings(name: voiceRoom),
|
|
);
|
|
if (replace) {
|
|
return navigator.pushReplacement<T, T>(route);
|
|
}
|
|
return navigator.push<T>(route);
|
|
}
|
|
|
|
static Future<T?> openRoomEdit<T>(
|
|
BuildContext context, {
|
|
required bool needRestCurrentRoomInfo,
|
|
bool rootNavigator = true,
|
|
}) {
|
|
return Navigator.of(context, rootNavigator: rootNavigator).push<T>(
|
|
_buildRoute<T>(
|
|
RoomEditPage(
|
|
needRestCurrentRoomInfo: needRestCurrentRoomInfo ? "true" : "false",
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
static Future<T?> openRoomTheme<T>(
|
|
BuildContext context, {
|
|
bool rootNavigator = false,
|
|
}) {
|
|
return Navigator.of(
|
|
context,
|
|
rootNavigator: rootNavigator,
|
|
).push<T>(_buildRoute<T>(RoomThemePage()));
|
|
}
|
|
|
|
static Future<T?> openRoomBackgroundSelect<T>(
|
|
BuildContext context, {
|
|
bool rootNavigator = false,
|
|
}) {
|
|
return Navigator.of(
|
|
context,
|
|
rootNavigator: rootNavigator,
|
|
).push<T>(_buildRoute<T>(const RoomBackgroundSelectPage()));
|
|
}
|
|
|
|
static Future<T?> openRoomBackgroundUpload<T>(
|
|
BuildContext context, {
|
|
bool rootNavigator = false,
|
|
}) {
|
|
return Navigator.of(
|
|
context,
|
|
rootNavigator: rootNavigator,
|
|
).push<T>(_buildRoute<T>(const RoomBackgroundUploadPage()));
|
|
}
|
|
|
|
static Future<T?> openRoomBackgroundPreview<T>(
|
|
BuildContext context, {
|
|
String? backgroundPath,
|
|
bool rootNavigator = false,
|
|
}) {
|
|
return Navigator.of(context, rootNavigator: rootNavigator).push<T>(
|
|
_buildRoute<T>(RoomBackgroundPreviewPage(backgroundPath: backgroundPath)),
|
|
);
|
|
}
|
|
|
|
static Future<T?> openRoomMusic<T>(
|
|
BuildContext context, {
|
|
bool rootNavigator = false,
|
|
}) {
|
|
return Navigator.of(context, rootNavigator: rootNavigator).push<T>(
|
|
_buildDarkRoute<T>(
|
|
const RoomMusicPage(),
|
|
settings: RouteSettings(name: roomMusic),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void initRouter(FluroRouter router) {
|
|
router.define(
|
|
voiceRoom,
|
|
handler: Handler(handlerFunc: (_, params) => VoiceRoomPage()),
|
|
);
|
|
router.define(
|
|
roomTheme,
|
|
handler: Handler(handlerFunc: (_, params) => RoomThemePage()),
|
|
);
|
|
router.define(
|
|
roomBackgroundSelect,
|
|
handler: Handler(
|
|
handlerFunc: (_, params) => const RoomBackgroundSelectPage(),
|
|
),
|
|
);
|
|
router.define(
|
|
roomBackgroundPreview,
|
|
handler: Handler(
|
|
handlerFunc: (_, params) => const RoomBackgroundPreviewPage(),
|
|
),
|
|
);
|
|
router.define(
|
|
roomBackgroundUpload,
|
|
handler: Handler(
|
|
handlerFunc: (_, params) => const RoomBackgroundUploadPage(),
|
|
),
|
|
);
|
|
router.define(
|
|
roomMusic,
|
|
handler: Handler(handlerFunc: (_, params) => const RoomMusicPage()),
|
|
);
|
|
router.define(
|
|
roomEdit,
|
|
handler: Handler(
|
|
handlerFunc:
|
|
(_, params) => RoomEditPage(
|
|
needRestCurrentRoomInfo: params['need']?.first ?? "false",
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|