Skip to content
Snippets Groups Projects
Commit 91233c31 authored by Leon Tappe's avatar Leon Tappe :fire:
Browse files

add a test dialog to test

parent 4e67dddd
No related branches found
No related tags found
No related merge requests found
......@@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
class ErrorColumn extends StatelessWidget {
final String text;
final Widget? action;
final List<Widget> actions;
const ErrorColumn(this.text, {Key? key, this.action}) : super(key: key);
const ErrorColumn(this.text, {Key? key, this.actions = const []}) : super(key: key);
@override
Widget build(BuildContext context) {
......@@ -12,8 +12,8 @@ class ErrorColumn extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(text, style: Theme.of(context).textTheme.headline4, textAlign: TextAlign.center),
if (action != null) const Divider(),
action ?? const SizedBox(height: 0.0, width: 0.0)
if (actions.isNotEmpty) const Divider(),
...actions,
],
);
}
......
......@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:connectivity/connectivity.dart';
import 'package:digital_3g_common/backend_switcher.dart';
import 'package:digital_3g_common/content_dialog.dart';
import 'package:digital_3g_common/ui.dart';
import 'package:digital_3g_common/verification_api.dart';
import 'package:flutter/material.dart';
......@@ -141,50 +142,76 @@ class _HomePageState extends State<HomePage> {
else if (state == VerificationState.unverified)
ErrorColumn(
'Dein Nachweis ist nicht mehr gültig',
action: ElevatedButton(
onPressed: _onDeleteTicket,
child: const Text('Nachweis löschen'),
),
actions: [
ElevatedButton(
onPressed: _onDeleteTicket,
child: const Text('Nachweis löschen'),
),
ElevatedButton(
onPressed: () => showDialog(
context: context,
builder: (_) => const ContentDialog(
title: Text('Dein Nachweis ist nicht mehr gültig'),
children: [
Text('Der Endzeitpunkt deines Nachweises wurde erreicht. Das bedeutet, dass du deinen aktuellen Nachweis nicht weiter nutzen kannst. Du solltest deinen Nachweis löschen und an der Akkreditierungsstelle einen neuen Nachweis einholen.'),
Divider(),
Text('Die verschiedenen Nachweise haben ab dem Scannen des QR-Codes folgende Laufzeiten'),
Text('Test: 24 Stunden'),
Text('Genesen: Ein halbes Jahr, maximal bis zum Semesterende'),
Text('Geimpft: Bis zum Semesterende'),
],
)),
child: const Text('Hilfe anzeigen'),
),
],
)
else if (state == VerificationState.error)
if (_bloc!.error == VerificationErrorType.encryption)
ErrorColumn(
'Der Schlüssel deines Nachweises ist ungültig',
action: ElevatedButton(
onPressed: _onDeleteTicket,
child: const Text('Nachweis löschen'),
),
actions: [
ElevatedButton(
onPressed: _onDeleteTicket,
child: const Text('Nachweis löschen'),
),
],
)
else if (_bloc!.error == VerificationErrorType.oldseed)
ErrorColumn(
'Dieser QR-Code ist bereits abgelaufen',
action: ElevatedButton(
onPressed: _bloc!.onRevoke,
child: const Text('Erneut probieren'),
),
actions: [
ElevatedButton(
onPressed: _bloc!.onRevoke,
child: const Text('Erneut probieren'),
),
],
)
else if (_bloc!.error == VerificationErrorType.signing)
ErrorColumn(
'Die Signatur deines Nachweises ist ungültig',
action: BlocProvider.of<BackendSwitcher>(context).mode ==
BackendMode.development
? ElevatedButton(
onPressed: () =>
Navigator.of(context).pushNamed('/settings'),
child: const Text('Zu den Einstellungen'),
)
: ElevatedButton(
onPressed: _onDeleteTicket,
child: const Text('Nachweis löschen'),
),
actions: [
BlocProvider.of<BackendSwitcher>(context).mode ==
BackendMode.development
? ElevatedButton(
onPressed: () =>
Navigator.of(context).pushNamed('/settings'),
child: const Text('Zu den Einstellungen'),
)
: ElevatedButton(
onPressed: _onDeleteTicket,
child: const Text('Nachweis löschen'),
),
],
)
else if (_bloc!.error == VerificationErrorType.server)
ErrorColumn(
'Es gibt ein Problem bei der Serververbindung',
action: ElevatedButton(
onPressed: _bloc!.onCheck,
child: const Text('Erneut probieren'),
),
actions: [
ElevatedButton(
onPressed: _bloc!.onCheck,
child: const Text('Erneut probieren'),
),
],
)
else
Text(
......@@ -212,7 +239,9 @@ class _HomePageState extends State<HomePage> {
return const SizedBox(width: 0.0, height: 0.0);
},
),
if (state != VerificationState.noTicket && state != VerificationState.error && state != VerificationState.unverified)
if (state != VerificationState.noTicket &&
state != VerificationState.error &&
state != VerificationState.unverified)
Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment