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 @@ ...@@ -157,7 +157,7 @@
97C146E61CF9000F007C117D /* Project object */ = { 97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 1020; LastUpgradeCheck = 1300;
ORGANIZATIONNAME = ""; ORGANIZATIONNAME = "";
TargetAttributes = { TargetAttributes = {
97C146ED1CF9000F007C117D = { 97C146ED1CF9000F007C117D = {
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1020" LastUpgradeVersion = "1300"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
......
...@@ -6,6 +6,7 @@ import 'dart:typed_data'; ...@@ -6,6 +6,7 @@ import 'dart:typed_data';
import 'package:connectivity/connectivity.dart'; import 'package:connectivity/connectivity.dart';
import 'package:digital_3g_common/backend_switcher.dart'; import 'package:digital_3g_common/backend_switcher.dart';
import 'package:digital_3g_common/content_dialog.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/ui.dart';
import 'package:digital_3g_common/verification_api.dart'; import 'package:digital_3g_common/verification_api.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -387,21 +388,6 @@ class _HomePageState extends State<HomePage> { ...@@ -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 @override
void dispose() { void dispose() {
_clockTimer?.cancel(); _clockTimer?.cancel();
...@@ -413,6 +399,7 @@ class _HomePageState extends State<HomePage> { ...@@ -413,6 +399,7 @@ class _HomePageState extends State<HomePage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_bloc = BlocProvider.of<VerificationBloc>(context);
_clockTimer = Timer.periodic(const Duration(seconds: 1), (timer) { _clockTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
setState(() { setState(() {
_currentDate = DateTime.now(); _currentDate = DateTime.now();
...@@ -421,7 +408,9 @@ class _HomePageState extends State<HomePage> { ...@@ -421,7 +408,9 @@ class _HomePageState extends State<HomePage> {
_refreshTimer = Timer.periodic(const Duration(seconds: 30), (timer) { _refreshTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
_bloc!.onCheck(); _bloc!.onCheck();
}); });
_connectionListener = Connectivity().onConnectivityChanged.listen(_throwConnectivityResult); _initConnectivity();
_initPreferences();
_loadMotd();
} }
@override @override
...@@ -434,6 +423,40 @@ class _HomePageState extends State<HomePage> { ...@@ -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 { void _onDeleteTicket() async {
final result = await showDialog<bool>( final result = await showDialog<bool>(
context: context, context: context,
......
...@@ -31,6 +31,7 @@ class VerificationBloc extends Bloc<VerificationEvent, VerificationState> { ...@@ -31,6 +31,7 @@ class VerificationBloc extends Bloc<VerificationEvent, VerificationState> {
_initVerificationStore().then((_) => _initTicketFile().then((value) => _loadTicket())); _initVerificationStore().then((_) => _initTicketFile().then((value) => _loadTicket()));
} }
VerificationApi? get api => _api;
VerificationErrorType? get error => _error; VerificationErrorType? get error => _error;
String? get ticket => _ticket; String? get ticket => _ticket;
VerificationResponse? get verification => _verification; 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