freezer/lib/ui/error.dart

64 lines
1.6 KiB
Dart
Raw Normal View History

2021-07-02 16:28:59 +00:00
import 'package:connectivity/connectivity.dart';
2020-06-23 19:23:12 +00:00
import 'package:flutter/material.dart';
2021-07-02 16:28:59 +00:00
import 'package:flutter/widgets.dart';
import 'package:freezer/translations.i18n.dart';
2020-06-23 19:23:12 +00:00
2021-07-02 16:28:59 +00:00
int counter = 0;
2020-06-23 19:23:12 +00:00
2021-07-02 16:28:59 +00:00
class ErrorScreen extends StatefulWidget {
2020-06-23 19:23:12 +00:00
final String message;
2021-07-02 16:28:59 +00:00
const ErrorScreen({this.message, Key key}) : super(key: key);
2020-06-23 19:23:12 +00:00
2021-07-02 16:28:59 +00:00
@override
_ErrorScreenState createState() => _ErrorScreenState();
}
class _ErrorScreenState extends State<ErrorScreen> {
bool checkArl = false;
@override
void initState() {
Connectivity().checkConnectivity().then((connectivity) {
if (connectivity != ConnectivityResult.none && counter > 3) {
setState(() {
checkArl = true;
});
}
});
counter += 1;
super.initState();
}
2020-06-23 19:23:12 +00:00
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(
Icons.error,
color: Colors.red,
size: 64.0,
),
Container(height: 4.0,),
2021-07-02 16:28:59 +00:00
Text(widget.message ?? 'Please check your connection and try again later...'.i18n),
if (checkArl)
Padding(
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 32.0),
child: Text(
"Your ARL might be expired, try logging out and logging back in using new ARL or browser.".i18n,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12.0,
),
),
)
2020-06-23 19:23:12 +00:00
],
),
);
}
}