Files
flutterApp/lib/features/home/presentation/routes/home_routes.dart
2026-05-13 10:34:07 +08:00

42 lines
2.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:maibu_satabot_v2/features/home/presentation/pages/dj_page.dart';
import 'package:maibu_satabot_v2/features/home/presentation/pages/home_page.dart';
import 'package:maibu_satabot_v2/features/home/presentation/pages/usage.dart';
import 'package:maibu_satabot_v2/features/home/presentation/pages/productDesc.dart';
import '../../../../core/di/injection.dart';
import '../../../../core/router/route_paths.dart';
import '../../../devices/presentation/bloc/device_status_bloc.dart';
import '../../presentation/bloc/permission_request_bloc.dart';
import '../../../remote_control/presentation/bloc/remote_control_cubit.dart';
import '../../../remote_control/presentation/pages/remote_control_page.dart';
import '../pages/route_plan_page.dart';
import '../pages/running_status_page.dart';
class HomeRoutes {
/// 全屏功能页面(不带导航栏)
/// 在 createRouter 的根 routes 中使用 ...HomeRoutes.routes 引入
static List<RouteBase> get routes => [
GoRoute(
path: RoutePaths.remoteControl,
builder: (context, state) => BlocProvider(
// 每次进入该路由,都会创建一个全新的 Cubit 并开启循环
create: (context) => sl<RemoteControlCubit>()..startControlLoop(),
child: const RemoteControlPage(),
),
),
GoRoute(path: RoutePaths.routePlan, builder: (context, state) => const RoutePlanPage()),
GoRoute(path: RoutePaths.djMap, builder: (context, state) => const DjPage()),
GoRoute(path: RoutePaths.productDesc, builder: (context, state) => const ProductPage()),
GoRoute(path: RoutePaths.usage, builder: (context, state) => const ManualPage()),
GoRoute(
path: RoutePaths.runningStatus,
builder: (context, state) => BlocProvider.value(
value: sl<DeviceStatusBloc>(), // 使用全局单例 DeviceStatusBloc,确保数据流不中断
child: const RunningStatusPage(),
),
),
];
}