52 lines
1.6 KiB
Dart
52 lines
1.6 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import '../../../../core/localization/app_localizations.dart';
|
||
|
|
|
||
|
|
/// 只确认用户意图;关闭、返回或取消弹窗均不发送控制请求。
|
||
|
|
Future<bool> confirmEmergencyStop(
|
||
|
|
BuildContext context, {
|
||
|
|
required bool engage,
|
||
|
|
required String sn,
|
||
|
|
}) async {
|
||
|
|
final tr = AppLocalizations.of(context);
|
||
|
|
return await showDialog<bool>(
|
||
|
|
context: context,
|
||
|
|
builder: (dialogContext) => AlertDialog(
|
||
|
|
title: Text(
|
||
|
|
tr.translate(
|
||
|
|
engage
|
||
|
|
? 'remote_control.emergency_confirm_title'
|
||
|
|
: 'remote_control.emergency_release_title',
|
||
|
|
),
|
||
|
|
),
|
||
|
|
content: Text(
|
||
|
|
tr.translate(
|
||
|
|
engage
|
||
|
|
? 'remote_control.emergency_confirm_message'
|
||
|
|
: 'remote_control.emergency_release_message',
|
||
|
|
{'sn': sn},
|
||
|
|
),
|
||
|
|
),
|
||
|
|
actions: [
|
||
|
|
TextButton(
|
||
|
|
key: const ValueKey('emergency-cancel'),
|
||
|
|
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||
|
|
child: Text(tr.translate('remote_control.emergency_cancel')),
|
||
|
|
),
|
||
|
|
FilledButton(
|
||
|
|
key: const ValueKey('emergency-confirm'),
|
||
|
|
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||
|
|
child: Text(
|
||
|
|
tr.translate(
|
||
|
|
engage
|
||
|
|
? 'remote_control.emergency_confirm_stop'
|
||
|
|
: 'remote_control.emergency_confirm_release',
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
) ??
|
||
|
|
false;
|
||
|
|
}
|