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

Added valid till / from text on cards #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,7 @@
"No QR code was found in the selected file. Please try another one.": "Es wurde in der ausgewählten Datei kein QR-Code gefunden. Bitte versuche es mit einer anderen Datei.",
"The QR code in the selected file is invalid. Please try again.": "Der QR-Code in der ausgewählten Datei ist ungültig. Bitte versuche es erneut.",
"You have already added this QR code. Please select another file.": "Du hast diesen QR-Code bereits hinzugefügt. Bitte wähle eine andere Datei aus.",
"Please give the app permission to access your files to be able to select one.": "Bitte gebe der App die Erlaubnis, auf deine Dateien zuzugreifen, um eine auswählen zu können."
}
"Please give the app permission to access your files to be able to select one.": "Bitte gebe der App die Erlaubnis, auf deine Dateien zuzugreifen, um eine auswählen zu können.",
"Valid from {}": "Gültig ab {}",
"Valid till {}": "Gültig bis {}"
}
6 changes: 4 additions & 2 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,7 @@
"No QR code was found in the selected file. Please try another one.": "No QR code was found in the selected file. Please try another one.",
"The QR code in the selected file is invalid. Please try again.": "The QR code in the selected file is invalid. Please try again.",
"You have already added this QR code. Please select another file.": "You have already added this QR code. Please select another file.",
"Please give the app permission to access your files to be able to select one.": "Please give the app permission to access your files to be able to select one."
}
"Please give the app permission to access your files to be able to select one.": "Please give the app permission to access your files to be able to select one.",
"Valid from {}": "Valid from {}",
"Valid till {}": "Valid till {}"
}
33 changes: 32 additions & 1 deletion lib/elements/pass_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,37 @@ class PassInfo {
}
}

static String getRemaining(GreenCertificate cert) {
RegulationResult? result;
result = RegulationsProvider.getUserRegulation().validate(cert);
if (result == null)
return '';

if (result.type == RegulationResultType.not_valid_yet) {
switch (cert.certificateType) {
case CertificateType.vaccination:
return 'Valid from {}'.tr(args: [DateFormat('dd.MM.yyyy').format(result.relevantTime)]);
case CertificateType.recovery:
return 'Valid from {}'.tr(args: [DateFormat('dd.MM.yyyy').format(result.relevantTime)]);
case CertificateType.test:
return 'Valid from {}'.tr(args: [DateFormat('dd.MM.yyyy | HH:mm').format(result.relevantTime)]);
case CertificateType.unknown:
return 'Unknown'.tr();
}
} else {
switch (cert.certificateType) {
case CertificateType.vaccination:
return 'Valid till {}'.tr(args: [DateFormat('dd.MM.yyyy').format(result.relevantTime)]);
case CertificateType.recovery:
return 'Valid till {}'.tr(args: [DateFormat('dd.MM.yyyy').format(result.relevantTime)]);
case CertificateType.test:
return 'Valid till {}'.tr(args: [DateFormat('dd.MM.yyyy | HH:mm').format(result.relevantTime)]);
case CertificateType.unknown:
return 'Unknown'.tr();
}
}
}

static Widget getSmallPassCard(GreenCertificate cert) {
Color cardColor = GPColors.blue;
Color textColor = Colors.white;
Expand Down Expand Up @@ -209,4 +240,4 @@ class PassInfo {
],
);
}
}
}
10 changes: 9 additions & 1 deletion lib/views/my_passes_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ class _MyPassesPageState extends State<MyPassesPage> with AutomaticKeepAliveClie
fontWeight: FontWeight.bold,
),
),
Padding(padding: const EdgeInsets.symmetric(vertical: 2.0)),
Text(
PassInfo.getRemaining(certs[idx]),
style: TextStyle(
color: textColor,
fontSize: 15.0,
),
),
],
),
),
Expand Down Expand Up @@ -263,4 +271,4 @@ class _MyPassesPageState extends State<MyPassesPage> with AutomaticKeepAliveClie

@override
bool get wantKeepAlive => true;
}
}