import 'package:flutter/material.dart'; import 'package:kooltab2/viewmodels/bar_screen_view_model.dart'; import 'package:provider/provider.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; Future showNewTabDialog(BuildContext context) async { final controller = TextEditingController(); final name = await showDialog( context: context, builder: (dialogContext) { return AlertDialog( title: const Text('Open new tab'), content: TextField( controller: controller, autofocus: true, decoration: const InputDecoration(labelText: 'Customer / group name'), onSubmitted: (value) { Navigator.of(dialogContext).pop(value); }, ), actionsPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16), actions: [ TextButton( onPressed: () => Navigator.of(dialogContext).pop(), child: const Text('Cancel'), ), FilledButton( onPressed: () { Navigator.of(dialogContext).pop(controller.text); }, child: const Text('Open tab'), ), ], ); }, ); if (name == null || name.trim().isEmpty) return; if (!context.mounted) return; try { await context.read().createTab(name.trim()); } catch (e, stack) { Sentry.captureException(e, stackTrace: stack); if (!context.mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Could not create tab: $e')), ); } }