2026-05-19 08:46:35 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2026-06-16 17:34:00 +08:00
|
|
|
|
import 'package:get_it/get_it.dart';
|
2026-05-29 14:13:34 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
2026-07-02 16:04:30 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
2026-08-25 11:34:32 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
2026-05-19 08:46:35 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_bloc.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_event.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_state.dart';
|
2026-05-29 14:13:34 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
2026-08-07 08:49:29 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/site/presentation/widgets/site_selector_widget.dart';
|
2026-05-19 08:46:35 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/widgets/power_card.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/widgets/stats_grid.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/widgets/work_order_card.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/widgets/quick_entry_card.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/widgets/power_trend_chart.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/widgets/plant_overview_card.dart';
|
2026-06-05 19:06:21 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/features/v2/home/presentation/widgets/tcp_status_indicator.dart';
|
2026-06-09 14:39:55 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/components/device_status_modal.dart';
|
2026-09-10 09:02:23 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/components/agora_video_player.dart';
|
2026-06-09 14:39:55 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/device_status_bloc.dart';
|
2026-05-19 08:46:35 +08:00
|
|
|
|
|
2026-06-16 17:34:00 +08:00
|
|
|
|
import '../../../../remote_control/presentation/bloc/remote_control_cubit.dart';
|
|
|
|
|
|
|
2026-05-19 08:46:35 +08:00
|
|
|
|
class HomeV2Page extends StatefulWidget {
|
|
|
|
|
|
const HomeV2Page({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<HomeV2Page> createState() => _HomeV2PageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _HomeV2PageState extends State<HomeV2Page> {
|
|
|
|
|
|
late HomeV2Bloc _bloc;
|
|
|
|
|
|
|
2026-09-10 09:02:23 +08:00
|
|
|
|
// ===== 电站实时视频(声网)默认测试配置 =====
|
|
|
|
|
|
// 弹窗打开就用这组值自动开播,输入框仍保留,可随时改完点「重新加载」
|
|
|
|
|
|
// TODO: 接口对接后改为后端下发的真实值
|
|
|
|
|
|
static const String _agoraAppId = '875f6494d87548e783fefbf33f598c97';
|
|
|
|
|
|
static const String _agoraChannel = '36test-01';
|
|
|
|
|
|
static const String _agoraToken =
|
|
|
|
|
|
'007eJxTYLhsYtaz3e2gTMKZ27JzrOs/KB3OTFaYKfGX2+/Y6zem5TMUGCzMTdPMTCxNUoAME4tUcwvjtNS0pDRj4zRTS4tkS3P55PlZDYGMDGsfyTEyMkAgiM/JYGxWklpcomtgyMAAAN9rIEI=';
|
|
|
|
|
|
|
2026-05-19 08:46:35 +08:00
|
|
|
|
@override
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
_bloc = context.read<HomeV2Bloc>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Scaffold(
|
2026-08-25 11:34:32 +08:00
|
|
|
|
backgroundColor: context.appColors.pageBackground,
|
2026-06-16 17:34:00 +08:00
|
|
|
|
body: BlocConsumer<HomeV2Bloc, HomeV2State>(
|
|
|
|
|
|
listener: (context, state) {
|
|
|
|
|
|
// 🔥 监听错误状态,显示友好提示
|
|
|
|
|
|
if (state is HomeV2Error && state.shouldShowError) {
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
SnackBar(
|
|
|
|
|
|
content: Text(state.message),
|
|
|
|
|
|
duration: const Duration(seconds: 2),
|
|
|
|
|
|
behavior: SnackBarBehavior.floating,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
backgroundColor: context.appColors.warning,
|
2026-05-19 08:46:35 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-06-16 17:34:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
builder: (context, state) {
|
2026-07-02 16:04:30 +08:00
|
|
|
|
// 🔥 错误状态显示重试按钮
|
2026-06-16 17:34:00 +08:00
|
|
|
|
if (state is HomeV2Error) {
|
2026-07-02 16:04:30 +08:00
|
|
|
|
return Center(
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
children: [
|
2026-08-25 11:34:32 +08:00
|
|
|
|
Icon(
|
2026-08-07 08:49:29 +08:00
|
|
|
|
Icons.error_outline,
|
|
|
|
|
|
size: 48,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.warning,
|
2026-08-07 08:49:29 +08:00
|
|
|
|
),
|
2026-07-02 16:04:30 +08:00
|
|
|
|
const SizedBox(height: 12),
|
2026-08-07 08:49:29 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
state.message,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
|
color: context.appColors.textTertiary,
|
|
|
|
|
|
),
|
2026-08-07 08:49:29 +08:00
|
|
|
|
),
|
2026-07-02 16:04:30 +08:00
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
|
onPressed: () => _bloc.add(const HomeV2LoadData()),
|
|
|
|
|
|
child: const Text('重试'),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
2026-06-16 17:34:00 +08:00
|
|
|
|
}
|
2026-05-19 08:46:35 +08:00
|
|
|
|
|
|
|
|
|
|
if (state is HomeV2Loaded) {
|
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
|
_bloc.add(const HomeV2Refresh());
|
|
|
|
|
|
},
|
|
|
|
|
|
child: CustomScrollView(
|
|
|
|
|
|
slivers: [
|
|
|
|
|
|
SliverAppBar(
|
|
|
|
|
|
pinned: true,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
backgroundColor: context.appColors.cardBackground,
|
2026-05-19 08:46:35 +08:00
|
|
|
|
elevation: 0,
|
2026-05-25 12:58:29 +08:00
|
|
|
|
automaticallyImplyLeading: false,
|
2026-05-19 08:46:35 +08:00
|
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
|
|
|
|
background: Container(
|
2026-05-25 12:58:29 +08:00
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 40, 16, 16),
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.cardBackground,
|
2026-05-25 12:58:29 +08:00
|
|
|
|
child: Row(
|
2026-05-19 08:46:35 +08:00
|
|
|
|
children: [
|
2026-08-07 08:49:29 +08:00
|
|
|
|
Expanded(child: SiteSelectorWidget()),
|
|
|
|
|
|
const SizedBox(width: 12),
|
2026-06-09 14:39:55 +08:00
|
|
|
|
TcpStatusIndicator(
|
|
|
|
|
|
onTap: () => _showDeviceStatusModal(context),
|
|
|
|
|
|
),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SliverPadding(
|
2026-05-25 12:58:29 +08:00
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 8, 16, 40),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
sliver: SliverList(
|
|
|
|
|
|
delegate: SliverChildListDelegate([
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
|
// 天气和告警
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Container(
|
2026-06-09 14:39:55 +08:00
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
|
horizontal: 12,
|
|
|
|
|
|
vertical: 8,
|
|
|
|
|
|
),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
decoration: BoxDecoration(
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.fillBackground,
|
2026-05-25 12:58:29 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: [
|
2026-08-25 11:34:32 +08:00
|
|
|
|
Icon(
|
2026-06-09 14:39:55 +08:00
|
|
|
|
Icons.cloud_queue,
|
|
|
|
|
|
size: 16,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.primary,
|
2026-06-09 14:39:55 +08:00
|
|
|
|
),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(width: 6),
|
2026-07-02 16:04:30 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
AppLocalizations.of(
|
|
|
|
|
|
context,
|
|
|
|
|
|
).translate('home_v2.weather'),
|
2026-08-25 11:34:32 +08:00
|
|
|
|
style: TextStyle(
|
2026-05-25 12:58:29 +08:00
|
|
|
|
fontSize: 13,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.textSecondary,
|
2026-05-25 12:58:29 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Container(
|
2026-06-09 14:39:55 +08:00
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
|
horizontal: 12,
|
|
|
|
|
|
vertical: 8,
|
|
|
|
|
|
),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
decoration: BoxDecoration(
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.danger.withOpacity(0.1),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: [
|
2026-08-25 11:34:32 +08:00
|
|
|
|
Icon(
|
2026-06-09 14:39:55 +08:00
|
|
|
|
Icons.warning_amber_rounded,
|
|
|
|
|
|
size: 16,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.danger,
|
2026-06-09 14:39:55 +08:00
|
|
|
|
),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(width: 6),
|
2026-07-02 16:04:30 +08:00
|
|
|
|
Expanded(
|
2026-05-25 12:58:29 +08:00
|
|
|
|
child: Text(
|
2026-07-02 16:04:30 +08:00
|
|
|
|
AppLocalizations.of(
|
|
|
|
|
|
context,
|
|
|
|
|
|
).translate('home_v2.emergency_alarm'),
|
2026-08-25 11:34:32 +08:00
|
|
|
|
style: TextStyle(
|
2026-05-25 12:58:29 +08:00
|
|
|
|
fontSize: 13,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.danger,
|
2026-05-25 12:58:29 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(width: 4),
|
2026-08-25 11:34:32 +08:00
|
|
|
|
Icon(
|
2026-06-09 14:39:55 +08:00
|
|
|
|
Icons.arrow_forward_ios,
|
|
|
|
|
|
size: 12,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.danger,
|
2026-06-09 14:39:55 +08:00
|
|
|
|
),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 16),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
PowerCard(data: state.homeData),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(height: 10),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
StatsGrid(data: state.homeData),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(height: 10),
|
2026-06-09 14:39:55 +08:00
|
|
|
|
PlantOverviewCard(
|
|
|
|
|
|
overview: state.homeData.plantOverview,
|
2026-09-10 09:02:23 +08:00
|
|
|
|
onTap: _showPlantVideo,
|
2026-06-09 14:39:55 +08:00
|
|
|
|
),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(height: 10),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
WorkOrderCard(stats: state.homeData.workOrderStats),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(height: 10),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
QuickEntryCard(),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(height: 10),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
PowerTrendChart(
|
|
|
|
|
|
data: state.homeData.powerTrendData,
|
|
|
|
|
|
trendType: state.trendType,
|
2026-06-09 14:39:55 +08:00
|
|
|
|
onToggleType: (type) =>
|
|
|
|
|
|
_bloc.add(HomeV2ToggleTrendType(type)),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
),
|
2026-05-25 12:58:29 +08:00
|
|
|
|
const SizedBox(height: 40),
|
2026-05-19 08:46:35 +08:00
|
|
|
|
]),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-02 16:04:30 +08:00
|
|
|
|
// 🔥 Initial/Loading 状态显示加载指示器
|
2026-08-25 11:34:32 +08:00
|
|
|
|
return Center(
|
|
|
|
|
|
child: CircularProgressIndicator(color: context.appColors.primary),
|
2026-08-07 08:49:29 +08:00
|
|
|
|
);
|
2026-05-19 08:46:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-05-25 12:58:29 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void didChangeDependencies() {
|
|
|
|
|
|
super.didChangeDependencies();
|
|
|
|
|
|
// 首次进入时自动加载数据,但不显示转圈
|
|
|
|
|
|
if (_bloc.state is HomeV2Initial) {
|
2026-06-05 19:06:21 +08:00
|
|
|
|
// 延迟 100ms,确保 AppUserCubit 状态已更新
|
|
|
|
|
|
Future.delayed(const Duration(milliseconds: 100), () {
|
|
|
|
|
|
if (mounted) {
|
|
|
|
|
|
_bloc.add(const HomeV2LoadData());
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-05-25 12:58:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 09:02:23 +08:00
|
|
|
|
/// 点击「电站概览」卡片 → 弹出声网视频组件
|
|
|
|
|
|
///
|
|
|
|
|
|
/// 默认带上测试配置自动开播,同时保留三个输入框可手动修改
|
|
|
|
|
|
void _showPlantVideo() {
|
|
|
|
|
|
AgoraVideoPlayer.showManualInput(
|
|
|
|
|
|
context,
|
|
|
|
|
|
title: '电站实时视频',
|
|
|
|
|
|
initialAppId: _agoraAppId,
|
|
|
|
|
|
initialChannelId: _agoraChannel,
|
|
|
|
|
|
initialToken: _agoraToken,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-25 12:58:29 +08:00
|
|
|
|
void _showPlantSelector() {
|
2026-05-29 14:13:34 +08:00
|
|
|
|
if (_bloc.state is! HomeV2Loaded) return;
|
2026-06-09 14:39:55 +08:00
|
|
|
|
|
2026-05-29 14:13:34 +08:00
|
|
|
|
final currentState = _bloc.state as HomeV2Loaded;
|
|
|
|
|
|
final sites = currentState.sites;
|
2026-06-09 14:39:55 +08:00
|
|
|
|
|
2026-05-29 14:13:34 +08:00
|
|
|
|
if (sites.isEmpty) {
|
2026-07-02 16:04:30 +08:00
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
SnackBar(
|
|
|
|
|
|
content: Text(
|
|
|
|
|
|
AppLocalizations.of(context).translate('home_v2.no_sites'),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
2026-05-29 14:13:34 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-25 12:58:29 +08:00
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
|
context: context,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
backgroundColor: context.appColors.cardBackground,
|
2026-05-25 12:58:29 +08:00
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
|
|
|
|
|
),
|
|
|
|
|
|
builder: (context) {
|
2026-05-29 14:13:34 +08:00
|
|
|
|
return BlocBuilder<HomeV2Bloc, HomeV2State>(
|
|
|
|
|
|
bloc: _bloc,
|
|
|
|
|
|
builder: (context, state) {
|
|
|
|
|
|
if (state is! HomeV2Loaded) return Container();
|
2026-06-09 14:39:55 +08:00
|
|
|
|
|
2026-05-29 14:13:34 +08:00
|
|
|
|
return Container(
|
|
|
|
|
|
padding: const EdgeInsets.all(14),
|
|
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
|
|
maxHeight: MediaQuery.of(context).size.height * 0.6,
|
2026-05-25 12:58:29 +08:00
|
|
|
|
),
|
2026-05-29 14:13:34 +08:00
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: [
|
2026-07-02 16:04:30 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
AppLocalizations.of(
|
|
|
|
|
|
context,
|
|
|
|
|
|
).translate('home_v2.select_site'),
|
2026-08-25 11:34:32 +08:00
|
|
|
|
style: TextStyle(
|
2026-05-29 14:13:34 +08:00
|
|
|
|
fontSize: 18,
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.textPrimary,
|
2026-05-29 14:13:34 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
|
itemCount: state.sites.length,
|
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
|
final site = state.sites[index];
|
|
|
|
|
|
final isSelected = state.selectedSite?.id == site.id;
|
2026-06-09 14:39:55 +08:00
|
|
|
|
|
2026-05-29 14:13:34 +08:00
|
|
|
|
return ListTile(
|
|
|
|
|
|
title: Text(site.siteName),
|
2026-06-09 14:39:55 +08:00
|
|
|
|
subtitle:
|
|
|
|
|
|
site.siteCode != null && site.siteCode!.isNotEmpty
|
2026-07-02 16:04:30 +08:00
|
|
|
|
? Text(
|
|
|
|
|
|
AppLocalizations.of(context)
|
|
|
|
|
|
.translate('home_v2.site_code')
|
|
|
|
|
|
.replaceAll('%s', site.siteCode!),
|
|
|
|
|
|
)
|
2026-05-29 14:13:34 +08:00
|
|
|
|
: null,
|
|
|
|
|
|
trailing: isSelected
|
2026-08-25 11:34:32 +08:00
|
|
|
|
? Icon(
|
2026-06-09 14:39:55 +08:00
|
|
|
|
Icons.check,
|
2026-08-25 11:34:32 +08:00
|
|
|
|
color: context.appColors.primary,
|
2026-06-09 14:39:55 +08:00
|
|
|
|
)
|
2026-05-29 14:13:34 +08:00
|
|
|
|
: null,
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
// 更新全局选中的场站
|
|
|
|
|
|
sl<SiteCubit>().selectSite(site);
|
|
|
|
|
|
Navigator.pop(context);
|
2026-06-09 14:39:55 +08:00
|
|
|
|
|
2026-05-29 14:13:34 +08:00
|
|
|
|
// 切换场站后,重新加载首页数据
|
|
|
|
|
|
_bloc.add(const HomeV2LoadData());
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
2026-05-25 12:58:29 +08:00
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-06-09 14:39:55 +08:00
|
|
|
|
|
|
|
|
|
|
// 显示设备状态模态框 - 从底部滑出
|
|
|
|
|
|
void _showDeviceStatusModal(BuildContext context) {
|
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
|
|
topLeft: Radius.circular(16),
|
|
|
|
|
|
topRight: Radius.circular(16),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
builder: (BuildContext context) {
|
2026-06-16 17:34:00 +08:00
|
|
|
|
return MultiBlocProvider(
|
|
|
|
|
|
providers: [
|
2026-07-02 16:04:30 +08:00
|
|
|
|
BlocProvider.value(value: context.read<DeviceStatusBloc>()),
|
2026-06-16 17:34:00 +08:00
|
|
|
|
BlocProvider.value(
|
2026-07-02 16:04:30 +08:00
|
|
|
|
value: GetIt.I<RemoteControlCubit>(), // 🔥 注入 RemoteControlCubit
|
2026-06-16 17:34:00 +08:00
|
|
|
|
),
|
|
|
|
|
|
],
|
2026-06-09 14:39:55 +08:00
|
|
|
|
child: const DeviceStatusModal(),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-05-19 08:46:35 +08:00
|
|
|
|
}
|