Commit 9cd24522 authored by 张宏's avatar 张宏

2222

parent 53839dd5
......@@ -41,7 +41,8 @@ class MonitoringIndexContent extends StatefulWidget {
class _MonitoringIndexContentState extends State<MonitoringIndexContent> {
late final MonitoringIndexCubit _monitoringIndexCubit;
StreamSubscription<OpenBluetoothScanEvent>? _bluetoothScanEventSub;
bool _isAlertDialogShowing = false;
/// 正在弹出框展示的告警,为空表示当前没有弹窗
AlertInfoBO? _currentDialogAlert;
@override
void initState() {
......@@ -62,11 +63,11 @@ class _MonitoringIndexContentState extends State<MonitoringIndexContent> {
@override
Widget build(BuildContext context) {
return BlocListener<MonitoringIndexCubit, MonitoringIndexState>(
listenWhen: (previous, current) =>
current.selectedAlert != null &&
current.selectedAlert != previous.selectedAlert,
listener: (context, state) {
if (state.selectedAlert != null && !_isAlertDialogShowing) {
_isAlertDialogShowing = true;
_showAlertDetailDialog(state.selectedAlert!);
}
},
child: BlocBuilder<MonitoringIndexCubit, MonitoringIndexState>(
builder: (context, state) {
......@@ -260,6 +261,10 @@ class _MonitoringIndexContentState extends State<MonitoringIndexContent> {
}
void _showAlertDetailDialog(AlertInfoBO alert) {
// 已有弹窗在展示,忽略新的请求
if (_currentDialogAlert != null) return;
_currentDialogAlert = alert;
showDialog<void>(
context: context,
builder: (_) => BlocProvider.value(
......@@ -267,7 +272,7 @@ class _MonitoringIndexContentState extends State<MonitoringIndexContent> {
child: MonitoringAlertDetailDialog(alert: alert),
),
).then((_) {
_isAlertDialogShowing = false;
_currentDialogAlert = null;
_monitoringIndexCubit.clearSelectedAlert();
});
}
......
......@@ -48,7 +48,7 @@ class MonitoringAlertDetailDialog extends StatelessWidget {
Widget _buildHeader() {
return Container(
padding: EdgeInsets.fromLTRB(40.w, 24.h, 40.w, 24.h),
padding: EdgeInsets.fromLTRB(40.w, 34.h, 40.w, 34.h),
decoration: const BoxDecoration(
// border: Border(
// bottom: BorderSide(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment