54 lines
1.3 KiB
Dart
54 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class AppDialog {
|
|
AppDialog._();
|
|
|
|
static Future<bool?> confirm(
|
|
BuildContext context, {
|
|
String title = '确认操作',
|
|
String message = '是否继续?',
|
|
String cancelText = '取消',
|
|
String confirmText = '确认',
|
|
}) {
|
|
return showDialog<bool>(
|
|
context: context,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
title: Text(title),
|
|
content: Text(message),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(false),
|
|
child: Text(cancelText),
|
|
),
|
|
FilledButton(
|
|
onPressed: () => Navigator.of(context).pop(true),
|
|
child: Text(confirmText),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
static Future<void> deviceHealthAlert(
|
|
BuildContext context, {
|
|
required List<String> lines,
|
|
}) {
|
|
return showDialog<void>(
|
|
context: context,
|
|
builder: (dialogContext) {
|
|
return AlertDialog(
|
|
content: Text(lines.join('\n')),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(dialogContext).pop(),
|
|
child: const Text('确定'),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|