Offline screen auto reconnect
This commit is contained in:
parent
0ada78e781
commit
68d313de01
|
|
@ -54,7 +54,7 @@ android {
|
|||
applicationId "com.Xperience.FaucetHub"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
minSdkVersion 19
|
||||
targetSdkVersion flutter.targetSdkVersion
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:external_app_launcher/external_app_launcher.dart';
|
||||
import 'package:fhub/backend/DebugHelper.dart';
|
||||
import 'package:fhub/home.dart';
|
||||
import 'package:fhub/src/CustomWidgets.dart';
|
||||
import 'package:fhub/welcome.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class OfflinePage extends StatefulWidget {
|
||||
|
|
@ -8,7 +12,7 @@ class OfflinePage extends StatefulWidget {
|
|||
@override
|
||||
State<OfflinePage> createState() => _OfflinePageState();
|
||||
}
|
||||
|
||||
var subscription;
|
||||
class _OfflinePageState extends State<OfflinePage> {
|
||||
|
||||
@override
|
||||
|
|
@ -17,6 +21,29 @@ class _OfflinePageState extends State<OfflinePage> {
|
|||
super.initState();
|
||||
|
||||
kickstartAnimations();
|
||||
|
||||
subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) async{
|
||||
// Got a new connectivity status!
|
||||
try{
|
||||
final connectivityResult = await (Connectivity().checkConnectivity());
|
||||
Debug.Log(connectivityResult);
|
||||
if(connectivityResult == ConnectivityResult.mobile || connectivityResult == ConnectivityResult.wifi || connectivityResult == ConnectivityResult.ethernet || connectivityResult == ConnectivityResult.vpn){
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_)=>MyHomePage()));
|
||||
|
||||
return;
|
||||
}
|
||||
}catch(e){
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
|
||||
subscription.cancel();
|
||||
}
|
||||
|
||||
void kickstartAnimations() async {
|
||||
|
|
@ -41,9 +68,11 @@ class _OfflinePageState extends State<OfflinePage> {
|
|||
|
||||
},
|
||||
context: context,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: id == 0 ? NoInternet() : ( id == 1 ? NewUpdate():Maintaince())
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: id == 0 ? NoInternet() : ( id == 1 ? NewUpdate():Maintaince())
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
try{
|
||||
final connectivityResult = await (Connectivity().checkConnectivity());
|
||||
Debug.Log(connectivityResult);
|
||||
if(connectivityResult != ConnectivityResult.mobile && connectivityResult != ConnectivityResult.mobile && connectivityResult != ConnectivityResult.ethernet){
|
||||
if(connectivityResult != ConnectivityResult.mobile && connectivityResult != ConnectivityResult.wifi && connectivityResult != ConnectivityResult.ethernet && connectivityResult != ConnectivityResult.vpn){
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_)=>OfflinePage(id:0)));
|
||||
|
||||
return;
|
||||
|
|
@ -55,7 +55,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
|
||||
void init() async{
|
||||
|
||||
|
||||
int serverVersion = await DataManager.GetVersion();
|
||||
if(serverVersion > 0 && serverVersion != DataManager.ClientVersion){
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> UpdatePage()));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.0+1
|
||||
version: 1.0.2+2
|
||||
|
||||
environment:
|
||||
sdk: '>=3.0.1 <4.0.0'
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user