2026-06-02 23:28:39 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
2026-06-04 02:30:03 +02:00
|
|
|
import '../../l10n/app_localizations.dart';
|
2026-06-02 23:28:39 +02:00
|
|
|
|
|
|
|
|
class NewDeckDialog extends StatefulWidget {
|
|
|
|
|
const NewDeckDialog({super.key});
|
|
|
|
|
|
|
|
|
|
static Future<String?> show(BuildContext context) {
|
|
|
|
|
return showDialog<String>(
|
|
|
|
|
context: context,
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
builder: (_) => const NewDeckDialog(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<NewDeckDialog> createState() => _NewDeckDialogState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _NewDeckDialogState extends State<NewDeckDialog> {
|
|
|
|
|
final _ctrl = TextEditingController();
|
|
|
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_ctrl.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-06-04 02:30:03 +02:00
|
|
|
final l10n = context.l10n;
|
2026-06-02 23:28:39 +02:00
|
|
|
return CallbackShortcuts(
|
|
|
|
|
bindings: {
|
|
|
|
|
const SingleActivator(LogicalKeyboardKey.escape): () =>
|
|
|
|
|
Navigator.pop(context),
|
|
|
|
|
},
|
|
|
|
|
child: AlertDialog(
|
2026-06-04 02:30:03 +02:00
|
|
|
title: Text(l10n.d('Nieuwe presentatie')),
|
2026-06-02 23:28:39 +02:00
|
|
|
content: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
width: 380,
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _ctrl,
|
|
|
|
|
autofocus: true,
|
2026-06-04 02:30:03 +02:00
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: l10n.d('Titel'),
|
|
|
|
|
hintText: l10n.d('Bijv. Kwartaalupdate Q4'),
|
2026-06-02 23:28:39 +02:00
|
|
|
),
|
2026-06-04 02:30:03 +02:00
|
|
|
validator: (v) => (v == null || v.trim().isEmpty)
|
|
|
|
|
? l10n.d('Vul een titel in')
|
|
|
|
|
: null,
|
2026-06-02 23:28:39 +02:00
|
|
|
onFieldSubmitted: (_) => _submit(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
actions: [
|
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () => Navigator.pop(context),
|
2026-06-04 02:30:03 +02:00
|
|
|
child: Text(l10n.t('cancel')),
|
2026-06-02 23:28:39 +02:00
|
|
|
),
|
2026-06-04 02:30:03 +02:00
|
|
|
ElevatedButton(onPressed: _submit, child: Text(l10n.d('Aanmaken'))),
|
2026-06-02 23:28:39 +02:00
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _submit() {
|
|
|
|
|
if (_formKey.currentState!.validate()) {
|
|
|
|
|
Navigator.pop(context, _ctrl.text.trim());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|