Final commit.
This commit is contained in:
74
lib/widget/scanner/manual_entry_dialog.dart
Normal file
74
lib/widget/scanner/manual_entry_dialog.dart
Normal file
@ -0,0 +1,74 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Öffnet den manuellen Scan-Code-Eingabe-Dialog und liefert den
|
||||
/// eingegebenen Code (oder `null` bei Abbruch / leerer Eingabe).
|
||||
Future<String?> showManualEntryDialog(BuildContext context) {
|
||||
return showDialog<String>(
|
||||
context: context,
|
||||
builder: (_) => const ManualEntryDialog(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Fallback-Eingabe, wenn ein Sticker nicht scanbar ist (beschädigt,
|
||||
/// schlechtes Licht). Erwartet das gleiche Format wie der QR-Code:
|
||||
/// `Artikelnr;Kundennr;Belegnr`.
|
||||
class ManualEntryDialog extends StatefulWidget {
|
||||
const ManualEntryDialog({super.key});
|
||||
|
||||
@override
|
||||
State<ManualEntryDialog> createState() => _ManualEntryDialogState();
|
||||
}
|
||||
|
||||
class _ManualEntryDialogState extends State<ManualEntryDialog> {
|
||||
final _controller = TextEditingController();
|
||||
final _focusNode = FocusNode();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => _focusNode.requestFocus());
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
final v = _controller.text.trim();
|
||||
if (v.isEmpty) return;
|
||||
Navigator.of(context).pop(v);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Scan-Code eingeben'),
|
||||
content: TextField(
|
||||
controller: _controller,
|
||||
focusNode: _focusNode,
|
||||
autocorrect: false,
|
||||
textInputAction: TextInputAction.done,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Artikelnr;Kundennr;Belegnr',
|
||||
hintText: 'z. B. BRETT-200;4711;AB-2026-0001',
|
||||
helperText: 'Format wie auf dem Sticker — drei Werte mit Semikolon',
|
||||
),
|
||||
onSubmitted: (_) => _submit(),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Abbrechen'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: _submit,
|
||||
child: const Text('Übernehmen'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user