Files
Client/lib/widget/info_dialog.dart
T

44 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import '../utils/clipboard_helper.dart';
class InfoDialog {
/// Shows a single-text dialog. When [copyable] is true (default for error
/// details surfaces), the dialog body is selectable and a "Kopieren" action
/// places it on the clipboard with a SnackBar confirmation.
static void show(
BuildContext context,
String info, {
bool copyable = false,
String? title,
}) {
showDialog<void>(
context: context,
builder: (dialogContext) {
final theme = Theme.of(dialogContext);
return AlertDialog(
title: title != null ? Text(title) : null,
content: SingleChildScrollView(
child: copyable
? SelectableText(info, style: theme.textTheme.bodyMedium)
: Text(info, style: theme.textTheme.bodyMedium),
),
contentPadding: const EdgeInsets.fromLTRB(20, 20, 20, 12),
actions: [
if (copyable)
TextButton.icon(
onPressed: () => copyToClipboard(dialogContext, info),
icon: const Icon(Icons.copy_outlined, size: 18),
label: const Text('Kopieren'),
),
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(),
child: const Text('Schließen'),
),
],
);
},
);
}
}