Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

753: add checkbox for static qr code verification #798

Merged
merged 8 commits into from
Feb 21, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,35 @@ import 'package:ehrenamtskarte/proto/card.pb.dart';
import 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';

class PositiveVerificationResultDialog extends StatelessWidget {
class PositiveVerificationResultDialog extends StatefulWidget {
final CardInfo cardInfo;
final bool hasStaticVerificationCode;
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved

const PositiveVerificationResultDialog({super.key, required this.cardInfo});
const PositiveVerificationResultDialog({
super.key,
required this.cardInfo,
required this.hasStaticVerificationCode,
});

static Future<void> show({
required BuildContext context,
required CardInfo cardInfo,
required bool hasStaticVerificationCode,
}) =>
showDialog(
context: context,
builder: (_) => PositiveVerificationResultDialog(
cardInfo: cardInfo,
hasStaticVerificationCode: hasStaticVerificationCode,
),
);

@override
PositiveVerificationResultDialogState createState() => PositiveVerificationResultDialogState();
}

class PositiveVerificationResultDialogState extends State<PositiveVerificationResultDialog> {
bool isChecked = false;

@override
Widget build(BuildContext context) {
Expand All @@ -19,7 +44,7 @@ class PositiveVerificationResultDialog extends StatelessWidget {
final regionsQuery = GetRegionsByIdQuery(
variables: GetRegionsByIdArguments(
project: projectId,
ids: [cardInfo.extensions.extensionRegion.regionId],
ids: [widget.cardInfo.extensions.extensionRegion.regionId],
),
);

Expand All @@ -28,19 +53,43 @@ class PositiveVerificationResultDialog extends StatelessWidget {
builder: (result, {refetch, fetchMore}) {
final data = result.data;
final region = result.isConcrete && data != null ? regionsQuery.parse(data).regionsByIdInProject[0] : null;
final bool isUncheckedStaticQrCode = !isChecked && widget.hasStaticVerificationCode;
return InfoDialog(
title: localization.positiveVerificationDialogTitle,
icon: Icons.verified_user,
iconColor: Colors.green,
child: IdCard(
cardInfo: cardInfo,
region: region != null ? Region(region.prefix, region.name) : null,
title: isUncheckedStaticQrCode ? "Prüfung notwendig" : localization.positiveVerificationDialogTitle,
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
icon: isUncheckedStaticQrCode ? Icons.info : Icons.verified_user,
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
iconColor: isUncheckedStaticQrCode ? Colors.yellow : Colors.green,
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Flexible(
child: IdCard(
cardInfo: widget.cardInfo,
region: region != null ? Region(region.prefix, region.name) : null,
),
),
if (widget.hasStaticVerificationCode)
Flexible(
child: Padding(
padding: const EdgeInsets.only(top: 16.0),
child: CheckboxListTile(
title: const Text('Ich habe die Daten mit einem amtlichen Lichtbildausweis abgeglichen.'),
checkColor: Theme.of(context).primaryColor,
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
controlAffinity: ListTileControlAffinity.leading,
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = value!;
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
});
},
),
),
)
else
Container()
],
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
),
);
},
);
}

static Future<void> show(BuildContext context, CardInfo cardInfo) =>
showDialog(context: context, builder: (_) => PositiveVerificationResultDialog(cardInfo: cardInfo));
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class VerificationQrScannerPage extends StatelessWidget {
"Der eingescannte Code konnte vom Server nicht verifiziert werden!",
);
} else {
await _onSuccess(context, cardInfo);
await _onSuccess(context, cardInfo, qrcode.hasStaticVerificationCode());
}
} on ServerVerificationException catch (e) {
await _onConnectionError(
Expand Down Expand Up @@ -144,9 +144,13 @@ class VerificationQrScannerPage extends StatelessWidget {
await ConnectionFailedDialog.show(context, message);
}

Future<void> _onSuccess(BuildContext context, CardInfo cardInfo) async {
Future<void> _onSuccess(BuildContext context, CardInfo cardInfo, bool hasStaticVerificationCode) async {
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
_closeWaitingDialog(context);
await PositiveVerificationResultDialog.show(context, cardInfo);
await PositiveVerificationResultDialog.show(
context: context,
cardInfo: cardInfo,
hasStaticVerificationCode: hasStaticVerificationCode,
);
}

void _openWaitingDialog(BuildContext context) {
Expand Down