Commit 78afe1fe authored by Leon Tappe's avatar Leon Tappe 🔥
Browse files

get message of the day into verification app

parent 6fbf34fa
......@@ -157,7 +157,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
......@@ -6,6 +6,7 @@ import 'dart:typed_data';
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/theme.dart';
import 'package:digital_3g_common/ui.dart';
import 'package:digital_3g_common/verification_api.dart';
import 'package:flutter/material.dart';
......@@ -387,21 +388,6 @@ class _HomePageState extends State<HomePage> {
);
}
@override
void didChangeDependencies() async {
_bloc = BlocProvider.of<VerificationBloc>(context);
final connected = await Connectivity().checkConnectivity();
setState(() => _disconnected = connected == ConnectivityResult.none);
if (_disconnected) {
_throwConnectivityResult(connected);
}
final prefs = await SharedPreferences.getInstance();
setState(() => _showHelp = prefs.getBool('show_help') ?? true);
super.didChangeDependencies();
}
@override
void dispose() {
_clockTimer?.cancel();
......@@ -413,6 +399,7 @@ class _HomePageState extends State<HomePage> {
@override
void initState() {
super.initState();
_bloc = BlocProvider.of<VerificationBloc>(context);
_clockTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
setState(() {
_currentDate = DateTime.now();
......@@ -421,7 +408,9 @@ class _HomePageState extends State<HomePage> {
_refreshTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
_bloc!.onCheck();
});
_connectionListener = Connectivity().onConnectivityChanged.listen(_throwConnectivityResult);
_initConnectivity();
_initPreferences();
_loadMotd();
}
@override
......@@ -434,6 +423,40 @@ class _HomePageState extends State<HomePage> {
}
}
Future<void> _initConnectivity() async {
final connected = await Connectivity().checkConnectivity();
setState(() => _disconnected = connected == ConnectivityResult.none);
if (_disconnected) {
_throwConnectivityResult(connected);
}
_connectionListener = Connectivity().onConnectivityChanged.listen(_throwConnectivityResult);
}
Future<void> _initPreferences() async {
final prefs = await SharedPreferences.getInstance();
setState(() => _showHelp = prefs.getBool('show_help') ?? true);
}
Future<void> _loadMotd() async {
final message = await _bloc!.api!.getMotd();
if (message.isEmpty) return;
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Systemnachricht',
style: Theme.of(context).textTheme.headline5!.copyWith(color: magenta),
),
Text(message)
],
),
duration: const Duration(seconds: 20),
));
}
void _onDeleteTicket() async {
final result = await showDialog<bool>(
context: context,
......
......@@ -31,6 +31,7 @@ class VerificationBloc extends Bloc<VerificationEvent, VerificationState> {
_initVerificationStore().then((_) => _initTicketFile().then((value) => _loadTicket()));
}
VerificationApi? get api => _api;
VerificationErrorType? get error => _error;
String? get ticket => _ticket;
VerificationResponse? get verification => _verification;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment