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

639: Invalidate card frontend #946

Merged
merged 18 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2e08506
639: invalidate card if expired
f1sh1918 Apr 18, 2023
dbd026b
639: fix isCardExpired
f1sh1918 Apr 18, 2023
e1e60a9
639: adjust text
f1sh1918 Apr 19, 2023
c2efb14
Update frontend/lib/identification/verification_workflow/dialogs/posi…
f1sh1918 Apr 20, 2023
2e38f73
Update frontend/lib/identification/card_detail_view/card_detail_view.…
f1sh1918 Apr 20, 2023
853ff0d
Merge branch 'main' into 639-invalidate-card-frontend
f1sh1918 Apr 24, 2023
240ac87
639: setLastCardVerification by card activation, remove invalid card …
f1sh1918 Apr 25, 2023
7361737
639: add validCard flag in settings, add card info texts for invalidC…
f1sh1918 Apr 26, 2023
ad374c4
639: add CardVerification extension to protobuf, set cardVerification…
f1sh1918 Apr 26, 2023
7e742a8
Update frontend/lib/identification/card_detail_view/card_detail_view.…
f1sh1918 Apr 27, 2023
a5d8e2b
Update frontend/lib/identification/card_detail_view/verification_code…
f1sh1918 Apr 27, 2023
bab04f6
639: use backend timestamp for activation, use lastVerificationTimeSt…
f1sh1918 Apr 27, 2023
08d35c7
Merge remote-tracking branch 'origin/639-invalidate-card-frontend' in…
f1sh1918 Apr 27, 2023
8743e5a
639: add unit comment, remove unneeded type check
f1sh1918 Apr 27, 2023
d02591b
Update backend/src/main/kotlin/app/ehrenamtskarte/backend/verificatio…
f1sh1918 Apr 28, 2023
0384b12
Update specs/card.proto
f1sh1918 Apr 28, 2023
67568f4
639: adjust date time for secondsSinceEpoch
f1sh1918 Apr 28, 2023
7b1b6bd
639: update spec
f1sh1918 Apr 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/build-configs/bayern/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const localization: LocalizationType = {
positiveVerificationDialogTitle: "Karte ist gültig",
},
moreActions: {
applyForAnotherCardTitle: "Weitere Ehrenamtskarte beantragen",
applyForAnotherCardTitle: "Ehrenamtskarte beantragen oder verlängern",
applyForAnotherCardDescription: "Ihre hinterlegte Karte bleibt erhalten.",
activateAnotherCardTitle: "Anderen Aktivierungscode einscannen",
activateAnotherCardDescription: "Dadurch wird die hinterlegte Karte vom Gerät gelöscht.",
Expand Down
2 changes: 1 addition & 1 deletion frontend/build-configs/nuernberg/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const localization: LocalizationType = {
positiveVerificationDialogTitle: "Pass ist gültig",
},
moreActions: {
applyForAnotherCardTitle: "Weiteren Nürnberg-Pass beantragen",
applyForAnotherCardTitle: "Nürnberg-Pass beantragen oder verlängern",
applyForAnotherCardDescription: "Ihr hinterlegter Pass bleibt erhalten.",
activateAnotherCardTitle: "Anderen Aktivierungscode einscannen",
activateAnotherCardDescription: "Dadurch wird der hinterlegte Pass vom Gerät gelöscht.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:ehrenamtskarte/graphql/graphql_api.dart';
import 'package:ehrenamtskarte/identification/card_detail_view/more_actions_dialog.dart';
import 'package:ehrenamtskarte/identification/card_detail_view/verification_code_view.dart';
import 'package:ehrenamtskarte/identification/id_card/id_card.dart';
import 'package:ehrenamtskarte/identification/util/card_info_utils.dart';
import 'package:ehrenamtskarte/proto/card.pb.dart';
import 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
Expand Down Expand Up @@ -45,9 +46,9 @@ class CardDetailView extends StatelessWidget {
final paddedCard = Padding(
padding: const EdgeInsets.all(8),
child: IdCard(
cardInfo: userCode.info,
region: region != null ? Region(region.prefix, region.name) : null,
),
cardInfo: userCode.info,
region: region != null ? Region(region.prefix, region.name) : null,
isExpired: isCardExpired(userCode.info)),
);
final richQrCode = RichQrCode(userCode: userCode, onMoreActionsPressed: () => _onMoreActionsPressed(context));

Expand Down Expand Up @@ -107,6 +108,7 @@ class RichQrCode extends StatelessWidget {

@override
Widget build(BuildContext context) {
final bool isExpired = isCardExpired(userCode.info);
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Column(
Expand All @@ -115,13 +117,15 @@ class RichQrCode extends StatelessWidget {
Container(
padding: const EdgeInsets.only(bottom: 4),
constraints: const BoxConstraints(maxWidth: 300),
child: const Text(
"Mit diesem QR-Code können Sie sich"
" bei Akzeptanzstellen ausweisen:",
child: Text(
isExpired
? "Ihre Karte ist abgelaufen.\n Unter weitere Aktionen können sie einen Antrag zur Verlängerung stellen."
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
: "Mit diesem QR-Code können Sie sich"
" bei Akzeptanzstellen ausweisen:",
textAlign: TextAlign.center,
),
),
Flexible(child: VerificationCodeView(userCode: userCode)),
Flexible(child: isExpired ? Container() : VerificationCodeView(userCode: userCode)),
Container(
alignment: Alignment.center,
child: TextButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,39 @@ class MoreActionsDialog extends StatelessWidget {
return AlertDialog(
contentPadding: const EdgeInsets.only(top: 12),
title: const Text("Weitere Aktionen"),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text(localization.applyForAnotherCardTitle),
subtitle: Text(localization.applyForAnotherCardDescription),
leading: const Icon(Icons.assignment, size: 36),
onTap: () {
Navigator.pop(context);
startApplication();
},
),
ListTile(
title: Text(localization.activateAnotherCardTitle),
subtitle: Text(localization.activateAnotherCardDescription),
leading: const Icon(Icons.add_card, size: 36),
onTap: () {
Navigator.pop(context);
startActivation();
},
),
ListTile(
title: Text(localization.verifyTitle),
subtitle: Text(localization.verifyDescription),
leading: const Icon(Icons.verified, size: 36),
onTap: () {
Navigator.pop(context);
startVerification();
},
),
],
content: SingleChildScrollView(
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text(localization.applyForAnotherCardTitle),
subtitle: Text(localization.applyForAnotherCardDescription),
leading: const Icon(Icons.assignment, size: 36),
onTap: () {
Navigator.pop(context);
startApplication();
},
),
ListTile(
title: Text(localization.activateAnotherCardTitle),
subtitle: Text(localization.activateAnotherCardDescription),
leading: const Icon(Icons.add_card, size: 36),
onTap: () {
Navigator.pop(context);
startActivation();
},
),
ListTile(
title: Text(localization.verifyTitle),
subtitle: Text(localization.verifyDescription),
leading: const Icon(Icons.verified, size: 36),
onTap: () {
Navigator.pop(context);
startVerification();
},
),
],
),
),
actions: [TextButton(onPressed: () => Navigator.pop(context), child: const Text("Abbrechen"))],
);
Expand Down
9 changes: 6 additions & 3 deletions frontend/lib/identification/id_card/card_content.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:ehrenamtskarte/build_config/build_config.dart';
import 'package:ehrenamtskarte/build_config/build_config.dart' show buildConfig;
import 'package:ehrenamtskarte/identification/id_card/card_header_logo.dart';
import 'package:ehrenamtskarte/identification/id_card/id_card.dart';
import 'package:ehrenamtskarte/proto/card.pb.dart';
Expand Down Expand Up @@ -40,8 +40,9 @@ PaddingStyle paddingHeader = PaddingStyle(
class CardContent extends StatelessWidget {
final CardInfo cardInfo;
final Region? region;
final bool isExpired;

const CardContent({super.key, required this.cardInfo, this.region});
const CardContent({super.key, required this.cardInfo, this.region, required this.isExpired});

String get _formattedExpirationDate {
final expirationDay = cardInfo.hasExpirationDay() ? cardInfo.expirationDay : null;
Expand Down Expand Up @@ -182,7 +183,9 @@ class CardContent extends StatelessWidget {
maxLines: 1,
text: TextSpan(
text: "Gültig bis: ",
style: TextStyle(fontSize: 14 * scaleFactor, color: textColor),
style: TextStyle(
fontSize: 14 * scaleFactor,
color: isExpired ? Theme.of(context).colorScheme.error : textColor),
children: [TextSpan(text: _formattedExpirationDate)],
),
),
Expand Down
8 changes: 3 additions & 5 deletions frontend/lib/identification/id_card/id_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class Region with EquatableMixin {
class IdCard extends StatelessWidget {
final CardInfo cardInfo;
final Region? region;
final bool isExpired;

const IdCard({super.key, required this.cardInfo, required this.region});
const IdCard({super.key, required this.cardInfo, required this.region, required this.isExpired});

@override
Widget build(BuildContext context) {
Expand All @@ -38,10 +39,7 @@ class IdCard extends StatelessWidget {
child: MediaQuery(
// Ignore text scale factor to enforce the same layout on all devices.
data: mediaQueryData.copyWith(textScaleFactor: 1),
child: CardContent(
cardInfo: cardInfo,
region: region,
),
child: CardContent(cardInfo: cardInfo, region: region, isExpired: isExpired),
),
),
),
Expand Down
7 changes: 7 additions & 0 deletions frontend/lib/identification/util/card_info_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ extension Hashing on CardInfo {
return utf8.encode(canonicalizedJsonString);
}
}

bool isCardExpired(CardInfo cardInfo) {
final expirationDay = cardInfo.hasExpirationDay() ? cardInfo.expirationDay : null;
return expirationDay == null
? false
: DateTime.fromMillisecondsSinceEpoch(0).add(Duration(days: expirationDay)).isBefore(DateTime.now());
}
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class PositiveVerificationResultDialogState extends State<PositiveVerificationRe
children: <Widget>[
Flexible(
child: IdCard(
cardInfo: widget.cardInfo,
region: region != null ? Region(region.prefix, region.name) : null,
),
cardInfo: widget.cardInfo,
region: region != null ? Region(region.prefix, region.name) : null,
isExpired: false),
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved
),
if (widget.isStaticVerificationCode)
Flexible(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ class VerificationQrScannerPage extends StatelessWidget {

Future<void> _onSuccess(BuildContext context, CardInfo cardInfo, bool isStaticVerificationCode) async {
await PositiveVerificationResultDialog.show(
context: context,
cardInfo: cardInfo,
isStaticVerificationCode: isStaticVerificationCode,
);
context: context, cardInfo: cardInfo, isStaticVerificationCode: isStaticVerificationCode);
}
}
2 changes: 2 additions & 0 deletions frontend/lib/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ThemeData get lightTheme {
secondary: primaryColor,
background: Colors.white,
surfaceVariant: const Color(0xffefefef),
error: const Color(0xffcc0000),
),
textTheme: defaultTypography.copyWith(
headlineMedium: defaultTypography.headlineMedium?.apply(color: Colors.black87),
Expand Down Expand Up @@ -54,6 +55,7 @@ ThemeData get darkTheme {
secondary: primaryColor,
background: const Color(0xff121212),
surfaceVariant: const Color(0xff262626),
error: const Color(0xff8b0000),
),
textTheme: defaultTypography.copyWith(
headlineMedium: defaultTypography.headlineMedium?.apply(color: Colors.white),
Expand Down