import 'package:flutter/material.dart'; /// Small shared widgets/helpers used across the admin screens. void toast(BuildContext context, String message) { ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message))); } class ErrorText extends StatelessWidget { const ErrorText(this.message, {super.key, this.onRetry}); final String message; final VoidCallback? onRetry; @override Widget build(BuildContext context) { return Center( child: Padding( padding: const EdgeInsets.all(24), child: Column( mainAxisSize: MainAxisSize.min, children: [ Text(message, textAlign: TextAlign.center), if (onRetry != null) ...[ const SizedBox(height: 12), OutlinedButton(onPressed: onRetry, child: const Text('Erneut versuchen')), ], ], ), ), ); } } class SectionHeader extends StatelessWidget { const SectionHeader(this.title, {super.key, this.action}); final String title; final Widget? action; @override Widget build(BuildContext context) { return Row( children: [ Expanded( child: Text(title, style: Theme.of(context).textTheme.titleMedium), ), ?action, ], ); } } /// Single-line text prompt dialog. Returns the trimmed value or null. Future promptText(BuildContext context, String title, String label) { final controller = TextEditingController(); return showDialog( context: context, builder: (context) => AlertDialog( title: Text(title), content: TextField( controller: controller, autofocus: true, decoration: InputDecoration(labelText: label), onSubmitted: (v) => Navigator.of(context).pop(v.trim()), ), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), child: const Text('Abbrechen'), ), FilledButton( onPressed: () => Navigator.of(context).pop(controller.text.trim()), child: const Text('OK'), ), ], ), ); }