fixed possible lockups on app start
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../model/account_data.dart';
|
||||
import '../../theming/light_app_theme.dart';
|
||||
import '../../widget/app_progress_indicator.dart';
|
||||
|
||||
/// Shown while the stored session is still being read. Normally gone within
|
||||
/// a second; after [hintDelay] it offers a way out so a keychain that keeps
|
||||
/// failing can never trap the user on a spinner.
|
||||
class AccountLoadingScreen extends StatefulWidget {
|
||||
const AccountLoadingScreen({super.key});
|
||||
|
||||
static const Duration hintDelay = Duration(seconds: 15);
|
||||
|
||||
@override
|
||||
State<AccountLoadingScreen> createState() => _AccountLoadingScreenState();
|
||||
}
|
||||
|
||||
class _AccountLoadingScreenState extends State<AccountLoadingScreen> {
|
||||
Timer? _hintTimer;
|
||||
bool _showHint = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_hintTimer = Timer(AccountLoadingScreen.hintDelay, () {
|
||||
if (mounted) setState(() => _showHint = true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_hintTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
backgroundColor: LightAppTheme.marianumRed,
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const AppProgressIndicator.large(color: Colors.white),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Konto wird geladen…',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
if (_showHint) ...[
|
||||
const SizedBox(height: 32),
|
||||
const Text(
|
||||
'Das dauert länger als üblich. Die gespeicherte Anmeldung '
|
||||
'konnte noch nicht gelesen werden.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextButton(
|
||||
onPressed: AccountData().abandonLoad,
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.white),
|
||||
child: const Text('Zur Anmeldung'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user