import 'package:flutter/material.dart'; import 'package:kooltab2/viewmodels/bar_screen_view_model.dart'; import 'package:provider/provider.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; await context.read().createTab(name.trim()); }