Files
stadtbote-app/lib/popups/tasks_popups/signature_popup.dart
T
Sven 5e7babf265 VHS-Karten integriert, Bildzoom ergänzt und Chat-IDs korrigiert
Unterschriftenerfassung dauerhaft auf Deutsch anzeigen, lokale VHS-Buildkonfiguration und Regressionstests ergänzen sowie Version auf 357.0.0+357 anheben.
2026-10-07 10:41:41 +02:00

103 lines
4.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:signature/signature.dart';
import 'package:stadtbote/model/task_info.dart';
import 'package:stadtbote/tools/app_localizations.dart';
import 'package:stadtbote/tools/util.dart';
showSignaturePopup(BuildContext context, TaskInfo taskInfo, Function(String?) onFinished) async {
await showDialog(
context: context,
builder: (BuildContext context) {
return PopScope(
canPop: false,
onPopInvokedWithResult: (bool didPop, dynamic result) async {
if (!didPop) {
final shouldPop = await taskDialogSecurityException(context, language: AppLanguage.german);
if (shouldPop) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
if (context.mounted) {
Navigator.of(context).pop();
}
}
}
},
child: AlertDialog(
contentPadding: EdgeInsets.zero,
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
final SignatureController controller = SignatureController();
var popupHeight = MediaQuery.of(context).size.height * 0.85;
var popupWidth = MediaQuery.of(context).size.width * 0.85;
String convertPoints(List<Point> points) {
if (points.isNotEmpty) {
String result = "";
for (var point in points) {
if (point.type != PointType.tap) {
result += "${point.offset.dx.toInt()},${point.offset.dy.toInt()};";
} else {
result += "A";
}
}
return result.replaceAll("AA", "A");
}
return "";
}
return SizedBox(
key: GlobalKey(),
height: popupHeight,
width: popupWidth,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 0.5,
),
),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: [
Text(taskInfo.task?.topic ?? ''),
const SizedBox(height: 20),
Expanded(
child: Signature(
controller: controller,
width: 500,
height: 200,
backgroundColor: Colors.lightBlueAccent,
),
),
getDefaultButton(
AppLocalizations.tr('apply', language: AppLanguage.german),
buttonHeight: 50,
() => {
if (controller.points.length > 50)
{Navigator.of(context).pop(), onFinished(convertPoints(controller.points))}
else
{
showAlertDialog(
AppLocalizations.tr('error', language: AppLanguage.german),
AppLocalizations.tr('signature_too_short', language: AppLanguage.german),
)
}
})
],
),
),
));
},
)));
});
}