Files
stadtbote-app/lib/popups/tasks_popups/scan_barcodes_popup.dart
T

105 lines
4.2 KiB
Dart

// 26.02.2025 Nach Abstimmung mit Gunnar entfernt
//import 'package:flutter/material.dart';
//import 'package:flutter/services.dart';
//import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
//import 'package:stadtbote/model/task_info.dart';
//import 'package:stadtbote/tools/util.dart';
/*showScanBarcodesPopup(BuildContext context, TaskInfo taskInfo, Function(List<String> barcodes) onFinished) async {
await showDialog(
context: context,
builder: (BuildContext context) {
return WillPopScope(
onWillPop: () async {
return await taskDialogSecurityException(context);
},
child: AlertDialog(
contentPadding: EdgeInsets.zero,
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
List<String> scannedBarcodes = [];
final ValueNotifier<List<Widget>> scannedBarcodeWidgetsNotifier = ValueNotifier<List<Widget>>([]);
List<Widget> createBarcodeWidgets() {
List<Widget> barcodeWidgets = [];
for (var barcode in scannedBarcodes) {
barcodeWidgets.add(SizedBox(
height: 20,
child: Center(child: Text(barcode)),
));
}
return barcodeWidgets;
}
void scanBarcode() async {
String barcodeScanResult;
try {
barcodeScanResult = await FlutterBarcodeScanner.scanBarcode('#ff6666', 'Abbrechen', true, ScanMode.QR);
scannedBarcodes.add(barcodeScanResult);
var barcodeWidgets = createBarcodeWidgets();
scannedBarcodeWidgetsNotifier.value = barcodeWidgets;
} on PlatformException {
barcodeScanResult = 'Failed to get platform version.';
}
}
return SizedBox(
key: GlobalKey(),
height: 345,
width: MediaQuery.of(context).size.width * 0.8,
child: Container(
height: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 0.5,
),
),
child: Padding(
padding: const EdgeInsets.all(35.0),
child: Column(
children: [
const Text('Gescannte Barcodes'),
const SizedBox(height: 20),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 0.5,
),
),
height: 100,
child: ValueListenableBuilder<List<Widget>>(
valueListenable: scannedBarcodeWidgetsNotifier,
builder: (context, value, child) {
return ListView(padding: const EdgeInsets.all(8), children: value);
},
),
),
const SizedBox(height: 20),
getDefaultButton('Hinzufügen', buttonHeight: 50, () => {scanBarcode()}),
const SizedBox(height: 10),
getDefaultButton('Übernehmen', buttonHeight: 50, () => {
Navigator.of(context).pop(),
onFinished(scannedBarcodes)})
],
),
),
));
})));
});
}*/