103 lines
3.5 KiB
Dart
103 lines
3.5 KiB
Dart
|
|
import 'dart:async';
|
||
|
|
|
||
|
|
import 'package:flutter/foundation.dart' show debugPrintSynchronously;
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import '../../../../core/localization/app_localizations.dart';
|
||
|
|
import '../cubit/device_alarms_cubit.dart';
|
||
|
|
import 'device_alarm_history_tab.dart';
|
||
|
|
import 'device_alarm_realtime_list.dart';
|
||
|
|
|
||
|
|
Future<void> showDeviceAlarmDialog(
|
||
|
|
BuildContext context, {
|
||
|
|
required DeviceAlarmsCubit cubit,
|
||
|
|
String? deviceSn,
|
||
|
|
}) {
|
||
|
|
unawaited(cubit.ensureSubscriptions(deviceSn: deviceSn));
|
||
|
|
debugPrintSynchronously(
|
||
|
|
'[设备告警] 打开底部面板 site=${cubit.state.siteId} scope=${deviceSn ?? '当前场站全部车辆'} records=${cubit.state.forDevice(deviceSn).alarms.length}',
|
||
|
|
);
|
||
|
|
return showModalBottomSheet<void>(
|
||
|
|
context: context,
|
||
|
|
useRootNavigator: true,
|
||
|
|
isScrollControlled: true,
|
||
|
|
useSafeArea: true,
|
||
|
|
showDragHandle: true,
|
||
|
|
backgroundColor: const Color(0xFFF6FAFE),
|
||
|
|
shape: const RoundedRectangleBorder(
|
||
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||
|
|
),
|
||
|
|
clipBehavior: Clip.antiAlias,
|
||
|
|
builder: (_) => DeviceAlarmDialog(cubit: cubit, deviceSn: deviceSn),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 实时与历史共用场站范围及最新处理状态,各自维护展示/加载组件。
|
||
|
|
class DeviceAlarmDialog extends StatelessWidget {
|
||
|
|
const DeviceAlarmDialog({super.key, required this.cubit, this.deviceSn});
|
||
|
|
final DeviceAlarmsCubit cubit;
|
||
|
|
final String? deviceSn;
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
final l10n = AppLocalizations.of(context);
|
||
|
|
return SafeArea(
|
||
|
|
top: false,
|
||
|
|
child: SizedBox(
|
||
|
|
width: double.infinity,
|
||
|
|
height: MediaQuery.sizeOf(context).height * 0.72,
|
||
|
|
child: DefaultTabController(
|
||
|
|
length: 2,
|
||
|
|
child: Padding(
|
||
|
|
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
|
||
|
|
child: Column(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||
|
|
children: [
|
||
|
|
Row(
|
||
|
|
children: [
|
||
|
|
Expanded(
|
||
|
|
child: Text(
|
||
|
|
l10n.translate(
|
||
|
|
deviceSn == null
|
||
|
|
? 'device_alarms.site_title'
|
||
|
|
: 'device_detail_v2.rec_fault_title',
|
||
|
|
),
|
||
|
|
style: const TextStyle(
|
||
|
|
fontSize: 16,
|
||
|
|
fontWeight: FontWeight.w800,
|
||
|
|
color: Color(0xFF1A2B4A),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
IconButton(
|
||
|
|
tooltip: l10n.translate('common.close'),
|
||
|
|
onPressed: () => Navigator.of(context).pop(),
|
||
|
|
icon: const Icon(Icons.close_rounded),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
TabBar(
|
||
|
|
labelColor: const Color(0xFF1C96F6),
|
||
|
|
tabs: [
|
||
|
|
Tab(text: l10n.translate('device_alarms.realtime')),
|
||
|
|
Tab(text: l10n.translate('device_alarms.history')),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
const SizedBox(height: 10),
|
||
|
|
Expanded(
|
||
|
|
child: TabBarView(
|
||
|
|
children: [
|
||
|
|
DeviceAlarmRealtimeList(cubit: cubit, deviceSn: deviceSn),
|
||
|
|
DeviceAlarmHistoryTab(cubit: cubit, deviceSn: deviceSn),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|