Skip to content

Commit

Permalink
Merge pull request #798 from digitalfabrik/753-add-checkbox-static-qr…
Browse files Browse the repository at this point in the history
…-verification

753: add checkbox for static qr code verification
  • Loading branch information
f1sh1918 authored Feb 21, 2023
2 parents 7776364 + 27b04d9 commit d14a3a6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 15 deletions.
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 isStaticVerificationCode;

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

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

@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,40 @@ 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.isStaticVerificationCode;
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 nötig" : localization.positiveVerificationDialogTitle,
icon: isUncheckedStaticQrCode ? Icons.report : Icons.verified_user,
iconColor: isUncheckedStaticQrCode ? Theme.of(context).colorScheme.onBackground : Colors.green,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Flexible(
child: IdCard(
cardInfo: widget.cardInfo,
region: region != null ? Region(region.prefix, region.name) : null,
),
),
if (widget.isStaticVerificationCode)
Flexible(
child: Padding(
padding: const EdgeInsets.only(top: 16.0),
child: CheckboxListTile(
title: const Text('Ich habe die Daten mit einem amtlichen Lichtbildausweis abgeglichen.'),
controlAffinity: ListTileControlAffinity.leading,
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = value ?? false;
});
},
),
),
)
],
),
);
},
);
}

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 isStaticVerificationCode) async {
_closeWaitingDialog(context);
await PositiveVerificationResultDialog.show(context, cardInfo);
await PositiveVerificationResultDialog.show(
context: context,
cardInfo: cardInfo,
isStaticVerificationCode: isStaticVerificationCode,
);
}

void _openWaitingDialog(BuildContext context) {
Expand Down
8 changes: 8 additions & 0 deletions frontend/lib/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ ThemeData get lightTheme {
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(side: MaterialStatePropertyAll(BorderSide(color: primaryColor, width: 1))),
),
checkboxTheme: CheckboxThemeData(
checkColor: const MaterialStatePropertyAll(Colors.black),
fillColor: MaterialStatePropertyAll(primaryColor),
),
);
}

Expand Down Expand Up @@ -66,5 +70,9 @@ ThemeData get darkTheme {
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(side: MaterialStatePropertyAll(BorderSide(color: primaryColor, width: 1))),
),
checkboxTheme: CheckboxThemeData(
checkColor: const MaterialStatePropertyAll(Colors.white),
fillColor: MaterialStatePropertyAll(primaryColor),
),
);
}

0 comments on commit d14a3a6

Please sign in to comment.